Click here to Skip to main content
15,886,640 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on a small project that needs to use ffmpeg to pull out some video from the main video. I have called the following within a command prompt and get my 8 second video named correctly in the folder:

ffmpeg -ss 00:47:25 -t 8 -i C:\\Personal\\TestData\\MainVideo.mp4 -vcodec copy -acodec copy C:\\Personal\\TestData\\Portion1.mp4


However, when I try to run this from a Process.Start command it opens what looks like a command prompt, but doesn't save the file out.

var processn = Process.Start("CMD.exe", "/C ffmpeg -ss 00:47:25 -t 8 -i C:\\Personal\\TestData\\MainVideo.mp4 -vcodec copy -acodec copy C:\\Personal\\TestData\\Portion1.mp4");
                          processn.WaitForExit(50000);


I am out of ideas.
Thank you

What I have tried:

I have given full access to everyone on that folder.
I have tried calling the ffmpeg.exe directly and just pass in the parameter with no success.

var processStartInfo = new ProcessStartInfo(@"C:\FFmpeg\bin\ffmpeg.exe");
                        processStartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                        processStartInfo.Arguments = $"/C -ss 00:47:25 -t 8 -i C:\\Personal\\TestData\\MainVideo1.mp4 -vcodec copy -acodec copy C:\\Personal\\TestData\\Portion1.mp4";
                        processStartInfo.UseShellExecute = false;
                        processStartInfo.CreateNoWindow = true;

                        var processn = Process.Start(processStartInfo);
                        processn.EnableRaisingEvents = true;
                        processn.WaitForExit();
Posted
Updated 16-Aug-18 10:20am

1 solution

This is what I did to finally get it to work

var processStartInfo = new ProcessStartInfo(@"C:\FFmpeg\bin\ffmpeg.exe");
processStartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
processStartInfo.Arguments = $@"-ss {startTime} -t 8 -i C:\Personal\TestData\MainVideo.mp4 -vcodec copy -acodec copy C:\Personal\TestData\Portion{counter}.mp4";
processStartInfo.UseShellExecute = false;
processStartInfo.CreateNoWindow = true;
var processn = Process.Start(processStartInfo);
 
Share this answer
 
Comments
Dave Kreskowiak 16-Aug-18 18:41pm    
If you launch the CMD process with a /K instead of /C, the command prompt will stay open letting to see any errors the rest of your command line displayed.

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