Click here to Skip to main content
15,887,344 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm converting video's to .swf format and creating a single frame from that video to use as a thumbnail. The problem that I am facing is that the process is throwing an exception of system.InvalidOperationException. I've searched everywhere and still can't solve this... can somebody please help me out on how to fix this please....

this is what I have done:

C#
filargs = "C:\\Program Files\\ffmpeg\\ffmpeg.exe -i " + inputfile + " -ar 22050 " + outputfile;

string spath;
spath = Server.MapPath(".");
ProcessStartInfo procStartIfo = new ProcessStartInfo();
procStartIfo.FileName = "C:\\Program Files\\ffmpeg\\ffmpeg.exe";
procStartIfo.Arguments = filargs;
procStartIfo.UseShellExecute = false;
procStartIfo.CreateNoWindow = false;
procStartIfo.RedirectStandardOutput = true;

try
{
    var process = new Process();

        process.StartInfo = procStartIfo;
        process.Start();
        process.WaitForExit();

}
Posted
Updated 31-May-13 2:05am
v3
Comments
ZurdoDev 31-May-13 7:55am    
Which line of code is causing it. It is somewhat of a generic error so you need to narrow down what is causing it.
link_that 31-May-13 8:04am    
All of the code runs smoothly until var process = new Process. I know that the process has to start first, but even on process.start() and process.WaitforExit gives me this error, I can't track down from where it comes from... I have tested that the command arguments is working in the command prompt.. The exception doesn't get thrown into the catch though, but when I hover over this it gives me this exception.....
ZurdoDev 31-May-13 8:17am    
Phantom called it. Essentially it looks like you are calling "ffmpeg.exe ffmpeg.exe" which who knows what that will do. Your file args likely should just be the part started with "-i"
link_that 31-May-13 8:20am    
I removed the path in the fileArgs to start with = "-i"... but its still giving this error....
ZurdoDev 31-May-13 8:22am    
Try taking the fileargs off and see if you can just get ffmpeg to run.

1 solution

You need to put the path into double quotes because there is a space in it. Also, remove the path from your fileargs.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900