[Ffmpeg-cvslog] r5939 - in trunk: libavformat/flvenc.c tests/ffmpeg.regression.ref tests/libav.regression.ref

bcoudurier subversion
Sun Aug 6 17:29:51 CEST 2006


Author: bcoudurier
Date: Sun Aug  6 17:29:50 2006
New Revision: 5939

Modified:
   trunk/libavformat/flvenc.c
   trunk/tests/ffmpeg.regression.ref
   trunk/tests/libav.regression.ref

Log:
always write duration and file size, fix seeking, progress bar is now active

Modified: trunk/libavformat/flvenc.c
==============================================================================
--- trunk/libavformat/flvenc.c	(original)
+++ trunk/libavformat/flvenc.c	Sun Aug  6 17:29:50 2006
@@ -25,6 +25,9 @@
     int hasAudio;
     int hasVideo;
     int reserved;
+    offset_t duration_offset;
+    offset_t filesize_offset;
+    int64_t duration;
 } FLVContext;
 
 static int get_audio_flags(AVCodecContext *enc){
@@ -160,12 +163,11 @@
 
     /* mixed array (hash) with size and string/type/data tuples */
     put_byte(pb, AMF_MIXED_ARRAY);
-    put_be32(pb, 4*flv->hasVideo + flv->hasAudio + (!!s->file_size) + (s->duration != AV_NOPTS_VALUE && s->duration));
+    put_be32(pb, 4*flv->hasVideo + flv->hasAudio + 2); // +2 for duration and file size
 
-    if (s->duration != AV_NOPTS_VALUE && s->duration) {
-        put_amf_string(pb, "duration");
-        put_amf_double(pb, s->duration / (double)AV_TIME_BASE);
-    }
+    put_amf_string(pb, "duration");
+    flv->duration_offset= url_ftell(pb);
+    put_amf_double(pb, 0); // delayed write
 
     if(flv->hasVideo){
         put_amf_string(pb, "width");
@@ -186,10 +188,9 @@
         put_amf_double(pb, samplerate);
     }
 
-    if(s->file_size){
-        put_amf_string(pb, "filesize");
-        put_amf_double(pb, s->file_size);
-    }
+    put_amf_string(pb, "filesize");
+    flv->filesize_offset= url_ftell(pb);
+    put_amf_double(pb, 0); // delayed write
 
     put_amf_string(pb, "");
     put_byte(pb, 9); // end marker 1 byte
@@ -217,6 +218,13 @@
     flags |= flv->hasVideo ? 1 : 0;
     url_fseek(pb, 4, SEEK_SET);
     put_byte(pb,flags);
+
+    /* update informations */
+    url_fseek(pb, flv->duration_offset, SEEK_SET);
+    put_amf_double(pb, flv->duration / (double)1000);
+    url_fseek(pb, flv->filesize_offset, SEEK_SET);
+    put_amf_double(pb, file_size);
+
     url_fseek(pb, file_size, SEEK_SET);
     return 0;
 }
@@ -250,6 +258,7 @@
     put_byte(pb,flags);
     put_buffer(pb, pkt->data, size);
     put_be32(pb,size+1+11); // previous tag size
+    flv->duration = pkt->pts + pkt->duration;
 
     put_flush_packet(pb);
     return 0;

Modified: trunk/tests/ffmpeg.regression.ref
==============================================================================
--- trunk/tests/ffmpeg.regression.ref	(original)
+++ trunk/tests/ffmpeg.regression.ref	Sun Aug  6 17:29:50 2006
@@ -125,8 +125,8 @@
 1453500 ./data/a-asv2.avi
 0b310840a6d3970595983491687669df *./data/out.yuv
 stddev: 18.82 PSNR:22.63 bytes:7602176
-2e1647c88d1b7e56d91058484db602da *./data/a-flv.flv
-658104 ./data/a-flv.flv
+fc2eaff78828dd0efd6483f754511f33 *./data/a-flv.flv
+658142 ./data/a-flv.flv
 4d9c04e7017dc68da7891048c46c1c37 *./data/out.yuv
 stddev:  8.08 PSNR:29.97 bytes:7602176
 a7ef4746f27be309138c188e327d3ebe *./data/a-ffv1.avi

Modified: trunk/tests/libav.regression.ref
==============================================================================
--- trunk/tests/libav.regression.ref	(original)
+++ trunk/tests/libav.regression.ref	Sun Aug  6 17:29:50 2006
@@ -19,8 +19,8 @@
 0026c4e2528ff8f71b79ef53d38cc04d *./data/b-libav.ffm
  389120 ./data/b-libav.ffm
 ./data/b-libav.ffm CRC=0x688bd1eb
-eb8ff480628c444be572045ef7208528 *./data/b-libav.flv
-339438 ./data/b-libav.flv
+1596b6d08a94e6b5519357ed23a48aa3 *./data/b-libav.flv
+339476 ./data/b-libav.flv
 ./data/b-libav.flv CRC=0x7b9076f8
 63e05396e2d52135c4025ce14eb090a9 *./data/b-libav.mov
 369893 ./data/b-libav.mov




More information about the ffmpeg-cvslog mailing list