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
Is There a C# Case Insensitive Equals Operator
How to Manage Files on an Mtp Portable Device
How to Call (Iron)Python Code from a C# App
Webexception How to Get Whole Response with a Body
Use Linq to Group a Sequence of Numbers with No Gaps
Pair-Wise Iteration in C# or Sliding Window Enumerator
No Type Inference with Generic Extension Method
Task Continuation on UI Thread
How to Read an Excel File in C# Without Using Microsoft.Office.Interop.Excel Libraries
Log4Net Rolling Daily Filename with Date in the File Name
Start Android Service from Unity3D Code
Python: Inflate and Deflate Implementations
What's the Difference Between System.Type and System.Runtimetype in C#
An Attribute Argument Must Be a Constant Expression, ...- Create an Attribute of Type Array