We have an ASP.NET web application (C#) that copies videos from a CCTV truck to a Linux server. What I am trying to do is convert the .AVI videos(which is how they are created on the truck) to .WMV in my C# code using Windows Media Encoder. I have a virtual directory to the truck location of the videos. I also have a virtual directory created to the Linux box. The application resides on a Windows Server 2003 and I am using VS 2005, .NET framework 2.0. The web app uses impersonation and the virtual directories are set up to connect with the impersonated user. When I use the application to copy the videos without converting, it works perfectly. When I try to implement the conversion code I receive the following error: Attempted to read or write protected memory. This is often an indication that other memory has been corrupted
The line that fails is: m_Encoder.PrepareToEncode(true);
I have been Googling this error for days now and have found few solutions. I have tried some of the solutions I did manage to find, but nothing has helped. I'm thinking it's a permissions issue, but I can't figure out what! Any help would be greatly appreciated and please let me know if you need any more information. I am totally new to WME so I could even be doing this all wrong!
Thanks in Advance,
Carmen
Here is the code I'm using for the conversion and then the method where I am calling the ConvertFile function: - private static string ConvertFile(string mediaFile)
-
{
-
UtilDaoOracle oraDao = new UtilDaoOracle();
-
oraDao.LogError(mediaFile, "ConvertFile", 500321);
-
-
WMEncoder m_Encoder = new WMEncoder();
-
-
IWMEncSourceGroup SrcGrp = (IWMEncSourceGroup)m_Encoder.SourceGroupCollection.Add("SG_1");
-
IWMEncVideoSource SrcVid = (IWMEncVideoSource)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
-
-
-
SrcVid.SetInput(mediaFile, "", "");
-
-
const string ProfileName = "Screen Video Medium (CBR)";
-
-
foreach (IWMEncProfile aProfile in m_Encoder.ProfileCollection)
-
{
-
if (aProfile.Name == ProfileName)
-
{
-
SrcGrp.set_Profile(aProfile);
-
oraDao.LogError(aProfile.Name.ToString(), "ConvertFileLoop", 500321);
-
break;
-
}
-
}
-
-
-
m_Encoder.File.LocalFileName = Regex.Replace(mediaFile, ".avi", ".wmv");
-
oraDao.LogError(m_Encoder.File.LocalFileName, "ConvertFileREturn", 500321);
-
-
m_Encoder.AutoStop = true;
-
-
try
-
{
-
m_Encoder.PrepareToEncode(true);
-
}
-
catch (Exception exp)
-
{
-
oraDao.LogError(exp.Message, "Preparetoencode", 500321);
-
m_Encoder.Flush();
-
}
-
-
try
-
{
-
m_Encoder.Start();
-
}
-
catch (Exception exp)
-
{
-
oraDao.LogError(exp.Message, "encoderstart", 500321);
-
m_Encoder.Flush();
-
}
-
-
return m_Encoder.File.LocalFileName;
-
-
}
-
-
-
private static bool CopyFile(string srcDir, string destDir, string fileName, bool ignoreIfInParentDir)
-
{
-
-
UtilDaoOracle oraDao = new UtilDaoOracle();
-
FileInfo destFile = new FileInfo(CombinePath(destDir, fileName));
-
-
//Only copy if the file does not already exist.
-
if (!destFile.Exists)
-
{
-
if (ignoreIfInParentDir && File.Exists(CombinePath(destFile.Directory.Parent.FullName, fileName)))
-
{
-
// Return if the files already exists in the parent directory.
-
return false;
-
}
-
-
FileInfo srcFile = new FileInfo(CombinePath(srcDir, fileName));
-
if (srcFile.Exists)
-
{
-
// Create the destination directory if not there already.
-
if (!destFile.Directory.Exists)
-
{
-
destFile.Directory.Create();
-
}
-
-
if (srcFile.Extension == ".avi")
-
{
-
string convertedFile = ConvertFile(srcFile.ToString());
-
FileInfo convertedFileDone = new FileInfo(convertedFile);
-
convertedFileDone.CopyTo(destFile.FullName);
-
}
-
else
-
{
-
srcFile.CopyTo(destFile.FullName);
-
}
-
-
return true;
-
}
-
else
-
{
-
Logger.LogWarning(string.Format("Source file not found on machine: {0}", srcFile.FullName));
-
}
-
}
-
return false;
-
}
-
0 1907 Sign in to post your reply or Sign up for a free account.
Similar topics
by: Greg |
last post by:
Does anybody know how to pass session variables from one
window to a new window in an ASP.net web application?
Please help.
Peace Out
Greg
|
by: Rob R. Ainscough |
last post by:
What is it with Microsoft, do they normally publish tools that don't work
and provide migrations that don't work either? Publish Web just goes to
never never land once I log into my server after...
|
by: ruca |
last post by:
Hi,
In my Web Application I have windows authenthication logon. Usually login
dialog don't appear, but in one of the computers this dialog appears when
it's not supposed. If I logon the Web App...
|
by: Lance Wynn |
last post by:
Hi all,
I got a new computer that is running XP Home, and is to be used for the
family as well as for me to do some work from home. I want to keep XP Home,
but I am having a problem getting...
|
by: booksnore |
last post by:
At the moment I have three separate setup projects for my C# ASP.NET
application one for the web project, one that uses Custom actions and
some code to create the database and then one which uses...
|
by: theBond |
last post by:
hello!
i am making a program which opens a word document which is kept on IIS server to be open from client web interface which can take some parameter.
i.e if i open the web page where i will...
|
by: coolmanist |
last post by:
Hi, I am working on a project in which I have to present a wysiwyg editor. I have to save this code as .doc, .rtf or .tiff format in server side. I am using C# and this is a web application.
My...
|
by: karthik25 |
last post by:
Hi All,
I have a problem in finding control in a dynamically created updated panel. I have given the code below. Following is just a starting effort in a completely dynamic user control. I am...
|
by: skcsknathan001 |
last post by:
I have 2 projects, and accessing a custom control , fron another project. Inside the custom control, it calls a function It compiles and when it runs I get a NullReference error message on the...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |