diff --git a/doc/demuxers.texi b/doc/demuxers.texi index e7c2abce57..1d2ee5bf37 100644 --- a/doc/demuxers.texi +++ b/doc/demuxers.texi @@ -538,6 +538,9 @@ This demuxer accepts the following options: Set size limit for looking up a new synchronization. Default value is 65536. +@item skip_unknown_pmt +Skip PMTs for programs not defined in the PAT. Default value is 0. + @item fix_teletext_pts Override teletext packet PTS and DTS values with the timestamps calculated from the PCR of the first program which the teletext stream is part of and is diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index fc9bb3940e..18df1afd9d 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -143,6 +143,7 @@ struct MpegTSContext { int skip_changes; int skip_clear; + int skip_unknown_pmt; int scan_all_pmts; @@ -172,6 +173,8 @@ static const AVOption options[] = { {.i64 = 0}, 0, 0, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_EXPORT | AV_OPT_FLAG_READONLY }, {"scan_all_pmts", "scan and combine all PMTs", offsetof(MpegTSContext, scan_all_pmts), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, AV_OPT_FLAG_DECODING_PARAM }, + {"skip_unknown_pmt", "skip PMTs for programs not advertised in the PAT", offsetof(MpegTSContext, skip_unknown_pmt), AV_OPT_TYPE_BOOL, + {.i64 = 0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, {"skip_changes", "skip changing / adding streams / programs", offsetof(MpegTSContext, skip_changes), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, 0 }, {"skip_clear", "skip clearing programs", offsetof(MpegTSContext, skip_clear), AV_OPT_TYPE_BOOL, @@ -2028,6 +2031,8 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len if (!ts->scan_all_pmts && ts->skip_changes) return; + if (ts->skip_unknown_pmt && !get_program(ts, h->id)) + return; if (!ts->skip_clear) clear_program(ts, h->id);