Opened 4 years ago

Closed 4 years ago

#9006 closed defect (fixed)

merge_pmt_versions not working properly for transportstream with multiple streams having same stream_identifier

Reported by: deeptho Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: ffmpeg@tmm1.net, Marton Balint Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

Some transport streams contain multiple audio streams with the
the same stream_identifier. In this case, when the merge_pmt_versions
option is activated, ffmpeg gets confused.

How to reproduce:

Compare

ffplay -ast 0 00_20201123_230057.ts

  Stream #0:0[0x1b6]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 50 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x1c1](ita): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 448 kb/s
    Stream #0:2[0x1c2](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, fltp, 128 kb/s
    Stream #0:3[0x24c](ita,ita,eng): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006), 492x250
    Stream #0:4[0x28a](Oth): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, mono, fltp, 64 kb/s
    Stream #0:5[0xbb9]: Unknown: none ([11][0][0][0] / 0x000B)
    Stream #0:6[0xbba]: Unknown: none ([11][0][0][0] / 0x000B)
    Stream #0:7[0x7d1]: Unknown: none ([5][0][0][0] / 0x0005)
    Stream #0:8[0x7d2]: Unknown: none ([5][0][0][0] / 0x0005)
    Stream #0:9[0xc1d]: Unknown: none ([12][0][0][0] / 0x000C)

to

ffplay -merge_pmt_versions 1 -ast 0 00_20201123_230057.ts

   Stream #0:0[0x1b6]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 50 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x1c1](ita): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 448 kb/s
    Stream #0:2[0x1c2](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, fltp, 96 kb/s
    Stream #0:3[0x24c](ita,ita,eng): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006), 492x250
    Stream #0:4[0xbb9]: Unknown: none ([11][0][0][0] / 0x000B)
    Stream #0:5[0xbba]: Unknown: none ([11][0][0][0] / 0x000B)
    Stream #0:6[0x7d1]: Unknown: none ([5][0][0][0] / 0x0005)
    Stream #0:7[0x7d2]: Unknown: none ([5][0][0][0] / 0x0005)
    Stream #0:8[0xc1d]: Unknown: none ([12][0][0][0] / 0x000C)


The second mp2 stream is missing.

Note that this test stream does not
have pmt changes. The net effect is that in my own viewer
that I am developing the stream fails to play back properly.
I have not been able to create a simple ffplay command that
actually shows a failing playback,

Still an inspection of the source shows the problem:
when the very first pmt is loaded,
"find_matching_stream" is called
with the following audio streams:

pid 450 (eng), stream_identifier=2
pid 650 (Oth), stream_identifier=2
...

The code then decides that 650 replaces 450, which is
of course incorrect.

Attachments (2)

pmt.txt (8.0 KB ) - added by deeptho 4 years ago.
parsed version of the pmt (obtained with dvbsnoop)
0001-avformat-mpegts-use-stream-index-based-lookup-with-m.patch (5.9 KB ) - added by Marton Balint 4 years ago.

Download all attachments as: .zip

Change History (10)

by deeptho, 4 years ago

Attachment: pmt.txt added

parsed version of the pmt (obtained with dvbsnoop)

comment:1 by Carl Eugen Hoyos, 4 years ago

Please provide the input file.

comment:2 by Aman, 4 years ago

Cc: ffmpeg@tmm1.net added

Yes, please share a small sample file with such a PMT

comment:3 by Marton Balint, 4 years ago

Cc: Marton Balint added

comment:4 by deeptho, 4 years ago

The alternative patch does not appear to work. With the same ffplay command,
I get:

ffplay -merge_pmt_versions 1 -ast 0 00_20201123_230057.ts

Stream #0:0[0x1b6]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 50 tbr, 90k tbn, 50 tbc
Stream #0:1[0x1c1](ita): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 448 kb/s
Stream #0:2[0x1c2](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, fltp, 96 kb/s
Stream #0:3[0x24c](ita,ita,eng): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
Stream #0:4[0xbb9]: Unknown: none ([11][0][0][0] / 0x000B)


So the second mp2 stream is still not found

in reply to:  2 comment:5 by deeptho, 4 years ago

Replying to tmm1:

Yes, please share a small sample file with such a PMT

I replied to that mailing list but the email bounced.

I have uploaded a sample on wetransfer.

This is a partial mpeg transport stream. It contain PAT, PMT and all streams related
to the specific program.

https://we.tl/t-F06CV0xo66

comment:6 by Marton Balint, 4 years ago

New patch attached here, please comment.

comment:7 by deeptho, 4 years ago

With the new patch:

ffplay -merge_pmt_versions 1 -ast 0 00_20201123_230057.ts

  Stream #0:0[0x1b6]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 50 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x1c1](ita): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 448 kb/s
    Stream #0:2[0x1c2](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, fltp, 128 kb/s
    Stream #0:3[0x24c](ita,ita,eng): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
    Stream #0:4[0x28a](Oth): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, mono, fltp, 64 kb/s

So this looks good.


comment:8 by Marton Balint, 4 years ago

Resolution: fixed
Status: newclosed

In the end this got fixed differently: e57879ec18edab5827268a498577cece82d56811

Note: See TracTickets for help on using tickets.