C# and FFmpeg preferably without shell commands?

Viewed 19791

I'd like to be able to use FFmpeg to convert a video file from within my C# program. I know I can just call a shell command, but is there a better way?

The issue with invoking a command via the shell, is I'm not sure you could do things like a progress bar, etc... or could you?

If there isn't a way, can anyone suggest the best way to layout some framework for executing shell commands. Passing one big long string is very cumbersome atm.

5 Answers

I have found this post few weeks ago when I was looking for answer for my problem. I tried to start ffmpeg process and pass arguments to it but it take sooo long to do everything. At this point I use Xabe.FFmpeg as it doing this out of the box and don't have to worry about ffmpeg executables because have feature to download latest version.

bool conversionResult = await new Conversion().SetInput(Resources.MkvWithAudio)
  .AddParameter(String.Format("-f image2pipe -i pipe:.bmp -maxrate {0}k -r {1} -an -y {2}",bitrate, fps, outputfilename))
  .Start();

There is documentation available here that shows how to get current percent of conversion.

Related