c# and ffmpeg

The first thing i’m going to talk about here is  how to use c# and ffmpeg.

Do you know what we can do with those two? Our private youtube stuff.

The need: Multimedia files in sharepoint but we want everybody to be able to see them independently if they have this or that program (eg: media player or quicktime…) so all videos must be converted to flv (Macromedia Flash video format). 

I searched the web for something that was already done but haven’t found much, you have:


None of them suited me sharpffmpeg looked like the most promissing but there’s no documentation. I thought with the time i’ll take to understand how to use it I could do one myself. And i did. Something simple that served my needs.

All i want is to get a movie and pass it to flv format. Simple and easy. How you do it?

First you need ffmpeg after that i created a console application and sent my commands to it.

System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = @”””C:\edgar\mediaHandler\ffmpeg\ffmpeg”””;
proc.StartInfo.Arguments = “-i C:\\edgar\\mediaHandler\\ffmpeg\1.mpg -ar 22050 -ab 32 -f flv -s 320×240 -aspect 4:3 -y movie4.flv”; /* use /y to overwrite if there it exists already or will fail */
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = false;
proc.StartInfo.RedirectStandardOutput = true;

You could elaborate the code more, i will probably do it later, but for now it’s up to you.
Please comment if this was of any help to you.

I edited this post just to tell you that this was a prototype. I have never used it again. So i’m not the right person to ask questions.

If anybody has got further into this issue and would like to help others please comment.



  1. very helpful. thanks.

  2. Hey,
    I am trying to do the same thing and I found your page. I run ffmpeg like this:

    Process process = new Process();

    process.StartInfo.FileName = @”” + fullPath + “\\Manage\\ffmpeg.exe”;
    process.StartInfo.Arguments = “-i \”movie.wmv\” -an -ss 00:00:03 -s 120×90 -vframes 1 -f mjpeg \”thumbnail.jpg\””;

    process.StartInfo.UseShellExecute = false;
    process.StartInfo.RedirectStandardError = true;
    process.StartInfo.CreateNoWindow = false;
    process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

    string output2 = process.StandardError.ReadToEnd();

    The problem is that it runs ffmpeg but does not include arguments at all… It jus shows standard output when you type ffmpeg in command line… I would appreciate any help 🙂

    Thanks !

  3. Hey, I found the solution 🙂

    You have to provide always full path:
    proc.StartInfo.Arguments = “-i \”” + fullPath + “\\Manage\\Temp\\” + fileName + “\” -an -ss 00:00:01 -s 120×90 -vframes 1 -f mjpeg \”” + fullPath + “\\Manage\\Temp\\” + name + “.jpg\

    where fullPath is full path 🙂 I mean C:\ and so on 🙂


  4. Hi all,
    I’m spanish (so my english could be better xD), I’ve downloaded open source SharpFFmpeg, because I need a C# video coder to implement it in sensors, and I first need to test it in my PC. I try to compile it and shows:
    A proyect with an Output Type of Class Library cannot be started directly
    where can I introduce the coomands you’ve written? in a console application…how? :S Thanks for your time.

  5. jesscerezap as u can see i did not use SharpFFmpeg.

    from c# i execute commands to the program ffmpeg.

    yes you do it in a console application.
    Create a console application in visual studio
    paste my code to it.
    and then change:
    proc.StartInfo.FileName to your ffmpegDirectory/ffmpeg
    proc.StartInfo.Arguments for your needs

    your english is pretty good.

  6. How can i create a thumbnail image from a flash file ? I tried the above code,its not working.Which other part i need to change ? Thanks in advance

    • The code in my post describes how to use ffmpeg with c#. And that’s all it is for. You should read the documentation of ffmpeg.

  7. You should check out the Podcasting Kit for SharePoint


    And my admittedly not so great solution for using ffmpeg as a converter in the archives of this project. Later versions use expression express and now the pks kit has encoding built in however if you are dead set on using ffmpeg you can probably upgrade my code to get it working

  8. I finally wrote up a blog about my own c# wrapper for ffmpeg. It has a detailed code listing, here:


  9. nice article, thanks..

    • thanks a lot!

Comments RSS TrackBack Identifier URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s