views:

1238

answers:

3

Hello

I am after a good tutorial or how to on using SharpFFMpeg or if there is an easy way to use ffmpeg in c# ...

I would like to convert video.(x format) to video.flv taking screenshots and saving them as i go.

If there is a good tutorial out there or you know an easy way to do please post it here.

Thanks, Kieran

A: 

Running command line args www.codeproject.com/KB/cs/Execute_Command_in_CSharp.aspx

Extracting images http://stream0.org/2008/02/howto-extract-images-from-a-vi.html

    protected void BTN_convert_Click(object sender, EventArgs e) {

  String runMe = @"C:\Documents and Settings\Wasabi Digital\My Documents\Visual Studio 2008\Projects\Evo\WEB\Bin\ffmpeg.exe";  
  String pathToFiles = @"C:\Documents and Settings\Wasabi Digital\My Documents\Visual Studio 2008\Evo\WEB\test\";    
  String convertVideo = " -i \"" + pathToFiles + "out.wmv\" \"" + pathToFiles + "sample3.flv\" ";
  String makeImages = " -i \"" + pathToFiles + "out.wmv\" -r 1 -ss 00:00:01 -t 00:00:15 -f image2 -s 120x96 \"" + pathToFiles + "images%05d.png\"";
  this.ExecuteCommandSync(runMe,convertVideo);
  this.ExecuteCommandSync(runMe, makeImages);
 }

And this is a code snipit taken from the first link. The extra quotation marks around the usage of command let it run with spaces in its name. ie ".../My Documents/..."

public void ExecuteCommandSync(String command, String args) {


 try {   
   System.Diagnostics.ProcessStartInfo procStartInfo =
    new System.Diagnostics.ProcessStartInfo("\""+command+"\"",args);

   Process.StandardOutput StreamReader.
   procStartInfo.RedirectStandardOutput = true;
   procStartInfo.UseShellExecute = false;

   procStartInfo.CreateNoWindow = true;

   System.Diagnostics.Process proc = new System.Diagnostics.Process();
   proc.StartInfo = procStartInfo;
   proc.Start();

   string result = proc.StandardOutput.ReadToEnd();

   Debug.WriteLine(result);
  } catch (Exception objException) {   
   // Log the exception
  }
Kieran
I have modified the command a little. Putting in the sample rates helps as sometimes it was failing on certain videos./* Taken fromhttp://www.catswhocode.com/blog/19-ffmpeg-commands-for-all-needs*/ffmpeg -i video_origine.avi -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv video_finale.flv
Kieran
A: 

Thats using ffmpeg.exe whith c# not using sharpffmpeg.

VeXii
as it turns out i could just use the ffmpeg to do all the things i was after. ie convert and make images. I have altered the script a little to better support conversion. See edit bellow.
Kieran
A: 

I'm new to c# and FFMpeg, I don't understand why initiating a process if a dll is available.

So why need the SharpFFMpeg.dll?

I looking into examples that us de SharpFFMpeg.dll, Anyone?