Opened 11 years ago

Closed 11 years ago

#2989 closed defect (fixed)

broken remuxing DVB subtitles from MPEG-TS to MPEG-TS

Reported by: Clément Bœsch Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: mpegts dvbsub
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

[~/src/ffmpeg]☭ ./ffmpeg -v verbose -i ~/samples/stream.TS -c copy -map 0:0 -map 0:5 -y test.ts
ffmpeg version N-56570-gf8e8932 Copyright (c) 2000-2013 the FFmpeg developers
  built on Sep 22 2013 20:54:45 with gcc 4.8.1 (GCC) 20130725 (prerelease)
  configuration: --enable-gpl --enable-version3 --enable-fontconfig --enable-libfreetype --enable-libmp3lame --enable-libvorbis --enable-libxvid --enable-libx264 --enable-libvpx --enable-libtheora --enable-x11grab --enable-libopenjpeg --enable-libass --enable-libmodplug --enable-libv4l2 --cc=colorgcc --samples=/home/ubitux/fate-samples --prefix=/tmp/ffinstall --disable-runtime-cpudetect --enable-libcelt --enable-libopencv --enable-frei0r --enable-libcaca --enable-libiec61883 --enable-libopencore-amrwb --enable-libopencore-amrnb --enable-libopus --enable-libpulse --enable-libspeex --enable-libquvi --assert-level=2 --enable-libzmq --enable-libschroedinger --cpu=native
  libavutil      52. 46.100 / 52. 46.100
  libavcodec     55. 33.100 / 55. 33.100
  libavformat    55. 18.102 / 55. 18.102
  libavdevice    55.  3.100 / 55.  3.100
  libavfilter     3. 87.100 /  3. 87.100
  libswscale      2.  5.100 /  2.  5.100
  libswresample   0. 17.103 /  0. 17.103
  libpostproc    52.  3.100 / 52.  3.100
[mpegts @ 0x2c65400] parser not found for codec dvb_teletext, packets or times may be invalid.
    Last message repeated 1 times
[mpeg2video @ 0x2c7f5e0] Invalid frame dimensions 0x0.
    Last message repeated 10 times
[mpegts @ 0x2c65400] max_analyze_duration 5000000 reached at 5000000 microseconds
[NULL @ 0x2c855c0] start time is not set in estimate_timings_from_pts
[mpegts @ 0x2c65400] PES packet size mismatch
    Last message repeated 3 times
Input #0, mpegts, from '/home/ubitux/samples/stream.TS':
  Duration: 00:01:44.00, start: 31021.622067, bitrate: 5535 kb/s
  Program 1537 
    Metadata:
      service_name    : TF1
      service_provider: SMR6
    Stream #0:0[0x78]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 15000 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x82](fra): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 192 kb/s
    Stream #0:2[0x83](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 128 kb/s
    Stream #0:3[0x85](qad): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 128 kb/s
    Stream #0:4[0x8c](fra): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
    Stream #0:5[0x96](fra): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006) (hearing impaired)
    Stream #0:6[0x97](eng): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
[mpegts @ 0x2c8a520] muxrate VBR, pcr every 2 pkts, sdt every 200, pat/pmt every 40 pkts
Output #0, mpegts, to 'test.ts':
  Metadata:
    encoder         : Lavf55.18.102
    Stream #0:0: Video: mpeg2video ([2][0][0][0] / 0x0002), yuv420p, 720x576 [SAR 64:45 DAR 16:9], q=2-31, max. 15000 kb/s, 25 fps, 90k tbn, 25 tbc
    Stream #0:1(fra): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006) (hearing impaired)
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:5 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mpegts @ 0x2c65400] Correcting start time by 200000
No more output streams to write to, finishing.
frame= 2582 fps=0.0 q=-1.0 Lsize=   64164kB time=00:01:43.72 bitrate=5067.8kbits/s    
video:59246kB audio:0kB subtitle:116 global headers:0kB muxing overhead 8.089452%

The mapped DVB subtitle stream is visible in VLC, mplayer, mpv, with the original file. After remuxing, the subtitles are not visible anymore (likely nothing is remuxed in the destination stream).

Sample is available here: http://lucy.pkh.me/samples/fr-tv-dvd-sub-and-teletext.ts (~69M)

Change History (6)

comment:1 by Carl Eugen Hoyos, 11 years ago

Keywords: dvbsub added; dvb_subtitles removed

comment:2 by Clément Bœsch, 11 years ago

I just realized this might be a duplicate of #2024.

comment:3 by mrlika, 11 years ago

Hi,

I found the root of the problem and going to fix it but I need FFmpeg expert advice in choosing a correct way to do it.

Description of the issue:

DVB subtitles have the following format in MPEG-TS stream:

data_identifier 8bit - always set to 0x20
subtitle_stream_id 8bit - always set to 0x00
subtitling_segments - actual payload
end_of_PES_data_field_makrer 8bit - always set to 0xFF

MPEG-TS demuxer throws everything except subtitling_segments and produces AVPacket.data in FORMAT 1:

subtitling_segments - actual payload

DVB subtitles decoder also expects AVPacket.data in FORMAT 1.

DVB subtitles encoder produces AVPacket.data in FORMAT 2:

subtitle_stream_id 8bit - always set to 0x00
subtitling_segments - actual payload
end_of_PES_data_field_makrer 8bit - always set to 0xFF

MPEG-TS muxer expects AVPacket.data to be in FORMAT 2 also.

So we have problem: from one hand demuxed and decoder work with AVPacket.data in FORMAT 1, from other hand encoder and muxer work with AVPacket data in FORMAT 2.

That is why when you copy subtitles directly from demuxer into muxer you get incorrect subtitles stream.

I see three possible ways of fixing the issue:

1) Use FORMAT 1 everywhere (i.e. fix DVB subtitles encoder and all muxers that support DVB subtitles to use FORMAT 1)

2) Use FORMAT 2 everywhere (i.e. fix DVB subtitles decoder and all demuxers that produce DVB subtitles to user FORMAT 2)

3) Use some other format for AVPacket.data with DVB subtitles and fix all the components to work with it.

Can you please advice the correct way of solving the issue?

Regards,
Andriy Lysnevych

Last edited 11 years ago by mrlika (previous) (diff)

in reply to:  3 comment:4 by Clément Bœsch, 11 years ago

Replying to mrlika:

[...]
Can you please advice the correct way of solving the issue?

I think someone is looking at this issue, you might want to follow this thread: http://ffmpeg.org/pipermail/ffmpeg-devel/2013-December/152174.html and eventually participate.

comment:5 by mrlika, 11 years ago

This issue should be fixed with https://github.com/FFmpeg/FFmpeg/commit/c917cde9cc52ad1ca89926a617f847bc9861d5a0 commit.

Also this bug is duplicate of third problem from ticket #2024.

Version 0, edited 11 years ago by mrlika (next)

comment:6 by Carl Eugen Hoyos, 11 years ago

Resolution: fixed
Status: newclosed

Fixed by Serhii Marchuk in c917cde9

Note: See TracTickets for help on using tickets.