[FFmpeg-devel] DVB Subtitles

JULIAN GARDNER joolzg at btinternet.com
Tue Jun 17 09:19:47 CEST 2014


test stream http://joolzg.myetrayz.net:8080/rapidbox/rapidFileDownload.php?r_id=72b32a1f754ba1c09b3695e0cb6cde7f

Ive been watching all the discussions lately regarding Dvb Subtitles and decided to look again at this.

I have removed 3 lines of code from ffmpeg.c and it now works as it should with one caveat that the "clear timeout" is not used at all.

Now this test stream shows subtitles at around 10, 15, 20, 23, 26, 31, 34 and 39 seconds with removal at 45 seconds, this last one being the one we are really need to look at. as there are no more and we need to the subtitles to be removed from the screen when the stream asks for it and not by some pre-determinated timeout.

Here is my output, with extra debug
encoder at encoder:~/ffmpeg$ ./ffmpeg -i /home/encoder/testStreams/ScreenHD60sec_ENG.ts -c:v libx264 -c:a libfaac -c:s dvbsub -y -f mpegts a.ts
ffmpeg version N-63057-g63504d8 Copyright (c) 2000-2014 the FFmpeg developers
  built on May  9 2014 21:38:23 with gcc 4.6 (Ubuntu/Linaro 4.6.4-1ubuntu1~12.04)
  configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libzvbi --cc='ccache cc'
  libavutil      52. 82.100 / 52. 82.100
  libavcodec     55. 60.103 / 55. 60.103
  libavformat    55. 37.102 / 55. 37.102
  libavdevice    55. 13.101 / 55. 13.101
  libavfilter     4.  5.100 /  4.  5.100
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
[dvbsub @ 0x1b666a0] composition_page_id 0002, ancillary_page_id 0002
[NULL @ 0x1b666a0] start time for stream 2 is not set in estimate_timings_from_pts
Input #0, mpegts, from '/home/encoder/testStreams/ScreenHD60sec_ENG.ts':
  Duration: 00:00:59.95, start: 0.727133, bitrate: 11317 kb/s
  Program 1 
    Stream #0:0[0x40](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 224 kb/s
    Stream #0:1[0x66](eng): Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv), 1920x1080 [SAR 1:1 DAR 16:9], max. 10000 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:2[0x400](eng): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
