Solved

Microsoft Encoder 4 works on local but not on remote

Posted on 2012-03-24
6
374 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 1

Author Comment

by:mlg101
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This very simple solution applies to a narrow cross-section of the "needs to close" variety. In this case, the full message in Event Viewer was in applog, Event ID 1000: Faulting application iexplore.exe, version 8.0.6001.18702, faulting module …
Many companies are making the switch from Microsoft to Google Apps (https://www.google.com/work/apps/business/). Use this article to learn more about what Google Apps has to offer and to help if you’re planning on migrating to Google Apps. It is …
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now