使用ffmpeg和c#从视频创建动画gif

时间:2014-10-10 06:16:25

标签: c# ffmpeg sharpffmpeg

我想从视频文件中获取动画gif。我无法从下面的代码创建gif。任何人都可以帮助我解决这个问题。

      Process ffmpeg; // creating process
    string video;
    string thumb;
 //   string text = System.IO.File.ReadAllText(@"C:\xampp\htdocs\h\myText.txt");
    video = Page.MapPath("") + "\\o.avi";
    thumb = Page.MapPath("") + "\\output\\o.gif"; // thumb name with path !
    ffmpeg = new Process();
    int num = 3;
    int secpos = 1;

    // ffmpeg.StartInfo.Arguments = "ffmpeg -i o.avi -vf scale=320:-1,format=rgb8,format=rgb24 -t 10 -r 10 output.gif"; // arguments !
    ffmpeg.StartInfo.Arguments = " -i \"" + video + "\" -s 108*80 -ss " + secpos + " -t " + num + "\" -vf scale=320:-1,format=rgb8,format=rgb24 \"" + thumb + "\"";
    ffmpeg.StartInfo.FileName = Page.MapPath("ffmpeg//ffmpeg.exe");
    ffmpeg.Start(); // start !  

我认为ffmpeg.StartInfo.Arguments有一个错误。

1 个答案:

答案 0 :(得分:0)

您的代码产生参数字符串

-i "path" -s 108*80 -ss 1 -t 3" -vf scale=320:-1,format=rgb8,format=rgb24 "path"

3"似乎是一个明显的错误。