1 diff -urN a/libavformat/avformat.h b/libavformat/avformat.h
2 --- a/libavformat/avformat.h 2018-11-05 16:22:26.000000000 -0700
3 +++ b/libavformat/avformat.h 2018-11-08 07:25:17.066799941 -0700
5 The user or muxer can override this through
6 AVFormatContext.avoid_negative_ts
8 +#define AVFMT_SEEK_NOSTREAMS 0x80000 /**< Stream index ignored by seek,
9 + or some streams fail to seek
12 #define AVFMT_SEEK_TO_PTS 0x4000000 /**< Seeking is based on PTS */
16 * Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS,
17 * AVFMT_GENERIC_INDEX, AVFMT_TS_DISCONT, AVFMT_NOBINSEARCH,
18 - * AVFMT_NOGENSEARCH, AVFMT_NO_BYTE_SEEK, AVFMT_SEEK_TO_PTS.
19 + * AVFMT_NOGENSEARCH, AVFMT_NO_BYTE_SEEK, AVFMT_SEEK_TO_PTS,
20 + * AVFMT_SEEK_NOSTREAMS
24 diff -urN a/libavformat/dv.c b/libavformat/dv.c
25 --- a/libavformat/dv.c 2018-11-01 12:34:26.000000000 -0600
26 +++ b/libavformat/dv.c 2018-11-08 07:25:17.066799941 -0700
28 AVInputFormat ff_dv_demuxer = {
30 .long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"),
31 + .flags = AVFMT_SEEK_NOSTREAMS,
32 .priv_data_size = sizeof(RawDVContext),
33 .read_probe = dv_probe,
34 .read_header = dv_read_header,
35 diff -urN a/libavformat/matroskadec.c b/libavformat/matroskadec.c
36 --- a/libavformat/matroskadec.c 2018-11-05 16:22:26.000000000 -0700
37 +++ b/libavformat/matroskadec.c 2018-11-08 07:25:17.067799930 -0700
39 AVInputFormat ff_matroska_demuxer = {
40 .name = "matroska,webm",
41 .long_name = NULL_IF_CONFIG_SMALL("Matroska / WebM"),
42 + .flags = AVFMT_SEEK_NOSTREAMS,
43 .extensions = "mkv,mk3d,mka,mks",
44 .priv_data_size = sizeof(MatroskaDemuxContext),
45 .read_probe = matroska_probe,
47 AVInputFormat ff_webm_dash_manifest_demuxer = {
48 .name = "webm_dash_manifest",
49 .long_name = NULL_IF_CONFIG_SMALL("WebM DASH Manifest"),
50 + .flags = AVFMT_SEEK_NOSTREAMS,
51 .priv_data_size = sizeof(MatroskaDemuxContext),
52 .read_header = webm_dash_manifest_read_header,
53 .read_packet = webm_dash_manifest_read_packet,
54 diff -urN a/libavformat/utils.c b/libavformat/utils.c
55 --- a/libavformat/utils.c 2018-11-05 16:22:26.000000000 -0700
56 +++ b/libavformat/utils.c 2018-11-08 07:25:17.069799908 -0700
57 @@ -2472,6 +2472,13 @@
58 return seek_frame_byte(s, stream_index, timestamp, flags);
61 + if (stream_index != -1 && (s->iformat->flags & AVFMT_SEEK_NOSTREAMS)) {
62 + timestamp = av_rescale_q(timestamp,
63 + s->streams[stream_index]->time_base,
68 if (stream_index < 0) {
69 stream_index = av_find_default_stream_index(s);