Converting DVB subtitles to WebVTT HLS/DASH¶
Many live streams go with synchronized text that duplicates what people are saying. Usually you can see it in TV channels received from a satellite. There are different ways to transfer these subtitles: as picture or as text.
Most subtitles received from a satellite are included as pictures, and Flussonic identifies such a track as DVB subtitle.
Text subtitles from satellite are identified as DVB teletext. HLS has another format of such subtitles and it is called WebVTT.
Flussonic Media Server can convert DVB subtitles to the WebVTT subtitle format using OCR technology. This is useful for displaying subtitles on devices and players that do not support DVB subtitles.
Note
The subtitle OCR recognition feature is available under a separate license, which must be purchased separately.
To read DVB subtitles, Flussonic uses the Tesseract OCR Engine. Tesseract recognizes the text and passes it to Flussonic, and Flussonic then creates WebVTT subtitles, which can be transmitted via the HLS and DASH protocols.
On this page:
See also:
About DVB subtitles¶
The DVB-SUB standard defines a bitmap-based subtitling format.
In an MPEG-TS source, DVB subtitles can appear in text form or as a stream of pictures. Often, they come in picture form, because the majority of devices do not support the text format.
In an example video stream:
ffprobe stream_sample.ts
Stream #0:0[0x1a4]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:1[0x1ae](fra): Audio: eac3 ([6][0][0][0] / 0x0006), 48000 Hz, stereo, fltp, 128 kb/s
Stream #0:2[0x1af](qad): Audio: eac3 ([6][0][0][0] / 0x0006), 48000 Hz, stereo, fltp, 128 kb/s
Stream #0:3[0x1b8](fra): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006) (hearing impaired)
Stream #0:4[0x1b0](qaa): Audio: eac3 ([6][0][0][0] / 0x0006), 48000 Hz, stereo, fltp, 128 kb/s
Stream #0:5[0x1b9](fra): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
The dvb_subtitle
stream contains subtitles transmitted as images.
Such subtitles are supported by some set-top-boxes, some TV sets, and by the VLC media player, but are not supported by iPhone or Android devices. Flussonic Media Server can convert these picture subtitles back to text to make them displayable on those devices.
About WebVTT subtitles¶
WebVTT (Web Video Text Tracks) is a common subtitle format that is supported by browsers and provides additional formatting options. Recognizing DVB subtitles and converting them to WebVTT helps reduce the load on the transmission channel.
WebVTT files are regular text files with the extension .vtt
. They consist of a sequence of text segments associated with time intervals, called cues.
Here is an example WebVTT file:
WEBVTT
00:01.000 --> 00:04.000
Never drink liquid nitrogen.
00:05.000 --> 00:09.000
— It will perforate your stomach.
— You could die.
It is possible to connect several WebVTT files to a video container to provide multiple sets of captions. This can be used to provide subtitles in different languages. Captions for different languages must be stored in separate files.
These files can also be used to transfer additional, non-subtitle data to JS players. For example, URL preview images for video frames. The WebVTT standard also supports styling the subtitles with CSS and changing their position, size, and alignment.
Installation and setup¶
Tesseract is a high-quality open-source CLI-based OCR engine. The software outputs text in UTF-8 format, and can recognize text from over 130 languages.
To set up DVB subtitle conversion:
-
Install Tesseract.
On Ubuntu, the flussonic-tesseract package is available:
apt install flussonic-tesseract
2. To enable DVB sustitles conversion, add the following line to the stream settings in/etc/flussonic/flussonic.conf
:subtitles=ocr_replace;
The option
subtitles=ocr_replace
turns on the DVB subtitle OCR feature. The resulting track with text subtitles replaces the track with DVB subtitles in an output stream.For example:
stream tvchannel { input tshttp://SOURCE:80/STREAM subtitles=ocr_replace; }
If you need both tracks – the one with DVB subtitles and the other with text subtitles, use the option
subtitles=ocr_add
. It adds a new track containing resulting subtitles in the text format to an output stream:stream tvchannel { input tshttp://SOURCE:80/STREAM subtitles=ocr_add; }
-
Apply the settings by running this command in the console:
service flussonic reload
If Tesseract has started successfully, the following lines will appear in the logs:
09:44:17.986 <0.966.0> [sow] tesseract_worker:58 start ocr for slv
09:44:18.275 <0.966.0> [sow] tesseract_worker:58 start ocr for srp
09:44:18.759 <0.966.0> [sow] tesseract_worker:58 start ocr for swe
09:44:19.045 <0.966.0> [sow] tesseract_worker:58 start ocr for dan
09:44:19.328 <0.966.0> [sow] tesseract_worker:58 start ocr for nor
An example of an HLS playlist index.m3u8 with subtitles:
#EXTM3U
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="English",DEFAULT=YES,AUTOSELECT=YES,FORCED=NO,LANGUAGE="eng",URI="http://flussonic-ip/index.m3u8"
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="French",DEFAULT=NO,AUTOSELECT=YES,FORCED=NO,LANGUAGE="fra",URI="http://flussonic-ip/index.m3u8"
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="German",DEFAULT=NO,AUTOSELECT=YES,FORCED=NO,LANGUAGE="deu",URI="http://flussonic-ip/index.m3u8"
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=450560,RESOLUTION=480x352,SUBTITLES="subs"
http://flussonic-ip/index.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=855040,RESOLUTION=480x352,SUBTITLES="subs"
http://flussonic-ip/index.m3u8
After the conversion, an output stream has WebVTT subtitles:
Passing teletext and closed captions¶
Flussonic can pass teletext and closed captions from MPEG-TS. For the output HLS, they will be converted to WebVTT, and for DASH, to TTML. See Teletext and Closed Captions