SUBTITLE extradata being set
[libx264 @ 0x1b67e00] using SAR=1/1
[libx264 @ 0x1b67e00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
[libx264 @ 0x1b67e00] profile High, level 4.0
[dvbsub @ 0x1b83820] dvbsub_init_encode 0x1b64fa0 4
[dvbsub @ 0x1b83820] composition_page_id 0001, ancillary_page_id 0001
[dvbsub @ 0x1b666a0] composition_page_id 0002, ancillary_page_id 0002
Output #0, mpegts, to 'a.ts':
  Metadata:
    encoder         : Lavf55.37.102
    Stream #0:0(eng): Video: h264 (libx264), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 90k tbn, 25 tbc
    Stream #0:1(eng): Audio: aac (libfaac), 48000 Hz, stereo, s16, 128 kb/s
    Stream #0:2(eng): Subtitle: dvb_subtitle (dvbsub)
Stream mapping:
  Stream #0:1 -> #0:0 (mpeg2video -> libx264)
  Stream #0:0 -> #0:1 (mp2 -> libfaac)
  Stream #0:2 -> #0:2 (dvbsub -> dvbsub)
Press [q] to stop, [?] for help
[dvbsub @ 0x1b666a0] DVBsubs 900000 900000 - 22986 31 1                   kbits/s    
[dvbsub @ 0x1b666a0]   sub 2               
Encode subs 23110
[dvbsub @ 0x1b666a0] DVBsubs 1303200 1303200 - 28 17 1                   7kbits/s    
[dvbsub @ 0x1b666a0]   sub 0               
Encode subs 14
[dvbsub @ 0x1b666a0] DVBsubs 1314000 1314000 - 23216 31 1                   its/s    
[dvbsub @ 0x1b666a0]   sub 2               
Encode subs 23412
[dvbsub @ 0x1b666a0] DVBsubs 1717200 1717200 - 28 17 1                   6kbits/s    
[dvbsub @ 0x1b666a0]   sub 0               
Encode subs 14
[dvbsub @ 0x1b666a0] DVBsubs 1728000 1728000 - 22726 31 1                   its/s    
[dvbsub @ 0x1b666a0]   sub 2               
Encode subs 23032
[dvbsub @ 0x1b666a0] DVBsubs 2041200 2041200 - 28 17 1                   7kbits/s    
[dvbsub @ 0x1b666a0]   sub 0               
Encode subs 14
[dvbsub @ 0x1b666a0] DVBsubs 2052000 2052000 - 17586 31 1                   its/s    
[dvbsub @ 0x1b666a0]   sub 2               
Encode subs 18169
[dvbsub @ 0x1b666a0] DVBsubs 2365200 2365200 - 28 17 1                   1kbits/s    
[dvbsub @ 0x1b666a0]   sub 0               
Encode subs 14
[dvbsub @ 0x1b666a0] DVBsubs 2376000 2376000 - 17282 31 1                   its/s    
[dvbsub @ 0x1b666a0]   sub 2               
Encode subs 17760
[dvbsub @ 0x1b666a0] DVBsubs 2736000 2736000 - 28 17 1                   9kbits/s    
[dvbsub @ 0x1b666a0]   sub 0               
Encode subs 14
[dvbsub @ 0x1b666a0] DVBsubs 2746800 2746800 - 13470 31 1                   its/s    
[dvbsub @ 0x1b666a0]   sub 1               
Encode subs 13267
[dvbsub @ 0x1b666a0] DVBsubs 2970000 2970000 - 28 17 1                   7kbits/s    
[dvbsub @ 0x1b666a0]   sub 0               
Encode subs 14
[dvbsub @ 0x1b666a0] DVBsubs 2980800 2980800 - 19572 31 1                   its/s    
[dvbsub @ 0x1b666a0]   sub 2               
Encode subs 19953
[dvbsub @ 0x1b666a0] DVBsubs 3474000 3474000 - 28 17 1                   6kbits/s    
[dvbsub @ 0x1b666a0]   sub 0               
Encode subs 14
[dvbsub @ 0x1b666a0] DVBsubs 3484800 3484800 - 23468 31 1                   its/s    
[dvbsub @ 0x1b666a0]   sub 2               
Encode subs 23322
[dvbsub @ 0x1b666a0] DVBsubs 4024800 4024800 - 28 17 1                   3kbits/s    
[dvbsub @ 0x1b666a0]   sub 0               
Encode subs 14
frame= 1500 fps= 25 q=-1.0 Lsize=   61263kB time=00:00:59.98 bitrate=8366.0kbits/s    
video:56449kB audio:44kB subtitle:158kB other streams:0kB global headers:0kB muxing overhead: 8.140836%
[libx264 @ 0x1b67e00] frame I:10    Avg QP:17.30  size:186767
[libx264 @ 0x1b67e00] frame P:598   Avg QP:22.51  size: 76471
[libx264 @ 0x1b67e00] frame B:892   Avg QP:24.59  size: 11442
[libx264 @ 0x1b67e00] consecutive B-frames:  7.9% 33.9% 14.0% 44.3%
[libx264 @ 0x1b67e00] mb I  I16..4: 20.8% 77.8%  1.3%
[libx264 @ 0x1b67e00] mb P  I16..4:  1.0%  7.9%  0.5%  P16..4: 34.7% 17.8% 12.1%  0.0%  0.0%    skip:26.0%
[libx264 @ 0x1b67e00] mb B  I16..4:  0.1%  0.2%  0.0%  B16..8: 31.8%  2.6%  0.6%  direct: 1.7%  skip:63.0%  L0:39.2% L1:44.1% BI:16.7%
[libx264 @ 0x1b67e00] 8x8 transform intra:82.4% inter:81.4%
[libx264 @ 0x1b67e00] coded y,uvDC,uvAC intra: 74.5% 75.0% 18.9% inter: 22.2% 14.8% 0.6%
[libx264 @ 0x1b67e00] i16 v,h,dc,p: 44% 31% 18%  6%
[libx264 @ 0x1b67e00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 24% 31%  4%  4%  4%  4%  4%  7%
[libx264 @ 0x1b67e00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 21% 14%  6%  8%  8%  8%  7%  8%
[libx264 @ 0x1b67e00] i8c dc,h,v,p: 49% 25% 19%  7%
[libx264 @ 0x1b67e00] Weighted P-Frames: Y:4.0% UV:2.8%
[libx264 @ 0x1b67e00] ref P L0: 66.8% 16.5% 12.1%  4.5%  0.1%
[libx264 @ 0x1b67e00] ref B L0: 86.2% 13.0%  0.8%
[libx264 @ 0x1b67e00] ref B L1: 96.3%  3.7%
[libx264 @ 0x1b67e00] kb/s:7707.20

As you can see there are some "sub 0" which are the clearing packets, these ones WERE being ignored and this is why the ffmpeg.c had the "nb = 2" hack.

So i have 3 different test encodes, from a file

1. encode video/audio and copy dvbsubtitles
2. encode video/audio/subtitles
3. encode video/audio and overlay dvbsubtitles

All 3 of these work as they should and the subtitles appear and disappear at the correct times.

BUT What is needed now is to fix the muxer, if a live stream is transcoded with dvb subtitles, ffmpeg creates a burst of data and then zero data until next subtitle arrives, this means it is unusable at the moment.

Now a question for the list.

If we take a HD stream, 1280x720 and have subtitles which are based on 720x576, what should we do if we have resized the video to 640x360, should we remap the subtitles to be in the same place or just leave them as is?

joolz


More information about the ffmpeg-devel mailing list