aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefano Sabatini <stefasab@gmail.com>2015-11-18 19:23:03 +0100
committerStefano Sabatini <stefasab@gmail.com>2016-02-23 18:44:12 +0100
commit14f7a3d55a43c1082ee1186a1990a431c641052d (patch)
tree8413603eb9ebbdfb8f6e84b8356a314d9101e19f
parent3ba57bfe8ddcf151d0dcfc6bdfe76b2bb57ba018 (diff)
downloadffmpeg-14f7a3d55a43c1082ee1186a1990a431c641052d.tar.gz
lavc/lavf: transmit stream_id information for mpegts KLV data packets
This allows to copy information related to the stream ID from the demuxer to the muxer, thus allowing for example to retain information related to synchronous and asynchronous KLV data packets. This information is used in the muxer when remuxing to distinguish the two kind of packets (if the information is lacking, data packets are considered synchronous). The fate reference changes are due to the use of av_packet_merge_side_data(), which increases the size of the output packet size, since side data is merged into the packet data.
-rw-r--r--doc/APIchanges3
-rw-r--r--libavcodec/avcodec.h6
-rw-r--r--libavcodec/avpacket.c1
-rw-r--r--libavcodec/version.h2
-rw-r--r--libavformat/mpegts.c31
-rw-r--r--libavformat/mpegtsenc.c26
-rw-r--r--tests/ref/fate/concat-demuxer-simple2-lavf-ts128
-rw-r--r--tests/ref/seek/lavf-ts54
8 files changed, 147 insertions, 104 deletions
diff --git a/doc/APIchanges b/doc/APIchanges
index 1194709fcd..0c7fc65c09 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2015-08-28
API changes, most recent first:
+2016-02-xx - xxxxxxx - lavc 57.25.100
+ Add AV_PKT_DATA_MPEGTS_STREAM_ID for exporting the MPEGTS stream ID.
+
2016-xx-xx - lavu 55.18.100
xxxxxxx audio_fifo.h - Add av_audio_fifo_peek_at().
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index d8497655b0..80f8a66339 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1403,6 +1403,12 @@ enum AVPacketSideDataType {
* side data includes updated metadata which appeared in the stream.
*/
AV_PKT_DATA_METADATA_UPDATE,
+
+ /**
+ * MPEGTS stream ID, this is required to pass the stream ID
+ * information from the demuxer to the corresponding muxer.
+ */
+ AV_PKT_DATA_MPEGTS_STREAM_ID,
};
#define AV_PKT_DATA_QUALITY_FACTOR AV_PKT_DATA_QUALITY_STATS //DEPRECATED
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index 4901d361b1..9538bf39f3 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -351,6 +351,7 @@ const char *av_packet_side_data_name(enum AVPacketSideDataType type)
case AV_PKT_DATA_WEBVTT_IDENTIFIER: return "WebVTT ID";
case AV_PKT_DATA_WEBVTT_SETTINGS: return "WebVTT Settings";
case AV_PKT_DATA_METADATA_UPDATE: return "Metadata Update";
+ case AV_PKT_DATA_MPEGTS_STREAM_ID: return "MPEGTS Stream ID";
}
return NULL;
}
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 99ba2e7451..3580cf2ad7 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -30,7 +30,7 @@
#define LIBAVCODEC_VERSION_MAJOR 57
#define LIBAVCODEC_VERSION_MINOR 24
-#define LIBAVCODEC_VERSION_MICRO 105
+#define LIBAVCODEC_VERSION_MICRO 106
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 22874e6f83..e44da1fc4b 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -235,6 +235,7 @@ typedef struct PESContext {
int total_size;
int pes_header_size;
int extended_stream_id;
+ uint8_t stream_id;
int64_t pts, dts;
int64_t ts_packet_pos; /**< position of first TS packet of this PES packet */
uint8_t header[MAX_PES_HEADER_SIZE];
@@ -862,8 +863,10 @@ static void reset_pes_packet_state(PESContext *pes)
av_buffer_unref(&pes->buffer);
}
-static void new_pes_packet(PESContext *pes, AVPacket *pkt)
+static int new_pes_packet(PESContext *pes, AVPacket *pkt)
{
+ char *sd;
+
av_init_packet(pkt);
pkt->buf = pes->buffer;
@@ -891,6 +894,13 @@ static void new_pes_packet(PESContext *pes, AVPacket *pkt)
pes->buffer = NULL;
reset_pes_packet_state(pes);
+
+ sd = av_packet_new_side_data(pkt, AV_PKT_DATA_MPEGTS_STREAM_ID, 1);
+ if (!sd)
+ return AVERROR(ENOMEM);
+ *sd = pes->stream_id;
+
+ return 0;
}
static uint64_t get_ts64(GetBitContext *gb, int bits)
@@ -979,14 +989,16 @@ static int mpegts_push_data(MpegTSFilter *filter,
PESContext *pes = filter->u.pes_filter.opaque;
MpegTSContext *ts = pes->ts;
const uint8_t *p;
- int len, code;
+ int ret, len, code;
if (!ts->pkt)
return 0;
if (is_start) {
if (pes->state == MPEGTS_PAYLOAD && pes->data_index > 0) {
- new_pes_packet(pes, ts->pkt);
+ ret = new_pes_packet(pes, ts->pkt);
+ if (ret < 0)
+ return ret;
ts->stop_parse = 1;
} else {
reset_pes_packet_state(pes);
@@ -1014,6 +1026,7 @@ static int mpegts_push_data(MpegTSFilter *filter,
code = pes->header[3] | 0x100;
av_log(pes->stream, AV_LOG_TRACE, "pid=%x pes_code=%#x\n", pes->pid,
code);
+ pes->stream_id = pes->header[3];
if ((pes->st && pes->st->discard == AVDISCARD_ALL &&
(!pes->sub_st ||
@@ -1197,7 +1210,9 @@ skip:
if (pes->buffer) {
if (pes->data_index > 0 &&
pes->data_index + buf_size > pes->total_size) {
- new_pes_packet(pes, ts->pkt);
+ ret = new_pes_packet(pes, ts->pkt);
+ if (ret < 0)
+ return ret;
pes->total_size = MAX_PES_PAYLOAD;
pes->buffer = av_buffer_alloc(pes->total_size +
AV_INPUT_BUFFER_PADDING_SIZE);
@@ -1220,7 +1235,9 @@ skip:
if (!ts->stop_parse && pes->total_size < MAX_PES_PAYLOAD &&
pes->pes_header_size + pes->data_index == pes->total_size + PES_START_SIZE) {
ts->stop_parse = 1;
- new_pes_packet(pes, ts->pkt);
+ ret = new_pes_packet(pes, ts->pkt);
+ if (ret < 0)
+ return ret;
}
}
buf_size = 0;
@@ -2663,7 +2680,9 @@ static int mpegts_read_packet(AVFormatContext *s, AVPacket *pkt)
if (ts->pids[i] && ts->pids[i]->type == MPEGTS_PES) {
PESContext *pes = ts->pids[i]->u.pes_filter.opaque;
if (pes->state == MPEGTS_PAYLOAD && pes->data_index > 0) {
- new_pes_packet(pes, pkt);
+ ret = new_pes_packet(pes, pkt);
+ if (ret < 0)
+ return ret;
pes->state = MPEGTS_SKIP;
ret = 0;
break;
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 765672067a..68f98673da 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1111,7 +1111,7 @@ static uint8_t *get_ts_payload_start(uint8_t *pkt)
* NOTE: 'payload' contains a complete PES payload. */
static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
const uint8_t *payload, int payload_size,
- int64_t pts, int64_t dts, int key)
+ int64_t pts, int64_t dts, int key, int stream_id)
{
MpegTSWriteStream *ts_st = st->priv_data;
MpegTSWrite *ts = s->priv_data;
@@ -1208,6 +1208,11 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
st->codec->codec_id == AV_CODEC_ID_AC3 &&
ts->m2ts_mode) {
*q++ = 0xfd;
+ } else if (st->codec->codec_type == AVMEDIA_TYPE_DATA) {
+ *q++ = stream_id != -1 ? stream_id : 0xfc;
+
+ if (stream_id == 0xbd) /* asynchronous KLV */
+ pts = dts = AV_NOPTS_VALUE;
} else {
*q++ = 0xbd;
if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
@@ -1451,6 +1456,15 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
const int64_t delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE) * 2;
int64_t dts = pkt->dts, pts = pkt->pts;
int opus_samples = 0;
+ int side_data_size;
+ char *side_data = NULL;
+ int stream_id = -1;
+
+ side_data = av_packet_get_side_data(pkt,
+ AV_PKT_DATA_MPEGTS_STREAM_ID,
+ &side_data_size);
+ if (side_data)
+ stream_id = side_data[0];
if (ts->reemit_pat_pmt) {
av_log(s, AV_LOG_WARNING,
@@ -1629,8 +1643,8 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
if ( ts_st2->payload_size
&& (ts_st2->payload_dts == AV_NOPTS_VALUE || dts - ts_st2->payload_dts > delay/2)) {
mpegts_write_pes(s, st2, ts_st2->payload, ts_st2->payload_size,
- ts_st2->payload_pts, ts_st2->payload_dts,
- ts_st2->payload_flags & AV_PKT_FLAG_KEY);
+ ts_st2->payload_pts, ts_st2->payload_dts,
+ ts_st2->payload_flags & AV_PKT_FLAG_KEY, stream_id);
ts_st2->payload_size = 0;
}
}
@@ -1643,7 +1657,7 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
ts_st->opus_queued_samples + opus_samples >= 5760 /* 120ms */)) {
mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_size,
ts_st->payload_pts, ts_st->payload_dts,
- ts_st->payload_flags & AV_PKT_FLAG_KEY);
+ ts_st->payload_flags & AV_PKT_FLAG_KEY, stream_id);
ts_st->payload_size = 0;
ts_st->opus_queued_samples = 0;
}
@@ -1652,7 +1666,7 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
av_assert0(!ts_st->payload_size);
// for video and subtitle, write a single pes packet
mpegts_write_pes(s, st, buf, size, pts, dts,
- pkt->flags & AV_PKT_FLAG_KEY);
+ pkt->flags & AV_PKT_FLAG_KEY, stream_id);
ts_st->opus_queued_samples = 0;
av_free(data);
return 0;
@@ -1684,7 +1698,7 @@ static void mpegts_write_flush(AVFormatContext *s)
if (ts_st->payload_size > 0) {
mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_size,
ts_st->payload_pts, ts_st->payload_dts,
- ts_st->payload_flags & AV_PKT_FLAG_KEY);
+ ts_st->payload_flags & AV_PKT_FLAG_KEY, -1);
ts_st->payload_size = 0;
ts_st->opus_queued_samples = 0;
}
diff --git a/tests/ref/fate/concat-demuxer-simple2-lavf-ts b/tests/ref/fate/concat-demuxer-simple2-lavf-ts
index fb2713cddf..4a50f52c6f 100644
--- a/tests/ref/fate/concat-demuxer-simple2-lavf-ts
+++ b/tests/ref/fate/concat-demuxer-simple2-lavf-ts
@@ -1,12 +1,12 @@
-video|1|982|0.010911|-2618|-0.029089|3600|0.040000|N/A|N/A|24801|564|K
-video|1|4582|0.050911|982|0.010911|3600|0.040000|N/A|N/A|16429|27072|_
-video|1|8182|0.090911|4582|0.050911|3600|0.040000|N/A|N/A|14508|44932|_
-video|1|11782|0.130911|8182|0.090911|3600|0.040000|N/A|N/A|12622|60536|_
-video|1|15382|0.170911|11782|0.130911|3600|0.040000|N/A|N/A|13393|74260|_
-video|1|18982|0.210911|15382|0.170911|3600|0.040000|N/A|N/A|13092|88924|_
-video|1|22582|0.250911|18982|0.210911|3600|0.040000|N/A|N/A|12755|102836|_
-video|1|26182|0.290911|22582|0.250911|3600|0.040000|N/A|N/A|12023|116748|_
-audio|0|0|0.000000|0|0.000000|2351|0.026122|N/A|N/A|208|159988|K
+video|1|982|0.010911|-2618|-0.029089|3600|0.040000|N/A|N/A|24815|564|K
+video|1|4582|0.050911|982|0.010911|3600|0.040000|N/A|N/A|16443|27072|_
+video|1|8182|0.090911|4582|0.050911|3600|0.040000|N/A|N/A|14522|44932|_
+video|1|11782|0.130911|8182|0.090911|3600|0.040000|N/A|N/A|12636|60536|_
+video|1|15382|0.170911|11782|0.130911|3600|0.040000|N/A|N/A|13407|74260|_
+video|1|18982|0.210911|15382|0.170911|3600|0.040000|N/A|N/A|13106|88924|_
+video|1|22582|0.250911|18982|0.210911|3600|0.040000|N/A|N/A|12769|102836|_
+video|1|26182|0.290911|22582|0.250911|3600|0.040000|N/A|N/A|12037|116748|_
+audio|0|0|0.000000|0|0.000000|2351|0.026122|N/A|N/A|222|159988|K
audio|0|2351|0.026122|2351|0.026122|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|4702|0.052244|4702|0.052244|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|7053|0.078367|7053|0.078367|2351|0.026122|N/A|N/A|209|N/A|K
@@ -20,17 +20,17 @@ audio|0|23510|0.261222|23510|0.261222|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|25861|0.287344|25861|0.287344|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|28212|0.313467|28212|0.313467|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|30563|0.339589|30563|0.339589|2351|0.026122|N/A|N/A|209|N/A|K
-video|1|29782|0.330911|26182|0.290911|3600|0.040000|N/A|N/A|14098|130096|_
-video|1|33382|0.370911|29782|0.330911|3600|0.040000|N/A|N/A|13329|145324|_
-video|1|36982|0.410911|33382|0.370911|3600|0.040000|N/A|N/A|12135|162996|_
-video|1|40582|0.450911|36982|0.410911|3600|0.040000|N/A|N/A|12282|176344|_
-video|1|44182|0.490911|40582|0.450911|3600|0.040000|N/A|N/A|24786|189692|K
-video|1|47782|0.530911|44182|0.490911|3600|0.040000|N/A|N/A|17440|216388|_
-video|1|51382|0.570911|47782|0.530911|3600|0.040000|N/A|N/A|15019|235000|_
-video|1|54982|0.610911|51382|0.570911|3600|0.040000|N/A|N/A|13449|251356|_
-video|1|58582|0.650911|54982|0.610911|3600|0.040000|N/A|N/A|12398|266020|_
-video|1|62182|0.690911|58582|0.650911|3600|0.040000|N/A|N/A|13455|279744|_
-audio|0|32915|0.365722|32915|0.365722|2351|0.026122|N/A|N/A|209|322608|K
+video|1|29782|0.330911|26182|0.290911|3600|0.040000|N/A|N/A|14112|130096|_
+video|1|33382|0.370911|29782|0.330911|3600|0.040000|N/A|N/A|13343|145324|_
+video|1|36982|0.410911|33382|0.370911|3600|0.040000|N/A|N/A|12149|162996|_
+video|1|40582|0.450911|36982|0.410911|3600|0.040000|N/A|N/A|12296|176344|_
+video|1|44182|0.490911|40582|0.450911|3600|0.040000|N/A|N/A|24800|189692|K
+video|1|47782|0.530911|44182|0.490911|3600|0.040000|N/A|N/A|17454|216388|_
+video|1|51382|0.570911|47782|0.530911|3600|0.040000|N/A|N/A|15033|235000|_
+video|1|54982|0.610911|51382|0.570911|3600|0.040000|N/A|N/A|13463|251356|_
+video|1|58582|0.650911|54982|0.610911|3600|0.040000|N/A|N/A|12412|266020|_
+video|1|62182|0.690911|58582|0.650911|3600|0.040000|N/A|N/A|13469|279744|_
+audio|0|32915|0.365722|32915|0.365722|2351|0.026122|N/A|N/A|223|322608|K
audio|0|35266|0.391844|35266|0.391844|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|37617|0.417967|37617|0.417967|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|39968|0.444089|39968|0.444089|2351|0.026122|N/A|N/A|209|N/A|K
@@ -44,12 +44,12 @@ audio|0|56425|0.626944|56425|0.626944|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|58776|0.653067|58776|0.653067|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|61127|0.679189|61127|0.679189|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|63478|0.705311|63478|0.705311|2351|0.026122|N/A|N/A|209|N/A|K
-video|1|65782|0.730911|62182|0.690911|3600|0.040000|N/A|N/A|13836|294408|_
-video|1|69382|0.770911|65782|0.730911|3600|0.040000|N/A|N/A|12163|309448|_
-video|1|72982|0.810911|69382|0.770911|3600|0.040000|N/A|N/A|12692|325992|_
-video|1|76582|0.850911|72982|0.810911|3600|0.040000|N/A|N/A|10824|339528|_
-video|1|80182|0.890911|76582|0.850911|3600|0.040000|N/A|N/A|11286|351372|_
-audio|0|65829|0.731433|65829|0.731433|2351|0.026122|N/A|N/A|209|404576|K
+video|1|65782|0.730911|62182|0.690911|3600|0.040000|N/A|N/A|13850|294408|_
+video|1|69382|0.770911|65782|0.730911|3600|0.040000|N/A|N/A|12177|309448|_
+video|1|72982|0.810911|69382|0.770911|3600|0.040000|N/A|N/A|12706|325992|_
+video|1|76582|0.850911|72982|0.810911|3600|0.040000|N/A|N/A|10838|339528|_
+video|1|80182|0.890911|76582|0.850911|3600|0.040000|N/A|N/A|11300|351372|_
+audio|0|65829|0.731433|65829|0.731433|2351|0.026122|N/A|N/A|223|404576|K
audio|0|68180|0.757556|68180|0.757556|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|70531|0.783678|70531|0.783678|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|72882|0.809800|72882|0.809800|2351|0.026122|N/A|N/A|209|N/A|K
@@ -60,17 +60,17 @@ audio|0|82286|0.914289|82286|0.914289|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|84637|0.940411|84637|0.940411|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|86988|0.966533|86988|0.966533|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|89339|0.992656|89339|0.992656|2351|0.026122|N/A|N/A|209|N/A|K
-video|1|83782|0.930911|80182|0.890911|3600|0.040000|N/A|N/A|12678|363592|_
+video|1|83782|0.930911|80182|0.890911|3600|0.040000|N/A|N/A|12692|363592|_
video|1|87382|0.970911|83782|0.930911|3600|0.040000|N/A|N/A|24711|377880|K
-video|1|91964|1.021822|88364|0.981822|3600|0.040000|N/A|N/A|24801|564|K
-video|1|95564|1.061822|91964|1.021822|3600|0.040000|N/A|N/A|16429|27072|_
-video|1|99164|1.101822|95564|1.061822|3600|0.040000|N/A|N/A|14508|44932|_
-video|1|102764|1.141822|99164|1.101822|3600|0.040000|N/A|N/A|12622|60536|_
-video|1|106364|1.181822|102764|1.141822|3600|0.040000|N/A|N/A|13393|74260|_
-video|1|109964|1.221822|106364|1.181822|3600|0.040000|N/A|N/A|13092|88924|_
-video|1|113564|1.261822|109964|1.221822|3600|0.040000|N/A|N/A|12755|102836|_
-video|1|117164|1.301822|113564|1.261822|3600|0.040000|N/A|N/A|12023|116748|_
-audio|0|90982|1.010911|90982|1.010911|2351|0.026122|N/A|N/A|208|159988|K
+video|1|91964|1.021822|88364|0.981822|3600|0.040000|N/A|N/A|24815|564|K
+video|1|95564|1.061822|91964|1.021822|3600|0.040000|N/A|N/A|16443|27072|_
+video|1|99164|1.101822|95564|1.061822|3600|0.040000|N/A|N/A|14522|44932|_
+video|1|102764|1.141822|99164|1.101822|3600|0.040000|N/A|N/A|12636|60536|_
+video|1|106364|1.181822|102764|1.141822|3600|0.040000|N/A|N/A|13407|74260|_
+video|1|109964|1.221822|106364|1.181822|3600|0.040000|N/A|N/A|13106|88924|_
+video|1|113564|1.261822|109964|1.221822|3600|0.040000|N/A|N/A|12769|102836|_
+video|1|117164|1.301822|113564|1.261822|3600|0.040000|N/A|N/A|12037|116748|_
+audio|0|90982|1.010911|90982|1.010911|2351|0.026122|N/A|N/A|222|159988|K
audio|0|93333|1.037033|93333|1.037033|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|95684|1.063156|95684|1.063156|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|98035|1.089278|98035|1.089278|2351|0.026122|N/A|N/A|209|N/A|K
@@ -84,17 +84,17 @@ audio|0|114492|1.272133|114492|1.272133|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|116843|1.298256|116843|1.298256|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|119194|1.324378|119194|1.324378|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|121545|1.350500|121545|1.350500|2351|0.026122|N/A|N/A|209|N/A|K
-video|1|120764|1.341822|117164|1.301822|3600|0.040000|N/A|N/A|14098|130096|_
-video|1|124364|1.381822|120764|1.341822|3600|0.040000|N/A|N/A|13329|145324|_
-video|1|127964|1.421822|124364|1.381822|3600|0.040000|N/A|N/A|12135|162996|_
-video|1|131564|1.461822|127964|1.421822|3600|0.040000|N/A|N/A|12282|176344|_
-video|1|135164|1.501822|131564|1.461822|3600|0.040000|N/A|N/A|24786|189692|K
-video|1|138764|1.541822|135164|1.501822|3600|0.040000|N/A|N/A|17440|216388|_
-video|1|142364|1.581822|138764|1.541822|3600|0.040000|N/A|N/A|15019|235000|_
-video|1|145964|1.621822|142364|1.581822|3600|0.040000|N/A|N/A|13449|251356|_
-video|1|149564|1.661822|145964|1.621822|3600|0.040000|N/A|N/A|12398|266020|_
-video|1|153164|1.701822|149564|1.661822|3600|0.040000|N/A|N/A|13455|279744|_
-audio|0|123897|1.376633|123897|1.376633|2351|0.026122|N/A|N/A|209|322608|K
+video|1|120764|1.341822|117164|1.301822|3600|0.040000|N/A|N/A|14112|130096|_
+video|1|124364|1.381822|120764|1.341822|3600|0.040000|N/A|N/A|13343|145324|_
+video|1|127964|1.421822|124364|1.381822|3600|0.040000|N/A|N/A|12149|162996|_
+video|1|131564|1.461822|127964|1.421822|3600|0.040000|N/A|N/A|12296|176344|_
+video|1|135164|1.501822|131564|1.461822|3600|0.040000|N/A|N/A|24800|189692|K
+video|1|138764|1.541822|135164|1.501822|3600|0.040000|N/A|N/A|17454|216388|_
+video|1|142364|1.581822|138764|1.541822|3600|0.040000|N/A|N/A|15033|235000|_
+video|1|145964|1.621822|142364|1.581822|3600|0.040000|N/A|N/A|13463|251356|_
+video|1|149564|1.661822|145964|1.621822|3600|0.040000|N/A|N/A|12412|266020|_
+video|1|153164|1.701822|149564|1.661822|3600|0.040000|N/A|N/A|13469|279744|_
+audio|0|123897|1.376633|123897|1.376633|2351|0.026122|N/A|N/A|223|322608|K
audio|0|126248|1.402756|126248|1.402756|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|128599|1.428878|128599|1.428878|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|130950|1.455000|130950|1.455000|2351|0.026122|N/A|N/A|209|N/A|K
@@ -108,12 +108,12 @@ audio|0|147407|1.637856|147407|1.637856|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|149758|1.663978|149758|1.663978|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|152109|1.690100|152109|1.690100|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|154460|1.716222|154460|1.716222|2351|0.026122|N/A|N/A|209|N/A|K
-video|1|156764|1.741822|153164|1.701822|3600|0.040000|N/A|N/A|13836|294408|_
-video|1|160364|1.781822|156764|1.741822|3600|0.040000|N/A|N/A|12163|309448|_
-video|1|163964|1.821822|160364|1.781822|3600|0.040000|N/A|N/A|12692|325992|_
-video|1|167564|1.861822|163964|1.821822|3600|0.040000|N/A|N/A|10824|339528|_
-video|1|171164|1.901822|167564|1.861822|3600|0.040000|N/A|N/A|11286|351372|_
-audio|0|156811|1.742344|156811|1.742344|2351|0.026122|N/A|N/A|209|404576|K
+video|1|156764|1.741822|153164|1.701822|3600|0.040000|N/A|N/A|13850|294408|_
+video|1|160364|1.781822|156764|1.741822|3600|0.040000|N/A|N/A|12177|309448|_
+video|1|163964|1.821822|160364|1.781822|3600|0.040000|N/A|N/A|12706|325992|_
+video|1|167564|1.861822|163964|1.821822|3600|0.040000|N/A|N/A|10838|339528|_
+video|1|171164|1.901822|167564|1.861822|3600|0.040000|N/A|N/A|11300|351372|_
+audio|0|156811|1.742344|156811|1.742344|2351|0.026122|N/A|N/A|223|404576|K
audio|0|159162|1.768467|159162|1.768467|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|161513|1.794589|161513|1.794589|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|163864|1.820711|163864|1.820711|2351|0.026122|N/A|N/A|209|N/A|K
@@ -124,12 +124,12 @@ audio|0|173268|1.925200|173268|1.925200|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|175619|1.951322|175619|1.951322|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|177970|1.977444|177970|1.977444|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|180321|2.003567|180321|2.003567|2351|0.026122|N/A|N/A|209|N/A|K
-video|1|174764|1.941822|171164|1.901822|3600|0.040000|N/A|N/A|12678|363592|_
+video|1|174764|1.941822|171164|1.901822|3600|0.040000|N/A|N/A|12692|363592|_
video|1|178364|1.981822|174764|1.941822|3600|0.040000|N/A|N/A|24711|377880|K
-video|1|139582|1.550911|135982|1.510911|3600|0.040000|N/A|N/A|12692|325992|_
-video|1|143182|1.590911|139582|1.550911|3600|0.040000|N/A|N/A|10824|339528|_
-video|1|146782|1.630911|143182|1.590911|3600|0.040000|N/A|N/A|11286|351372|_
-audio|0|132429|1.471433|132429|1.471433|2351|0.026122|N/A|N/A|209|404576|K
+video|1|139582|1.550911|135982|1.510911|3600|0.040000|N/A|N/A|12706|325992|_
+video|1|143182|1.590911|139582|1.550911|3600|0.040000|N/A|N/A|10838|339528|_
+video|1|146782|1.630911|143182|1.590911|3600|0.040000|N/A|N/A|11300|351372|_
+audio|0|132429|1.471433|132429|1.471433|2351|0.026122|N/A|N/A|223|404576|K
audio|0|134780|1.497556|134780|1.497556|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|137131|1.523678|137131|1.523678|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|139482|1.549800|139482|1.549800|2351|0.026122|N/A|N/A|209|N/A|K
@@ -140,12 +140,12 @@ audio|0|148886|1.654289|148886|1.654289|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|151237|1.680411|151237|1.680411|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|153588|1.706533|153588|1.706533|2351|0.026122|N/A|N/A|209|N/A|K
audio|0|155939|1.732656|155939|1.732656|2351|0.026122|N/A|N/A|209|N/A|K
-video|1|150382|1.670911|146782|1.630911|3600|0.040000|N/A|N/A|12678|363592|_
+video|1|150382|1.670911|146782|1.630911|3600|0.040000|N/A|N/A|12692|363592|_
video|1|153982|1.710911|150382|1.670911|3600|0.040000|N/A|N/A|24711|377880|K
-video|1|161182|1.790911|157582|1.750911|3600|0.040000|N/A|N/A|12135|162996|_
-video|1|164782|1.830911|161182|1.790911|3600|0.040000|N/A|N/A|12282|176344|_
-video|1|168382|1.870911|164782|1.830911|3600|0.040000|N/A|N/A|24786|189692|K
-video|1|171982|1.910911|168382|1.870911|3600|0.040000|N/A|N/A|17440|216388|_
-video|1|175582|1.950911|171982|1.910911|3600|0.040000|N/A|N/A|15019|235000|_
+video|1|161182|1.790911|157582|1.750911|3600|0.040000|N/A|N/A|12149|162996|_
+video|1|164782|1.830911|161182|1.790911|3600|0.040000|N/A|N/A|12296|176344|_
+video|1|168382|1.870911|164782|1.830911|3600|0.040000|N/A|N/A|24800|189692|K
+video|1|171982|1.910911|168382|1.870911|3600|0.040000|N/A|N/A|17454|216388|_
+video|1|175582|1.950911|171982|1.910911|3600|0.040000|N/A|N/A|15033|235000|_
0|mp2|unknown|audio|1/44100|[3][0][0][0]|0x0003|s16p|44100|1|mono|0|N/A|0/0|0/0|1/90000|0|0.000000|N/A|N/A|64000|N/A|N/A|N/A|N/A|89|0|0|0|0|0|0|0|0|0|0|0
1|mpeg2video|4|video|1/50|[2][0][0][0]|0x0002|352|288|0|0|1|1:1|11:9|yuv420p|8|tv|unknown|unknown|unknown|left|00:00:00:00|1|N/A|25/1|25/1|1/90000|N/A|N/A|N/A|N/A|N/A|104857200|N/A|N/A|N/A|60|0|0|0|0|0|0|0|0|0|0|0
diff --git a/tests/ref/seek/lavf-ts b/tests/ref/seek/lavf-ts
index e57651ef9c..f9808242f0 100644
--- a/tests/ref/seek/lavf-ts
+++ b/tests/ref/seek/lavf-ts
@@ -1,53 +1,53 @@
-ret: 0 st: 0 flags:1 dts: 1.400000 pts: 1.440000 pos: 564 size: 24801
+ret: 0 st: 0 flags:1 dts: 1.400000 pts: 1.440000 pos: 564 size: 24815
ret: 0 st:-1 flags:0 ts:-1.000000
-ret: 0 st: 0 flags:1 dts: 1.400000 pts: 1.440000 pos: 564 size: 24801
+ret: 0 st: 0 flags:1 dts: 1.400000 pts: 1.440000 pos: 564 size: 24815
ret: 0 st:-1 flags:1 ts: 1.894167
-ret: 0 st: 0 flags:1 dts: 1.880000 pts: 1.920000 pos: 189692 size: 24786
+ret: 0 st: 0 flags:1 dts: 1.880000 pts: 1.920000 pos: 189692 size: 24800
ret: 0 st: 0 flags:0 ts: 0.788333
-ret: 0 st: 0 flags:1 dts: 1.400000 pts: 1.440000 pos: 564 size: 24801
+ret: 0 st: 0 flags:1 dts: 1.400000 pts: 1.440000 pos: 564 size: 24815
ret: 0 st: 0 flags:1 ts:-0.317500
-ret: 0 st: 0 flags:1 dts: 1.400000 pts: 1.440000 pos: 564 size: 24801
+ret: 0 st: 0 flags:1 dts: 1.400000 pts: 1.440000 pos: 564 size: 24815
ret: 0 st: 1 flags:0 ts: 2.576667
-ret: 0 st: 1 flags:1 dts: 2.160522 pts: 2.160522 pos: 404576 size: 209
+ret: 0 st: 1 flags:1 dts: 2.160522 pts: 2.160522 pos: 404576 size: 223
ret: 0 st: 1 flags:1 ts: 1.470833
-ret: 0 st: 1 flags:1 dts: 1.429089 pts: 1.429089 pos: 159988 size: 208
+ret: 0 st: 1 flags:1 dts: 1.429089 pts: 1.429089 pos: 159988 size: 222
ret: 0 st:-1 flags:0 ts: 0.365002
-ret: 0 st: 0 flags:1 dts: 1.400000 pts: 1.440000 pos: 564 size: 24801
+ret: 0 st: 0 flags:1 dts: 1.400000 pts: 1.440000 pos: 564 size: 24815
ret: 0 st:-1 flags:1 ts:-0.740831
-ret: 0 st: 0 flags:1 dts: 1.400000 pts: 1.440000 pos: 564 size: 24801
+ret: 0 st: 0 flags:1 dts: 1.400000 pts: 1.440000 pos: 564 size: 24815
ret: 0 st: 0 flags:0 ts: 2.153333
-ret: 0 st: 1 flags:1 dts: 1.794811 pts: 1.794811 pos: 322608 size: 209
+ret: 0 st: 1 flags:1 dts: 1.794811 pts: 1.794811 pos: 322608 size: 223
ret: 0 st: 0 flags:1 ts: 1.047500
-ret: 0 st: 0 flags:1 dts: 1.400000 pts: 1.440000 pos: 564 size: 24801
+ret: 0 st: 0 flags:1 dts: 1.400000 pts: 1.440000 pos: 564 size: 24815
ret: 0 st: 1 flags:0 ts:-0.058333
-ret: 0 st: 1 flags:1 dts: 1.429089 pts: 1.429089 pos: 159988 size: 208
+ret: 0 st: 1 flags:1 dts: 1.429089 pts: 1.429089 pos: 159988 size: 222
ret: 0 st: 1 flags:1 ts: 2.835833
-ret: 0 st: 1 flags:1 dts: 2.160522 pts: 2.160522 pos: 404576 size: 209
+ret: 0 st: 1 flags:1 dts: 2.160522 pts: 2.160522 pos: 404576 size: 223
ret: 0 st:-1 flags:0 ts: 1.730004
-ret: 0 st: 1 flags:1 dts: 1.429089 pts: 1.429089 pos: 159988 size: 208
+ret: 0 st: 1 flags:1 dts: 1.429089 pts: 1.429089 pos: 159988 size: 222
ret: 0 st:-1 flags:1 ts: 0.624171
-ret: 0 st: 0 flags:1 dts: 1.400000 pts: 1.440000 pos: 564 size: 24801
+ret: 0 st: 0 flags:1 dts: 1.400000 pts: 1.440000 pos: 564 size: 24815
ret: 0 st: 0 flags:0 ts:-0.481667
-ret: 0 st: 0 flags:1 dts: 1.400000 pts: 1.440000 pos: 564 size: 24801
+ret: 0 st: 0 flags:1 dts: 1.400000 pts: 1.440000 pos: 564 size: 24815
ret: 0 st: 0 flags:1 ts: 2.412500
-ret: 0 st: 1 flags:1 dts: 2.160522 pts: 2.160522 pos: 404576 size: 209
+ret: 0 st: 1 flags:1 dts: 2.160522 pts: 2.160522 pos: 404576 size: 223
ret: 0 st: 1 flags:0 ts: 1.306667
-ret: 0 st: 1 flags:1 dts: 1.429089 pts: 1.429089 pos: 159988 size: 208
+ret: 0 st: 1 flags:1 dts: 1.429089 pts: 1.429089 pos: 159988 size: 222
ret: 0 st: 1 flags:1 ts: 0.200844
-ret: 0 st: 1 flags:1 dts: 1.429089 pts: 1.429089 pos: 159988 size: 208
+ret: 0 st: 1 flags:1 dts: 1.429089 pts: 1.429089 pos: 159988 size: 222
ret: 0 st:-1 flags:0 ts:-0.904994
-ret: 0 st: 0 flags:1 dts: 1.400000 pts: 1.440000 pos: 564 size: 24801
+ret: 0 st: 0 flags:1 dts: 1.400000 pts: 1.440000 pos: 564 size: 24815
ret: 0 st:-1 flags:1 ts: 1.989173
-ret: 0 st: 0 flags:0 dts: 1.960000 pts: 2.000000 pos: 235000 size: 15019
+ret: 0 st: 0 flags:0 dts: 1.960000 pts: 2.000000 pos: 235000 size: 15033
ret: 0 st: 0 flags:0 ts: 0.883344
-ret: 0 st: 0 flags:1 dts: 1.400000 pts: 1.440000 pos: 564 size: 24801
+ret: 0 st: 0 flags:1 dts: 1.400000 pts: 1.440000 pos: 564 size: 24815
ret: 0 st: 0 flags:1 ts:-0.222489
-ret: 0 st: 0 flags:1 dts: 1.400000 pts: 1.440000 pos: 564 size: 24801
+ret: 0 st: 0 flags:1 dts: 1.400000 pts: 1.440000 pos: 564 size: 24815
ret: 0 st: 1 flags:0 ts: 2.671678
-ret: 0 st: 1 flags:1 dts: 2.160522 pts: 2.160522 pos: 404576 size: 209
+ret: 0 st: 1 flags:1 dts: 2.160522 pts: 2.160522 pos: 404576 size: 223
ret: 0 st: 1 flags:1 ts: 1.565844
-ret: 0 st: 1 flags:1 dts: 1.429089 pts: 1.429089 pos: 159988 size: 208
+ret: 0 st: 1 flags:1 dts: 1.429089 pts: 1.429089 pos: 159988 size: 222
ret: 0 st:-1 flags:0 ts: 0.460008
-ret: 0 st: 0 flags:1 dts: 1.400000 pts: 1.440000 pos: 564 size: 24801
+ret: 0 st: 0 flags:1 dts: 1.400000 pts: 1.440000 pos: 564 size: 24815
ret: 0 st:-1 flags:1 ts:-0.645825
-ret: 0 st: 0 flags:1 dts: 1.400000 pts: 1.440000 pos: 564 size: 24801
+ret: 0 st: 0 flags:1 dts: 1.400000 pts: 1.440000 pos: 564 size: 24815