[FFmpeg-user] Preserve dvb_subtitles when transcoding

Jakub Vojáček jakub at jacon.cz
Sun Jul 8 01:15:00 EEST 2018


Hello,

I am having problem recording dvb_subtitles from a live stream into a mp4
file. I have a live stream that has dvb_teletext in it, ffprobe looks like:

Input #0, mpegts, from 'udp://@239.100.200.2:1234':
  Duration: N/A, start: 7822.640600, bitrate: N/A
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 (Main) ([27][0][0][0] / 0x001B),
yuv420p(progressive), 720x480 [SAR 40:33 DAR 20:11], 25 fps, 25 tbr, 90k
tbn, 50 tbc
    Stream #0:1[0x101]: Video: h264 (Main) ([27][0][0][0] / 0x001B),
yuv420p(progressive), 720x480 [SAR 40:33 DAR 20:11], 25 fps, 25 tbr, 90k
tbn, 50 tbc
    Stream #0:2[0x102](cze): Audio: aac (LC) ([15][0][0][0] / 0x000F),
48000 Hz, stereo, fltp, 127 kb/s
    Stream #0:3[0x103](cze): Subtitle: dvb_teletext ([6][0][0][0] /
0x0006), 492x250

I am trying to capture a part of this stream into a mp4 while preserving
dvb_teletext (since I am extracting subtitles from it afterwards) as well
as change the bitrate etc. The command I am using is

ffmpeg -y -fix_sub_duration -i "udp://@239.100.200.2:1234" -map 0 -copyinkf
-codec copy -t 20 -f mp4 output.mp4

which does work but the dvb_subtitles are somehow damaged and not usable,
ffprobe on the output.mp4 file shows

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5634fcc566c0] st: 0 edit list: 2 Missing key
frame while searching for timestamp: 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5634fcc566c0] st: 1 edit list: 2 Missing key
frame while searching for timestamp: 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5634fcc566c0] DTS discontinuity in stream 3:
packet 3 with DTS 7201, packet 4 with DTS 14400
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5634fcc566c0] DTS discontinuity in stream 3:
packet 5 with DTS 14401, packet 6 with DTS 21600
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5634fcc566c0] DTS discontinuity in stream 3:
packet 7 with DTS 21601, packet 8 with DTS 28800
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5634fcc566c0] DTS discontinuity in stream 3:
packet 9 with DTS 28801, packet 10 with DTS 36000
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5634fcc566c0] DTS discontinuity in stream 3:
packet 11 with DTS 36001, packet 12 with DTS 43200
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.12.100
  Duration: 00:00:19.92, start: 0.000000, bitrate: 1639 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p,
720x480 [SAR 40:33 DAR 20:11], 397 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
(default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p,
720x480 [SAR 40:33 DAR 20:11], 999 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:2(cze): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz,
stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
    Stream #0:3(cze): Data: none ([6][0][0][0] / 0x0006), 138 kb/s (default)
    Metadata:
      handler_name    : SubtitleHandler
Unsupported codec with id 0 for input stream 3

The subtitles inside this mp4 file are not usable. What I also tried was to
change the codec of the subtitles to mov_text using

ffmpeg -y -txt_format text -txt_page 888 -fix_sub_duration -i "udp://@
239.100.200.2:1234" -map 0 -copyinkf -scodec mov_text -vcodec copy -acodec
copy -t 10 -f mp4 output.mp4

which does work slighly better. Subtitles are preserverd but their encoding
is not correct. When the subtitles are extracted or the file is played in
VLC, the subtitles are showing badly encoded characters (for example "-Döti
vzkazujÜ, Öe o nö rodiny" instead of "-Děti vzkazují, že ně rodiny")

How can the subtitles be preserved, is there something wrong with the
ffmpeg command?

For the sake of testing, I have recorded a 100 second sample of this stream
using multicat, available to download here https://goo.gl/zGpHRA. The file
seems to containt dvb_subtitles as well, according to ffprobe

Input #0, mpegts, from 'test.ts':
  Duration: 00:01:40.60, start: 19950.480600, bitrate: 2233 kb/s
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 (Main) ([27][0][0][0] / 0x001B),
yuv420p(progressive), 720x480 [SAR 40:33 DAR 20:11], 25 fps, 25 tbr, 90k
tbn, 50 tbc
    Stream #0:1[0x101]: Video: h264 (Main) ([27][0][0][0] / 0x001B),
yuv420p(progressive), 720x480 [SAR 40:33 DAR 20:11], 25 fps, 25 tbr, 90k
tbn, 50 tbc
    Stream #0:2[0x102](cze): Audio: aac (LC) ([15][0][0][0] / 0x000F),
48000 Hz, stereo, fltp, 150 kb/s
    Stream #0:3[0x103](cze): Subtitle: dvb_teletext ([6][0][0][0] /
0x0006), 492x250

You can test mine 2 ffmpeg commands on this sample and you should observe
same issues. Can you please help me figure out what I am doing wrong?

I am using ffmpeg 4.0 configuration: --cpu=native --enable-pthreads
--extra-version=hd --enable-vaapi --enable-vdpau --enable-nonfree
--enable-gpl --enable-swscale --enable-libx264 --enable-version3
--enable-nvenc --enable-libnpp --enable-cuda --enable-cuvid
--enable-cuda-sdk --enable-filter=scale_cuda --enable-filter=thumbnail_cuda
--extra-cflags=-I/usr/local/cuda-9.1/include
--extra-ldflags=-L/usr/local/cuda-9.1/lib64 --enable-libx264
--enable-libx265 --enable-libxvid --enable-libass --enable-libwavpack
--enable-libsoxr --enable-libfdk-aac --enable-libfreetype
--enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis
--enable-libvpx --enable-librtmp --enable-libnpp --enable-opengl
--enable-version3 --enable-avresample --enable-avisynth --enable-openal
--enable-opencl --enable-libzvbi --enable-iconv

with applied patch
http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=a790813739a880a0a86084ec8c4e2d5a6a79c11d

Thank you very much,
Jakub


More information about the ffmpeg-user mailing list