[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Microsoft Encoder 4 works on local but not on remote

Posted on 2012-03-24
6
Medium Priority
?
405 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 2000 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
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

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 …
This collection of functions covers all the normal rounding methods of just about any numeric value.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

873 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