tags:

views:

242

answers:

3

I'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?

+1  A: 

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.

Jason
A: 
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

Mike Samteladze
Please edit your question, rather than post an answer. Stack Overflow is not a traditional messaging forum. The order of "Answers" does not have to be chronological. See the FAQ for details.
Stu Thompson
A: 

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

Mike Samteladze