[FFmpeg-cvslog] Merge commit 'dbbaad32e36b9046cd19d6e3329e2ca7ab49b401'

Matthieu Bouron git at videolan.org
Thu Jun 23 17:56:42 CEST 2016


ffmpeg | branch: master | Matthieu Bouron <matthieu.bouron at stupeflix.com> | Thu Jun 23 17:52:14 2016 +0200| [4e7a9212820a56bc731c09b2f11ae1422d070837] | committer: Matthieu Bouron

Merge commit 'dbbaad32e36b9046cd19d6e3329e2ca7ab49b401'

* commit 'dbbaad32e36b9046cd19d6e3329e2ca7ab49b401':
  movenc: Provide output bytestream markers for fragmented content

Merged-by: Matthieu Bouron <matthieu.bouron at stupeflix.com>

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

 libavformat/movenc.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 37f2b5f..4e5f65f 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -4236,6 +4236,7 @@ static int mov_flush_fragment(AVFormatContext *s, int force)
     int i, first_track = -1;
     int64_t mdat_size = 0;
     int ret;
+    int has_video = 0, starts_with_key = 0, first_video_track = 1;
 
     if (!(mov->flags & FF_MOV_FLAG_FRAGMENT))
         return 0;
@@ -4283,6 +4284,7 @@ static int mov_flush_fragment(AVFormatContext *s, int force)
         for (i = 0; i < mov->nb_streams; i++)
             mov->tracks[i].data_offset = pos + moov_size + 8;
 
+        avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_HEADER);
         if (mov->flags & FF_MOV_FLAG_DELAY_MOOV)
             mov_write_identification(s->pb, s);
         if ((ret = mov_write_moov_tag(s->pb, mov, s)) < 0)
@@ -4338,6 +4340,14 @@ static int mov_flush_fragment(AVFormatContext *s, int force)
             track->data_offset = 0;
         else
             track->data_offset = mdat_size;
+        if (track->par->codec_type == AVMEDIA_TYPE_VIDEO) {
+            has_video = 1;
+            if (first_video_track) {
+                if (track->entry)
+                    starts_with_key = track->cluster[0].flags & MOV_SYNC_SAMPLE;
+                first_video_track = 0;
+            }
+        }
         if (!track->entry)
             continue;
         if (track->mdat_buf)
@@ -4349,6 +4359,10 @@ static int mov_flush_fragment(AVFormatContext *s, int force)
     if (!mdat_size)
         return 0;
 
+    avio_write_marker(s->pb,
+                      av_rescale(mov->tracks[first_track].cluster[0].dts, AV_TIME_BASE, mov->tracks[first_track].timescale),
+                      (has_video ? starts_with_key : mov->tracks[first_track].cluster[0].flags & MOV_SYNC_SAMPLE) ? AVIO_DATA_MARKER_SYNC_POINT : AVIO_DATA_MARKER_BOUNDARY_POINT);
+
     for (i = 0; i < mov->nb_streams; i++) {
         MOVTrack *track = &mov->tracks[i];
         int buf_size, write_moof = 1, moof_tracks = -1;
@@ -5807,8 +5821,10 @@ static int mov_write_trailer(AVFormatContext *s)
             avio_seek(pb, mov->reserved_header_pos, SEEK_SET);
             mov_write_sidx_tags(pb, mov, -1, 0);
             avio_seek(pb, end, SEEK_SET);
+            avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_TRAILER);
             mov_write_mfra_tag(pb, mov);
         } else {
+            avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_TRAILER);
             mov_write_mfra_tag(pb, mov);
         }
     }


======================================================================

diff --cc libavformat/movenc.c
index 37f2b5f,d8022dc..4e5f65f
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@@ -4235,7 -3183,7 +4235,8 @@@ static int mov_flush_fragment(AVFormatC
      MOVMuxContext *mov = s->priv_data;
      int i, first_track = -1;
      int64_t mdat_size = 0;
 +    int ret;
+     int has_video = 0, starts_with_key = 0, first_video_track = 1;
  
      if (!(mov->flags & FF_MOV_FLAG_FRAGMENT))
          return 0;
@@@ -4279,14 -3229,17 +4280,15 @@@
          if (i < mov->nb_streams && !force)
              return 0;
  
 -        if ((ret = ffio_open_null_buf(&moov_buf)) < 0)
 -            return ret;
 -        mov_write_moov_tag(moov_buf, mov, s);
 -        buf_size = ffio_close_null_buf(moov_buf);
 +        moov_size = get_moov_size(s);
          for (i = 0; i < mov->nb_streams; i++)
 -            mov->tracks[i].data_offset = pos + buf_size + 8;
 +            mov->tracks[i].data_offset = pos + moov_size + 8;
  
+         avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_HEADER);
          if (mov->flags & FF_MOV_FLAG_DELAY_MOOV)
              mov_write_identification(s->pb, s);
 -        mov_write_moov_tag(s->pb, mov, s);
 +        if ((ret = mov_write_moov_tag(s->pb, mov, s)) < 0)
 +            return ret;
  
          if (mov->flags & FF_MOV_FLAG_DELAY_MOOV) {
              if (mov->flags & FF_MOV_FLAG_GLOBAL_SIDX)
@@@ -5798,17 -4291,18 +5812,19 @@@ static int mov_write_trailer(AVFormatCo
          for (i = 0; i < mov->nb_streams; i++)
             mov->tracks[i].data_offset = 0;
          if (mov->flags & FF_MOV_FLAG_GLOBAL_SIDX) {
 +            int64_t end;
              av_log(s, AV_LOG_INFO, "Starting second pass: inserting sidx atoms\n");
              res = shift_data(s);
 -            if (res == 0) {
 -                int64_t end = avio_tell(pb);
 -                avio_seek(pb, mov->reserved_header_pos, SEEK_SET);
 -                mov_write_sidx_tags(pb, mov, -1, 0);
 -                avio_seek(pb, end, SEEK_SET);
 -                avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_TRAILER);
 -                mov_write_mfra_tag(pb, mov);
 -            }
 +            if (res < 0)
 +                goto error;
 +            end = avio_tell(pb);
 +            avio_seek(pb, mov->reserved_header_pos, SEEK_SET);
 +            mov_write_sidx_tags(pb, mov, -1, 0);
 +            avio_seek(pb, end, SEEK_SET);
++            avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_TRAILER);
 +            mov_write_mfra_tag(pb, mov);
          } else {
+             avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_TRAILER);
              mov_write_mfra_tag(pb, mov);
          }
      }



More information about the ffmpeg-cvslog mailing list