summaryrefslogtreecommitdiff
path: root/libavformat/mux.c
diff options
context:
space:
mode:
authorJan Sebechlebsky <sebechlebskyjan@gmail.com>2016-08-02 15:24:19 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2016-08-22 12:59:54 +0200
commit2fc9a3eb7a8c606bd403dc9fbdb8463144b243cf (patch)
tree7e0d5b1f7125346933ec5ddc570681f6d44a1ed3 /libavformat/mux.c
parent429b41e7b283f860ee69c81fa2be96ff2af12200 (diff)
avformat/mux: Restore original ts in write_packet on error
Restore original timestamps in write_packet() if the actual write operation was not successfull. This allows to pass the same packet to nonblocking muxer repeatedly without corrupting the timestamps. Signed-off-by: Jan Sebechlebsky <sebechlebskyjan@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/mux.c')
-rw-r--r--libavformat/mux.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/libavformat/mux.c b/libavformat/mux.c
index e9973edd08..a427f4659b 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -657,6 +657,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
static int write_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret, did_split;
+ int64_t pts_backup, dts_backup;
+
+ pts_backup = pkt->pts;
+ dts_backup = pkt->dts;
if (s->output_ts_offset) {
AVStream *st = s->streams[pkt->stream_index];
@@ -743,6 +747,11 @@ fail:
if (did_split)
av_packet_merge_side_data(pkt);
+ if (ret < 0) {
+ pkt->pts = pts_backup;
+ pkt->dts = dts_backup;
+ }
+
return ret;
}