473,770 Members | 1,905 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# WEB:Trouble converting videos on virtual directories using Windows Media Encoder 9

1 New Member
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.Prepa reToEncode(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:

Expand|Select|Wrap|Line Numbers
  1. private static string ConvertFile(string mediaFile)
  2.         {            
  3.             UtilDaoOracle oraDao = new UtilDaoOracle();
  4.             oraDao.LogError(mediaFile, "ConvertFile", 500321);
  5.  
  6.             WMEncoder m_Encoder = new WMEncoder();
  7.  
  8.             IWMEncSourceGroup SrcGrp = (IWMEncSourceGroup)m_Encoder.SourceGroupCollection.Add("SG_1");
  9.             IWMEncVideoSource SrcVid = (IWMEncVideoSource)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
  10.  
  11.  
  12.             SrcVid.SetInput(mediaFile, "", "");
  13.  
  14.             const string ProfileName = "Screen Video Medium (CBR)";
  15.  
  16.             foreach (IWMEncProfile aProfile in m_Encoder.ProfileCollection)
  17.             {
  18.                 if (aProfile.Name == ProfileName)
  19.                 {
  20.                     SrcGrp.set_Profile(aProfile);
  21.                     oraDao.LogError(aProfile.Name.ToString(), "ConvertFileLoop", 500321);
  22.                     break;
  23.                 }
  24.             }
  25.  
  26.  
  27.             m_Encoder.File.LocalFileName = Regex.Replace(mediaFile, ".avi", ".wmv");
  28.             oraDao.LogError(m_Encoder.File.LocalFileName, "ConvertFileREturn", 500321);
  29.  
  30.             m_Encoder.AutoStop = true;
  31.  
  32.             try
  33.             {
  34.                 m_Encoder.PrepareToEncode(true);
  35.             }
  36.             catch (Exception exp)
  37.             {
  38.                 oraDao.LogError(exp.Message, "Preparetoencode", 500321);
  39.                 m_Encoder.Flush();
  40.             }
  41.  
  42.             try
  43.             {
  44.                 m_Encoder.Start();
  45.             }
  46.             catch (Exception exp)
  47.             {
  48.                 oraDao.LogError(exp.Message, "encoderstart", 500321);
  49.                 m_Encoder.Flush();
  50.             }
  51.  
  52.             return m_Encoder.File.LocalFileName;
  53.  
  54.         }
  55.  
  56.  
  57. private static bool CopyFile(string srcDir, string destDir, string fileName, bool ignoreIfInParentDir)
  58.         {
  59.  
  60.             UtilDaoOracle oraDao = new UtilDaoOracle();
  61.             FileInfo destFile = new FileInfo(CombinePath(destDir, fileName));
  62.  
  63.             //Only copy if the file does not already exist.
  64.             if (!destFile.Exists)
  65.             {
  66.                 if (ignoreIfInParentDir && File.Exists(CombinePath(destFile.Directory.Parent.FullName, fileName)))
  67.                 {
  68.                     // Return if the files already exists in the parent directory.
  69.                     return false;
  70.                 }
  71.  
  72.                 FileInfo srcFile = new FileInfo(CombinePath(srcDir, fileName));
  73.                 if (srcFile.Exists)
  74.                 {
  75.                     // Create the destination directory if not there already.
  76.                     if (!destFile.Directory.Exists)
  77.                     {
  78.                         destFile.Directory.Create();
  79.                     }
  80.  
  81.                     if (srcFile.Extension == ".avi")
  82.                     {
  83.                         string convertedFile = ConvertFile(srcFile.ToString());
  84.                         FileInfo convertedFileDone = new FileInfo(convertedFile);
  85.                         convertedFileDone.CopyTo(destFile.FullName);                        
  86.                     }
  87.                     else
  88.                     {
  89.                         srcFile.CopyTo(destFile.FullName);
  90.                     }
  91.  
  92.                     return true;
  93.                 }
  94.                 else
  95.                 {
  96.                     Logger.LogWarning(string.Format("Source file not found on machine: {0}", srcFile.FullName));
  97.                 }
  98.             }
  99.             return false;
  100.         }
  101.  
Feb 29 '08 #1
0 1929

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1647
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
2
1324
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 the User/Password login screen -- just a partially repainted VS 2005 screen and nothing else, no errors, no warnings, nothing. Just one more feature that doesn't work. I think I passed my limit of sanity some time ago. As far as ASP 1.1 to ASP...
1
1185
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 works fine, but every time I try to run on same computer, dialog appears. I think the problem maybe was the computer don't belong to domain and I change this setting. After this the problem persists and I don't know what to do more.
16
2226
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 Visual Interdev to connect to any FrontPage Webs. I get an error 401 on the IIS Logs, and in interdev, I just get the login prompt, until it tells me that I'm not authorized to view the web. I've searched the web, and can find no reason why this...
0
1136
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 Custom Actions to prompt the user for username and pwd when installing a windows service. I want to bundle all three into a single install. I'm not sure if this possible with Visual Studio alone, if it is then does anyone know of a good online...
0
1107
theBond
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 add some argunment to modify the word file from client. the same prog works if i run it from server but when i run from client it does not work. Do anyone know any method to do this where i can open server doc file and which can be modified at run...
1
4467
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 question is how to convert such an html page (or html code) to one of these formats. Any suggestions on these ? There are many 3rd party tools for this but I couldn't find a free one.
4
3492
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 experimenting before getting to the actual part. This is what I am trying to do: * Create a tab container dynamically * Create 5 tabs dynamically * Add an update panel to each of the tabs
3
2426
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 function which accepts the ImageButton. Basically custom control is called .. goes into execute functions, but the ImageButton control inside the custom control is not passed to the function. I'm thinking is it some permission blocking the visibility...
0
9618
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10259
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10101
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9906
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.