Arun Kumar
Arun Kumar

Reputation: 303

ffmpeg c# asp.net help on ProcessStartInfo

I wrote the code to convert the file in c#asp.net using ffmpeg. While executing it shows error as "The filename, directory name, or volume label syntax is incorrect" but my paths are correct. So what is the solution for this?

ProcessStartInfo info = new ProcessStartInfo("e:\ffmpeg\bin\ffmpeg.exe", "-i cars1.flv -same_quant intermediate1.mpg");

process.Start();

I tried another way as shown below. But that is also won't works.

ProcessStartInfo info = new ProcessStartInfo("ffmpeg.exe", "-i cars1.flv -same_quant intermediate1.mpg");

Please help me with sample code for converting one video file format to another using ffmpeg in c# asp.net. Thanks in advance.

Upvotes: 1

Views: 3555

Answers (3)

Zaki
Zaki

Reputation: 5600

You need to have backslashes in your path see below this is how I create videos using ffmpeg.exe

        string sConverterPath = @"C:\ffmpeg.exe";
        string sConverterArguments = @" -i ";
        sConverterArguments += "\"" + sAVIFile + "\"";
        sConverterArguments += " -s " + iVideoWidth.ToString() + "x" + iVideoHeight.ToString() + " ";
        sConverterArguments += " -b " + iVideoBitRate.ToString() + "k -ab " + iAudioBitRate.ToString() + "k -ac 1 -ar 44100 -r 24 -absf remove_extra ";
        sConverterArguments += "\"" + sOutputFile + "\"";


        Process oProcess = new Process();
        oProcess.StartInfo.UseShellExecute = true;
        oProcess.StartInfo.Arguments = sConverterArguments;
        oProcess.StartInfo.FileName = sConverterPath;

Upvotes: 0

Deepu Madhusoodanan
Deepu Madhusoodanan

Reputation: 1505

There is wrapper library available

http://www.ffmpeg-csharp.com/

Also refer

http://www.codeproject.com/Articles/24995/FFMPEG-using-ASP-NET

https://stackoverflow.com/questions/tagged/asp.net+c%23+video

    string apppath = Request.PhysicalApplicationPath; 

    string outf = Server.MapPath(".");

    string fileargs = "-i" + " " + "\"C:/file.mp4 \"" + " " + "\"C:/files/test.flv \"";

    Process myProcess = new Process();

    myProcess.StartInfo.FileName = Server.MapPath(".")+"//ffmpeg.exe";

    myProcess.StartInfo.Arguments = fileargs;

    myProcess.StartInfo.UseShellExecute = false;

    myProcess.StartInfo.CreateNoWindow = false;

    myProcess.StartInfo.RedirectStandardOutput = false;

    myProcess.Start();

    myProcess.WaitForExit(50 * 1000);

Thanks

Deepu

Upvotes: 1

Justin
Justin

Reputation: 6711

The backslashes (\) in your path are considered to start escape sequences. To prevent this, either use double backslashes (\\), or prefix the string with @.

ProcessStartInfo info = new ProcessStartInfo("e:\\ffmpeg\\bin\\ffmpeg.exe", 
                         "-i cars1.flv -same_quant intermediate1.mpg");

Or:

ProcessStartInfo info = new ProcessStartInfo(@"e:\ffmpeg\bin\ffmpeg.exe", 
                         "-i cars1.flv -same_quant intermediate1.mpg");

Upvotes: 0

Related Questions