ffmpeg设置转换时的持续时间

时间:2010-05-26 14:02:33

标签: ffmpeg

我正在使用ffmpeg转换视频,并且会话持续时间显示为00:00:00.00。 这是我的传递论点

"-i " + FileName + " -ar 22050 -b 500k -f flv -t " + Duration + " " + outputfile

我的代码将其呈现给

-i 1.mov -ar 22050 -b 500k -f flv -t 00:03:34.99 1.flv

我错过了什么?


filargs = "flvtool2 -UP " + outputfile;
            proc = new Process();
            proc.StartInfo.FileName = spath + "flvtool2.exe";
            proc.StartInfo.Arguments = filargs;
            proc.StartInfo.UseShellExecute = false;
            proc.StartInfo.CreateNoWindow = false;
            proc.StartInfo.RedirectStandardOutput = false;

            proc.Start();

            proc.WaitForExit();
            proc.Close();

我试过这个,没有效果,持续时间仍为0.其中“outputfile”是我没有持续时间的转换文件

2 个答案:

答案 0 :(得分:1)

我在刚刚运行的测试中看到同样的问题。这似乎是ffmpeg中的一个已知问题。对于flv,它不能正确写入所有元数据,包括持续时间。您可以使用flvtool2为您修复元数据。跑吧:

flvtool2 -UP file.flv

它将根据时间戳自动查找持续时间并将元数据写入文件。我只是尝试了它并且效果很好。

答案 1 :(得分:0)

我已经解决了我的问题

static void Fix(string Path)
        {
            string spath;
            spath = AppDomain.CurrentDomain.BaseDirectory;
            string filargs = "-U " + Path;
            Process proc1 = new Process();
            proc1.StartInfo.FileName = spath + "flvtool2.exe";
            proc1.StartInfo.Arguments = filargs;
            proc1.StartInfo.UseShellExecute = false;
            proc1.StartInfo.CreateNoWindow = false;
            proc1.StartInfo.RedirectStandardOutput
= false;
            proc1.Start();
            proc1.WaitForExit();
            proc1.Close();
        }

它做得很好

相关问题