aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-01-03 02:37:18 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-01-03 02:47:35 +0100
commit504267fb56ba815ff896f9d5a7ce129a8ae674ab (patch)
treecb0da038222499fed110a21e7c291f9f3203b7f5 /libavformat
parent0506f687e8771c2bc3cddf4c9bc3ad77e37f69f2 (diff)
downloadffmpeg-504267fb56ba815ff896f9d5a7ce129a8ae674ab.tar.gz
avformat/movenc: Use cluster timestamps when available in edts
Also print both if they differ Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/movenc.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 946770dd03..a82622ecd3 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -2232,7 +2232,21 @@ static int mov_write_edts_tag(AVIOContext *pb, MOVMuxContext *mov,
int version = duration < INT32_MAX ? 0 : 1;
int entry_size, entry_count, size;
int64_t delay, start_ct = track->start_cts;
- delay = av_rescale_rnd(track->start_dts + start_ct, MOV_TIMESCALE,
+ int64_t start_dts = track->start_dts;
+
+ if (track->entry) {
+ if (start_dts != track->cluster[0].dts || start_ct != track->cluster[0].cts) {
+
+ av_log(mov->fc, AV_LOG_DEBUG,
+ "EDTS using dts:%"PRId64" cts:%d instead of dts:%"PRId64" cts:%"PRId64" tid:%d\n",
+ track->cluster[0].dts, track->cluster[0].cts,
+ start_dts, start_ct, track->track_id);
+ start_dts = track->cluster[0].dts;
+ start_ct = track->cluster[0].cts;
+ }
+ }
+
+ delay = av_rescale_rnd(start_dts + start_ct, MOV_TIMESCALE,
track->timescale, AV_ROUND_DOWN);
version |= delay < INT32_MAX ? 0 : 1;
@@ -2268,8 +2282,8 @@ static int mov_write_edts_tag(AVIOContext *pb, MOVMuxContext *mov,
* special meaning. Normally start_ct should end up positive or zero
* here, but use FFMIN in case dts is a a small positive integer
* rounded to 0 when represented in MOV_TIMESCALE units. */
- av_assert0(av_rescale_rnd(track->start_dts, MOV_TIMESCALE, track->timescale, AV_ROUND_DOWN) <= 0);
- start_ct = -FFMIN(track->start_dts, 0);
+ av_assert0(av_rescale_rnd(start_dts, MOV_TIMESCALE, track->timescale, AV_ROUND_DOWN) <= 0);
+ start_ct = -FFMIN(start_dts, 0);
/* Note, this delay is calculated from the pts of the first sample,
* ensuring that we don't reduce the duration for cases with
* dts<0 pts=0. */