mlg101
asked on
Microsoft Encoder 4 works on local but not on remote
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>
ASKER
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?
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
I found 1 google result for that dealing with expression enoder, but it didn't solve the issue
ASKER
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!!
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.
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?