Using Ffmpeg in .Net

Use (ffmpeg) executable inside C#.NET project

Ok, I figured it out. For anyone else looking to write a .NET wrapper for ffmpeg. Download the 'shared' version. Add the contents of the 'bin' folder (with the executables) to your project. Just by doing right click your solution -> add new item...

Then you can use the executable as follows.

You can have ffmpeg, ffprobe etc.. output in json or xml. So you can parse the output and do whatever.

ProcessStartInfo startInfo = new ProcessStartInfo();

startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ffmpeg\\ffmpeg.exe");
startInfo.Arguments = "-f dshow -i video=\"Front Camera\"";
startInfo.RedirectStandardOutput = true;
//startInfo.RedirectStandardError = true;

Console.WriteLine(string.Format(
"Executing \"{0}\" with arguments \"{1}\".\r\n",
startInfo.FileName,
startInfo.Arguments));

try
{
using (Process process = Process.Start(startInfo))
{
while (!process.StandardOutput.EndOfStream)
{
string line = process.StandardOutput.ReadLine();
Console.WriteLine(line);
}

process.WaitForExit();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}

Console.ReadKey();

Happy coding.

How can I use ffmpeg.net in my winfoms(c#)?

You can also use ffmpeg.exe directly. I have i.e done so to generate an image automatically when a videofile is uploaded to our cms system.

Please check out this blog (not mine): http://jasonjano.wordpress.com/2010/02/09/a-simple-c-wrapper-for-ffmpeg/

Using FFmpeg in C# project

This is my sample, hope this help

You can use .exe file like this:

ffmpeg.StartInfo.UseShellExecute = false;
ffmpeg.StartInfo.RedirectStandardOutput = true;
ffmpeg.StartInfo.FileName = Server.MapPath("~/Video_Clips/ffmpeg.exe");

ffmpeg.StartInfo.Arguments = String.Format(@"-i ""{0}"" -threads 8 -f webm -aspect 16:9 -vcodec libvpx -deinterlace -g 120 -level 216 -profile 0 -qmax 42 -qmin 10 -rc_buf_aggressivity 0.95 -vb 2M -acodec libvorbis -aq 90 -ac 2 ""{1}""",
Server.MapPath("~/Video_Clips/" + sNameWithoutExtension + ".wmv"),
Server.MapPath("~/Video_Clips/" + sNameWithoutExtension + ".webm"));
ffmpeg.Start();

ffmpeg.WaitForExit();


Related Topics



Leave a reply



Submit