diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-06-20 00:48:51 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-06-20 00:48:51 +0200 |
commit | 6af1793dd5a26b0617b31b0165f94d4bfc7c5160 (patch) | |
tree | 29219f7b787dff7ce0709feade754f12ab6f6135 | |
parent | 03bda44689914b68f0ebc6e39d6a30f5591b3781 (diff) | |
parent | 9455a023be9f3915ccf5511a0b8fdb5b8897b2b6 (diff) | |
download | ffmpeg-6af1793dd5a26b0617b31b0165f94d4bfc7c5160.tar.gz |
Merge commit '9455a023be9f3915ccf5511a0b8fdb5b8897b2b6' into release/1.1
* commit '9455a023be9f3915ccf5511a0b8fdb5b8897b2b6':
matroskaenc: do not write negative timestamps
Conflicts:
tests/ref/lavf/mkv
tests/ref/seek/lavf-mkv
No change to fate as ffmpeg was not affected by these bugs
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavformat/matroskaenc.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 38cd6a92ed..a8b829c3b3 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -95,6 +95,8 @@ typedef struct MatroskaMuxContext { AVPacket cur_audio_pkt; int have_attachments; + + int64_t ts_offset; } MatroskaMuxContext; @@ -1265,9 +1267,18 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt) AVIOContext *pb = s->pb->seekable ? s->pb : mkv->dyn_bc; AVCodecContext *codec = s->streams[pkt->stream_index]->codec; int ret, keyframe = !!(pkt->flags & AV_PKT_FLAG_KEY); - int64_t ts = mkv->tracks[pkt->stream_index].write_dts ? pkt->dts : pkt->pts; + int64_t ts; int cluster_size = avio_tell(pb) - (s->pb->seekable ? mkv->cluster_pos : 0); + if (pkt->dts < 0 && !mkv->ts_offset) + mkv->ts_offset = -pkt->dts; + + pkt->dts += mkv->ts_offset; + if (pkt->pts != AV_NOPTS_VALUE) + pkt->pts += mkv->ts_offset; + + ts = mkv->tracks[pkt->stream_index].write_dts ? pkt->dts : pkt->pts; + // start a new cluster every 5 MB or 5 sec, or 32k / 1 sec for streaming or // after 4k and on a keyframe if (mkv->cluster_pos != -1 && |