[vlc-devel] DVD subtitles and MPEG TS demuxer

Csaba Buday budaycsaba at gmail.com
Sat Dec 30 08:48:03 UTC 2023


Dear VLC Developers,

I may have come upon a regression in the MPEG TS handling.

I am trying to convert my DVDs to regular MPEG files, without transcoding.

I use a command like this:
cvlc -v --no-random --no-loop --no-repeat "dvdsimple:///dev/dvd#1-1"
--sout="#std{access=file{no-overwrite},mux=ps,dst=output.mpg}" --sout-all
vlc://quit

When I convert them to MPEG PS, they work. But the subtitle and audio track
languages are not shown anymore (just track 1, track 2, etc.), they must be
guessed during playback. Even though the three letter language codes are
present in the output file.

So I also tried to convert them to MPEG TS. Now the track languages are
visible, BUT the subtitles do not work. They are not even recognized as DVD
subtitles anymore, they are recognized as SCTE-27 subtitles.

According to this wiki page, even streaming should work:
https://wiki.videolan.org/Documentation:Streaming_HowTo/Stream_a_DVD/
Needless to say, I get the same result with UDP streaming as with streaming
to an output file.

I also get errors during playback, seemingly when the subtitles should be
displayed:
[00007f02800011a0] ts demux error: libdvbpsi error (misc PSI): Bad CRC_32
table 0xb2 !!!

I did some digging in the source code.
The muxer sets the i_stream_type to 0x82 for DVD subtitles.
https://github.com/videolan/vlc/blob/3.0.18/modules/mux/mpeg/tables.c#L853

    case VLC_CODEC_SPU:
        ts->i_stream_type = 0x82;
        pes->i_stream_id = 0xbd;
        break;

This has been introduced in version 0.6.2 as I can see, for both the muxer
and the demuxer.
https://github.com/videolan/vlc/blob/0.6.2/modules/mux/mpeg/ts.c#L469
https://github.com/videolan/vlc/blob/0.6.2/modules/demux/mpeg/ts.c#L1342

When SCTE-27 subtitles were introduced in 2.1.0, the DVD subtitle handling
was dropped:
https://github.com/videolan/vlc/commit/7e3dcdd09c2fac64f00acb360d30f24c74894609#diff-06fb03bad25d92afcf0a4e5f1a78a8f80b4766cd2541e82a27a62318ddd5935eL2174

Was this intentional? It was simply just deleted and replaced with SCTE-27,
which obviously does not work with DVD subtitles. Removing this capability
is not mentioned in the changelog OR the commit message.

So I installed the 2.0.8 version, and the subtitles worked, just as they
should. Subtitles work even when streaming from a new version of VLC
(3.0.20 from debian), and playback with 2.0.8, which confirms that the
muxing code is intact. With playback on 2.1.0 however, subtitles do not
work anymore.

So I grabbed the code, and tried to revert this change.
@@ -1440,10 +1440,7 @@
         es_format_Change( fmt, AUDIO_ES, VLC_CODEC_A52 );
         break;
     case 0x82:  /* SCTE-27 (sub) */
-        es_format_Change( fmt, SPU_ES, VLC_CODEC_SCTE_27 );
-        *p_datatype = TS_TRANSPORT_SECTIONS;
-        ts_sections_processor_Add( p_demux, &p_pes->p_sections_proc, 0xC6,
0x00,
-                                   SCTE27_Section_Callback, p_pes );
+        es_format_Change( fmt, SPU_ES, VLC_CODEC_SPU );
         break;
     case 0x84:  /* SDDS (audio) */
         es_format_Change( fmt, AUDIO_ES, VLC_CODEC_SDDS );

This fixed the issue. But this obviously breaks SCTE27 subtitles.

There is also the 0x92 stream type for DVD subtitles, but is seems to be
some legacy VLS code. I tried to change the ts mux code to 0x92, but it did
not work. I was able to fix that too, but that is an other story.

I understand that this may not be a widely used feature, it has been broken
for 10+ years and no one complained... I do not even know if it is part of
the MPEG standard, or just VLC specific, but it would be great, if it
worked.

Best regards,
Csaba Buday
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20231230/7e5544b3/attachment.htm>


More information about the vlc-devel mailing list