Commit c8e05c43 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '59f0275d'

* commit '59f0275d':
  movenc: Adjust the pts of new fragments similarly to what is done for dts
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 7ef515cd 59f0275d
...@@ -4055,6 +4055,11 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -4055,6 +4055,11 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
* which might not exactly match our dts. Therefore adjust the dts * which might not exactly match our dts. Therefore adjust the dts
* of this packet to be what the previous packets duration implies. */ * of this packet to be what the previous packets duration implies. */
trk->cluster[trk->entry].dts = trk->start_dts + trk->track_duration; 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 { } else {
/* New fragment, but discontinuous from previous fragments. /* New fragment, but discontinuous from previous fragments.
* Pretend the duration sum of the earlier fragments is * Pretend the duration sum of the earlier fragments is
...@@ -4098,6 +4103,9 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -4098,6 +4103,9 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
trk->flags |= MOV_TRACK_CTTS; trk->flags |= MOV_TRACK_CTTS;
trk->cluster[trk->entry].cts = pkt->pts - pkt->dts; trk->cluster[trk->entry].cts = pkt->pts - pkt->dts;
trk->cluster[trk->entry].flags = 0; 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) { if (enc->codec_id == AV_CODEC_ID_VC1) {
mov_parse_vc1_frame(pkt, trk, mov->fragments); mov_parse_vc1_frame(pkt, trk, mov->fragments);
} else if (pkt->flags & AV_PKT_FLAG_KEY) { } else if (pkt->flags & AV_PKT_FLAG_KEY) {
...@@ -4673,6 +4681,7 @@ static int mov_write_header(AVFormatContext *s) ...@@ -4673,6 +4681,7 @@ static int mov_write_header(AVFormatContext *s)
* this is updated. */ * this is updated. */
track->hint_track = -1; track->hint_track = -1;
track->start_dts = AV_NOPTS_VALUE; track->start_dts = AV_NOPTS_VALUE;
track->start_cts = AV_NOPTS_VALUE;
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (track->tag == MKTAG('m','x','3','p') || track->tag == MKTAG('m','x','3','n') || 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') || track->tag == MKTAG('m','x','4','p') || track->tag == MKTAG('m','x','4','n') ||
......
...@@ -112,6 +112,7 @@ typedef struct MOVTrack { ...@@ -112,6 +112,7 @@ typedef struct MOVTrack {
uint32_t tref_tag; uint32_t tref_tag;
int tref_id; ///< trackID of the referenced track int tref_id; ///< trackID of the referenced track
int64_t start_dts; int64_t start_dts;
int64_t start_cts;
int hint_track; ///< the track that hints this track, -1 if no hint track is set int hint_track; ///< the track that hints this track, -1 if no hint track is set
int src_track; ///< the track that this hint (or tmcd) track describes int src_track; ///< the track that this hint (or tmcd) track describes
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment