[FFmpeg-cvslog] r21615 - in trunk: ffmpeg.c libavformat/flvenc.c

cehoyos subversion
Tue Feb 2 23:23:09 CET 2010


Author: cehoyos
Date: Tue Feb  2 23:23:09 2010
New Revision: 21615

Log:
Guess the duration before converting video and write guessed duration
into flv header.

Patch by Justin Johnson, justin D johnson3 A gmail

Modified:
   trunk/ffmpeg.c
   trunk/libavformat/flvenc.c

Modified: trunk/ffmpeg.c
==============================================================================
--- trunk/ffmpeg.c	Tue Feb  2 22:31:20 2010	(r21614)
+++ trunk/ffmpeg.c	Tue Feb  2 23:23:09 2010	(r21615)
@@ -2104,6 +2104,19 @@ static int av_encode(AVFormatContext **o
         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;i<nb_output_files;i++) {
+        AVFormatContext *out_file = output_files[i];
+        AVFormatContext *in_file = input_files[i];
+
+        if (recording_time != INT64_MAX) {
+            out_file->duration = 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;i<nb_meta_data_maps;i++) {
         AVFormatContext *out_file;

Modified: trunk/libavformat/flvenc.c
==============================================================================
--- trunk/libavformat/flvenc.c	Tue Feb  2 22:31:20 2010	(r21614)
+++ trunk/libavformat/flvenc.c	Tue Feb  2 23:23:09 2010	(r21615)
@@ -221,7 +221,7 @@ static int flv_write_header(AVFormatCont
 
     put_amf_string(pb, "duration");
     flv->duration_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");



More information about the ffmpeg-cvslog mailing list