【问题标题】:create animated gif from video using ffmpeg and c#使用 ffmpeg 和 c# 从视频创建动画 gif
【发布时间】:2019-12-19 00:07:13
【问题描述】:

我正在尝试从视频文件中获取动画 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 有错误。

【问题讨论】:

  • 最好更具体地说明什么不起作用。你有例外还是什么?
  • 出现如下异常:t:3 -vf scale=320:-1,format=rgb8,format=rgb24 的持续时间规范无效

标签: c# ffmpeg sharpffmpeg


【解决方案1】:

您的代码生成参数字符串

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

3" 看起来很明显的错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-12-09
    • 2016-10-18
    • 2014-03-19
    • 2020-06-06
    • 2016-08-09
    • 2012-08-21
    • 2013-07-22
    • 2014-03-02
    相关资源
    最近更新 更多