[FFmpeg-cvslog] movenc: Assume streams starting at pts= 0 for discontinuous fragments with editlists

Martin Storsjö git at videolan.org
Tue Nov 17 16:01:26 CET 2015


ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Mon Jan  5 15:13:04 2015 +0200| [09e431b9e3674804172e7b0a0f865b65ec09739a] | committer: Martin Storsjö

movenc: Assume streams starting at pts=0 for discontinuous fragments with editlists

This allows producing fragments discontinously where the video
stream has b-frames (but starts at pts=0), but doesn't work for the
cases with audio with preroll.

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

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

 libavformat/movenc.c |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 3ee54bf..ac452b1 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -3506,10 +3506,18 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
     if (trk->start_dts == AV_NOPTS_VALUE) {
         trk->start_dts = pkt->dts;
         if (trk->frag_discont) {
-            /* Pretend the whole stream started at dts=0, with earlier fragments
-             * already written, with a duration summing up to pkt->dts. */
-            trk->frag_start   = pkt->dts;
-            trk->start_dts    = 0;
+            if (mov->use_editlist) {
+                /* Pretend the whole stream started at pts=0, with earlier fragments
+                 * already written. If the stream started at pts=0, the duration sum
+                 * of earlier fragments would have been pkt->pts. */
+                trk->frag_start = pkt->pts;
+                trk->start_dts  = pkt->dts - pkt->pts;
+            } else {
+                /* Pretend the whole stream started at dts=0, with earlier fragments
+                 * already written, with a duration summing up to pkt->dts. */
+                trk->frag_start = pkt->dts;
+                trk->start_dts  = 0;
+            }
             trk->frag_discont = 0;
         } else if (pkt->dts && mov->moov_written)
             av_log(s, AV_LOG_WARNING,



More information about the ffmpeg-cvslog mailing list