Solved

Microsoft Encoder 4 works on local but not on remote

Posted on 2012-03-24
6
388 Views
Last Modified: 2012-08-13
I have a simple page that takes a video and encodes it using Microsoft encoder 4 and Visual Basic. my code is below and it works on my local server but does not work on my remote server. I'm using visual web developer 2010 as local test server. then after the same exact thing is uploaded to my server, the encoder doesn't work on the web.

<%@ Page Language="VB" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Threading" %>
<%@ Import Namespace="Microsoft.Expression.Encoder" %>
<%@ Import Namespace="Microsoft.Win32" %>
<%@ Import Namespace="Microsoft.Win32" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQLClient" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="system.io" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    Dim strOrigFile As String
    
    'Button 1 will save the actual video file to a folder called "OVideos" on the server 
    'and also input the filename in the SQLServer Database as a reference to the video file.
    Protected Sub Button1_Click(sender As Object, e As System.EventArgs)
        
        Try
            ' Get the HttpFileCollection

            Dim hfc As HttpFileCollection = Request.Files
            
            For i As Integer = 0 To hfc.Count - 1

                Dim hpf As HttpPostedFile = hfc(i)
                                
                If hpf.ContentLength > 0 Then

                    hpf.SaveAs(Server.MapPath("~/OVideos/") & "\" & Path.GetFileName(hpf.FileName))

                End If

            Next i

        Catch ex As Exception

            ' Handle your exception here

        End Try

        Dim fileName As String = FileUpload1.FileName
        Dim fileName2 As String = FileUpload1.PostedFile.FileName
        
        Dim strConn As String = "Data Source=myDataSource"
        Dim MySQL As String = "INSERT INTO Videos (OriginalFile, FLVFile) Values (@OriginalFile, @FlVFile)"
        Dim Conn As New SqlConnection(strConn)
        Dim Cmd As New SqlCommand(MySQL, Conn)
        Cmd.Parameters.Add(New SqlParameter("@OriginalFile", fileName.ToString()))
        Cmd.Parameters.Add(New SqlParameter("@FLVFile", fileName2.ToString()))
        Conn.Open()
        Cmd.ExecuteNonQuery()
    End Sub
    
    'Button2 will recall the name of the saved file and tell mediaitem where the video is
    Protected Sub Button2_Click(sender As Object, e As System.EventArgs)
        
        Dim strConn As String = "Data Source=myDataSource"
        Dim MySQL As String = "Select * From Videos Where ID = 9"
        Dim Conn As New SqlConnection(strConn)
        Dim objDR As SqlDataReader
        Dim Cmd As New SqlCommand(MySQL, Conn)
        Conn.Open()
        objDR = Cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
        While objDR.Read()
            strOrigFile = objDR("OriginalFile").ToString()
        End While
        Conn.Close()
        
        ' Create the media item.
        Dim mediaItem As MediaItem
        Dim fileName As String = Server.MapPath("OVideos/" & strOrigFile)
        msgs.Text = fileName
        Try
            
            mediaItem = New MediaItem(fileName)
        Catch exp As InvalidMediaFileException
            'IndicateEncodingIsFinished(exp.Message)
            Return
        End Try
       

        ' Create the job, add the media item and encode.
        Using job As New Job()
            job.MediaItems.Add(mediaItem)
            job.OutputDirectory = "c:\output"

            'AddHandler job.EncodeProgress, AddressOf OnProgress

            job.Encode()
            
           
            
        End Using
         
        'IndicateEncodingIsFinished("Finished")
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:FileUpload ID="FileUpload1" runat="server" />
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button 1" />
        <asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="Button 2" />
        <asp:label ID="msgs" runat="server"></asp:label>
    </div>
    
    </form>
</body>
</html>

Open in new window

0
Comment
Question by:mlg101
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 37762688
It is a good practice to add application logging.  Add an event handler in the Global.asax file for the Application_Error, and capture the details for the exception stack trace.  

There are different approaches for logging (Enterprise Application Block, log4net, ...).  I personally use log4net.

When you published the website, did you do it manually, or use the Publish Web Site option?
0
 
LVL 1

Author Comment

by:mlg101
ID: 37762811
I do some manually because my server is right next to my computer. But I also "open website" and make changes live because it saves me a step in having to sync.

So, when I run it, there are no errors, it just refreshes the page, so application logging will record the exception as if I put a breakpoint and were debugging?
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 37763015
If you get a reference to an Exception object, the ToString() method returns the full stack trace, including line numbers, if a .pdb file can be found.

You can debug an ASP.NET web site, if you have configured it to allow it, by attaching to the web hosting process.

This article talks about that process, and does a pretty good job describing the steps:

Debug your ASP.NET Application while Hosted on IIS
http://www.codeproject.com/Articles/37182/Debug-your-ASP-NET-Application-while-Hosted-on-IIS
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 1

Author Comment

by:mlg101
ID: 37764316
after remote debug, the exception is "Cannot find video codec: XVID"

I found 1 google result for that dealing with expression enoder, but it didn't solve the issue
0
 
LVL 1

Author Closing Comment

by:mlg101
ID: 37764331
After downloading XVID codec on the server, it worked!! I just can't believe it worked. Thank you for your help. Although you make me work for the answers, it is more worth it because I learn instead of you doing it all for me.  thanks again!!
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 37765446
I love to make people work, because there is the opportunity to learn from the pain.  Some of my most important wins came right after huge moments of pain and struggle.  I have the opportunity to learn so much more than if it was an easy task.  It is as if you were driving with someone, and they knew the way, and then you have to drive that same way.  Until you do the driving, you won't really know all the turns.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question