From c5e1e9827d8aaced8b96a49859a6b0a1cd007d20 Mon Sep 17 00:00:00 2001 From: Justin Johnson Date: Tue, 2 Feb 2010 22:23:09 +0000 Subject: [PATCH] Guess the duration before converting video and write guessed duration into flv header. Patch by Justin Johnson, justin D johnson3 A gmail Originally committed as revision 21615 to svn://svn.ffmpeg.org/ffmpeg/trunk --- ffmpeg.c | 13 +++++++++++++ libavformat/flvenc.c | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ffmpeg.c b/ffmpeg.c index 3ffd596..720e11a 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -2104,6 +2104,19 @@ static int av_encode(AVFormatContext **output_files, ist->is_start = 1; } + /* set the duration of the output to the duration of the input + * if the output ends up being different, it'll be corrected later */ + for (i=0;iduration = recording_time / 1000000 * AV_TIME_BASE; + } else { + out_file->duration = in_file->duration; + } + } + /* set meta data information from input file if required */ for (i=0;iduration_offset= url_ftell(pb); - put_amf_double(pb, 0); // delayed write + put_amf_double(pb, s->duration / AV_TIME_BASE); // fill in the guessed duration, it'll be corrected later if incorrect if(video_enc){ put_amf_string(pb, "width"); -- 2.7.4