Solved

Microsoft Encoder 4 works on local but not on remote

Posted on 2012-03-24
6
384 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
  • 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
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 use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

832 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