[FFmpeg-cvslog] movenc: Don't use track_id to decide which track is the first in a moof

Martin Storsjö git at videolan.org
Thu Oct 30 02:24:35 CET 2014


ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Wed Oct 29 09:20:51 2014 +0200| [573b1de2d7f1db71030f91ecdded7d0bc071f6b6] | committer: Martin Storsjö

movenc: Don't use track_id to decide which track is the first in a moof

If one track doesn't have any samples within a moof, no traf/trun
is written for it. When the omit_tfhd_offset flag is set, none
of the tfhd atoms have any base_data_offset set, and the implicit
offset (end of previous track fragment data, or start of the moof
for the first trun) is used.

Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=573b1de2d7f1db71030f91ecdded7d0bc071f6b6
---

 libavformat/movenc.c |    4 +++-
 libavformat/movenc.h |    1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index d84ddbe..43b03c5 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -2458,7 +2458,7 @@ static int mov_write_trun_tag(AVIOContext *pb, MOVMuxContext *mov,
     avio_wb32(pb, track->entry); /* sample count */
     if (mov->flags & FF_MOV_FLAG_OMIT_TFHD_OFFSET &&
         !(mov->flags & FF_MOV_FLAG_SEPARATE_MOOF) &&
-        track->track_id != 1)
+        !mov->first_trun)
         avio_wb32(pb, 0); /* Later tracks follow immediately after the previous one */
     else
         avio_wb32(pb, moof_size + 8 + track->data_offset +
@@ -2477,6 +2477,7 @@ static int mov_write_trun_tag(AVIOContext *pb, MOVMuxContext *mov,
             avio_wb32(pb, track->cluster[i].cts);
     }
 
+    mov->first_trun = 0;
     return update_size(pb, pos);
 }
 
@@ -2598,6 +2599,7 @@ static int mov_write_moof_tag_internal(AVIOContext *pb, MOVMuxContext *mov,
 
     avio_wb32(pb, 0); /* size placeholder */
     ffio_wfourcc(pb, "moof");
+    mov->first_trun = 1;
 
     mov_write_mfhd_tag(pb, mov);
     for (i = 0; i < mov->nb_streams; i++) {
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index 2f2c09c..a463a8d 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -158,6 +158,7 @@ typedef struct MOVMuxContext {
     int max_fragment_size;
     int ism_lookahead;
     AVIOContext *mdat_buf;
+    int first_trun;
 
     int64_t reserved_moov_pos;
 



More information about the ffmpeg-cvslog mailing list