ffmpeg set duration when converting [closed]
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
开发者_运维技巧 Improve this questionI'm converting video with ffmpeg and after conversation duration is shown as 00:00:00.00. here is my passing arguments
"-i " + FileName + " -ar 22050 -b 500k -f flv -t " + Duration + " " + outputfile
Which is rendered by my code to
-i 1.mov -ar 22050 -b 500k -f flv -t 00:03:34.99 1.flv
what am I missing?
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();
I've tried this, no effect, duration is still 0. where "outputfile" is my converted file who has no duration
I see the same problem in a test I just ran. This appears to be a known issue in ffmpeg. For flv, it does not properly write all of the metadata, including the duration. You can use flvtool2 to fix the metadata for you. Just run:
flvtool2 -UP file.flv
and it will automatically find the duration based on the timestamps and write the metadata to the file. I just tried it and it worked great.
I've solved my problem
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();
}
it does the perfect job
精彩评论