[FFmpeg-devel] [PATCH] avformat/mpegts: add skip_unknown_pmt option

Aman Gupta aman at tmm1.net
Fri May 18 20:15:56 EEST 2018

On Fri, May 18, 2018 at 6:12 AM, Devin Heitmueller <
dheitmueller at kernellabs.com> wrote:

> Hello Aman,
> On Thu, May 17, 2018 at 8:04 PM, Aman Gupta <ffmpeg at tmm1.net> wrote:
> > From: Aman Gupta <aman at tmm1.net>
> >
> > Some filtered mpegts streams may erroneously include PMTs for programs
> > that are not advertised in the PAT. This confuses ffmpeg and most
> > players because multiple audio/video streams are created and it is
> > unclear which ones actually contain data.
> I guess my big question would be, why is the ffmpeg TS demux
> interpreting some PIDs as containing PMT if they are not referenced by
> the PAT?  I have to assume there is some heuristic in there which
> looks at arbitrary PID data and attempts to treat it as a PMT table
> (presumably in an attempt to play TS streams which are missing PAT).

There is no such heuristic, and ffmpeg is not interpreting random PIDs as
containing PMTs.

The issue is that the PMT PID advertised in the PAT contains multiple PMTs
for different programs. This is because the broadcaster decided to re-use
the same PID for multiple program PMTs.

> If that's the case, then I think *that's* what the patch should
> disable - assume the PAT/PMT are present and well-formed and don't
> play games trying to find a PMT assuming the PAT is absent/malformed.
> I can appreciate a player doing it's best to play some screwed up
> stream, but that sort of logic should not be the default.  There are
> all sorts of strange proprietary data sent by broadcasters over PIDs
> and I wouldn't want those to get mis-detected as PMT when the spec
> says PIDs not explicitly in the PAT/PMT should be completely ignored.

Again, we don't look at random PIDs and try to make sense of the data on

I think this option makes sense by default, because it follows how the spec
says the stream should be interpreted. Look at the PAT for programs, then
search the pids listed for PMTs that match those programs.

To be clear, this issue is specific to _filtered_ mpegts streams. In this
case, my tuner hardware is trying to filter the mpegts stream from the
broadcaster to include only the program I care about. It does this by
rewriting the PAT to contain only the program I requested, but since it
just passes through the pid reference in the PAT, all the PMTs  (including
those for other programs) come through. Most of the time this works fine,
because the pmt pid only contains PMTs for a single program.

Hope that makes sense,

> Devin
> --
> Devin J. Heitmueller - Kernel Labs
> http://www.kernellabs.com

More information about the ffmpeg-devel mailing list