summaryrefslogtreecommitdiff
path: root/libavformat/movenc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-12-19 02:56:45 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-12-19 02:58:16 +0100
commitc8e05c438f78ac5fee40f260a7f822f5a81b44e0 (patch)
tree3ad8c0a71688464c3f472add6dc4486d75a8b7c2 /libavformat/movenc.c
parent7ef515cda5fdfa5800a9336a128bff1f1b85edea (diff)
parent59f0275dd0a42a7f90271a83a78e9ca5e69ff5b0 (diff)
Merge commit '59f0275dd0a42a7f90271a83a78e9ca5e69ff5b0'
* commit '59f0275dd0a42a7f90271a83a78e9ca5e69ff5b0': movenc: Adjust the pts of new fragments similarly to what is done for dts Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/movenc.c')
-rw-r--r--libavformat/movenc.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 944541762a..cd98f762b8 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -4055,6 +4055,11 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
* which might not exactly match our dts. Therefore adjust the dts
* of this packet to be what the previous packets duration implies. */
trk->cluster[trk->entry].dts = trk->start_dts + trk->track_duration;
+ /* We also may have written the pts and the corresponding duration
+ * in sidx tags; make sure the sidx pts and duration match up with
+ * the next fragment. This means the cts of the first sample must
+ * be the same in all fragments. */
+ pkt->pts = pkt->dts + trk->start_cts;
} else {
/* New fragment, but discontinuous from previous fragments.
* Pretend the duration sum of the earlier fragments is
@@ -4098,6 +4103,9 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
trk->flags |= MOV_TRACK_CTTS;
trk->cluster[trk->entry].cts = pkt->pts - pkt->dts;
trk->cluster[trk->entry].flags = 0;
+ if (trk->start_cts == AV_NOPTS_VALUE)
+ trk->start_cts = pkt->pts - pkt->dts;
+
if (enc->codec_id == AV_CODEC_ID_VC1) {
mov_parse_vc1_frame(pkt, trk, mov->fragments);
} else if (pkt->flags & AV_PKT_FLAG_KEY) {
@@ -4673,6 +4681,7 @@ static int mov_write_header(AVFormatContext *s)
* this is updated. */
track->hint_track = -1;
track->start_dts = AV_NOPTS_VALUE;
+ track->start_cts = AV_NOPTS_VALUE;
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (track->tag == MKTAG('m','x','3','p') || track->tag == MKTAG('m','x','3','n') ||
track->tag == MKTAG('m','x','4','p') || track->tag == MKTAG('m','x','4','n') ||