Support for DVB Subtitles (Bitmap based)

Support for HandBrake on Linux, Solaris, and other Unix-like platforms
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Post Reply
lumbermatt
Posts: 3
Joined: Sun Mar 05, 2023 8:59 pm

Support for DVB Subtitles (Bitmap based)

Post by lumbermatt »

Description of problem or question:
I use Handbrake to encode recordings from the DVB-T2 broadcast. When Handbrake re-encodes the video and audio stream, the subtitle track is altered and no longer works. In the documentation it is indicated that Handbrake supports subtitles in bitmap form but does Handbrake support DVB-T Subtitles (as per ETSI EN 300 743) ?

Steps to reproduce the problem (If Applicable):
To record TV (DVB-T2), I use TVHeadend which generates MKV files with the following streams:

Code: Select all

Stream #0:0(eng): Video: h264 (High), yuv420p(tv, bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
Stream #0:1(fre): Audio: eac3, 48000 Hz, stereo, fltp, 128 kb/s (default) [French]
Stream #0:2(qaa): Audio: eac3, 48000 Hz, stereo, fltp, 128 kb/s (default) [Original audio]
Stream #0:3(qaa): Audio: eac3, 48000 Hz, stereo, fltp, 96 kb/s (default) [French - Visual-impaired]
Stream #0:4(fre): Subtitle: dvb_subtitle (default) [French - Hearing impaired]
Stream #0:5(fre): Subtitle: dvb_subtitle (default) [French]
Then in my workflow, I use Loselesscut to remove the commercial breaks and re-export the MKV with the video, the first two audio channels (French and original) and a subtitle track.

Code: Select all

Stream #0:0(eng): Video: h264 (High), yuv420p(tv, bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
Stream #0:1(fre): Audio: eac3, 48000 Hz, stereo, fltp, 128 kb/s (default)
Stream #0:2(qaa): Audio: eac3, 48000 Hz, stereo, fltp, 128 kb/s (default)
Stream #0:3(fre): Subtitle: dvb_subtitle (default)
The resulting file is functional from a subtitle point of view. I tested using the two players I'm sure support dvb subtitles (Kodi and Mplayer): I can turn subtitles on and off and switch between languages.

I re-encode this file (again as an MKV) with Handbrake to reduce the size with the following settings:
- Crop the video from 140px top and bottom to remove the black bands (and at the same time get rid of the the TV channel logo) to 1920x800
- Encoding of the video in h264 with Q=21
- Encoding of the two audio streams with a stereo downmix in AAC
- Integration of the subtitle track as a pass-through

In the output file, the subtitles no longer work: the player offers to display subtitles but nothing is displayed.

By extracting the subtitle tracks (in the form of an MKS file) before and after encoding by Handbrake I notice that the size has been greatly reduced:
- Original file before encoding by HB: 6.1 MB in the subtitle stream
- File after encoding by HB: only 101,2 Kb in the subtitle stream

A possible workaround is to request Handbrake not to integrate the subtitles and to integrate them later by extracting the subtitle stream from the original file and muxing it into the file produced by Handbrake (tested with mkvextract and mkvmerge)

In the activity log, there are a large number of errors concerning the subtitles (for example here by encoding 5 minutes in the middle of the film):

Code: Select all

[23:16:30] encx264: encoding at constant RF 21,000000
[23:16:30] encx264: unparsed options: ref=5:bframes=5:level=4.0:b-adapt=2:direct=auto:deblock=-1,-1:analyse=all:me=umh:merange=24:subme=10:trellis=2:psy-rd=1,0,15:vbv-bufsize=31250:vbv-maxrate=25000:rc-lookahead=60
x264 [info]: using SAR=1/1
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
x264 [info]: profile High, level 4.0, 4:2:0, 8-bit
[23:16:31] sync: first pts audio 0x1 is 0
[23:16:31] sync: first pts audio 0x2 is 0
[23:16:31] sync: first pts video is 450
[23:16:31] sync: first pts subtitle 0x3 is 50850
[23:16:36] sync: subtitle 0x3 duration <= 0, PTS 587250
[b][23:16:48] sync: subtitle 0x3 duration <= 0, PTS 1278450[/b]
[23:16:55] sync: subtitle 0x3 duration <= 0, PTS 1667250
[23:16:59] sync: subtitle 0x3 duration <= 0, PTS 1847250[...]
HandBrake version (e.g., 1.0.0):
20230305065846-4b497cbd0-master (x86_64) compiled from last available source

Operating system and version (e.g., Ubuntu 16.04 LTS, macOS 10.13 High Sierra, Windows 10 Creators Update):
KDE neon 5.27 (based on Ubuntu 22.04 LTS)
User avatar
Ritsuka
HandBrake Team
Posts: 1650
Joined: Fri Jan 12, 2007 11:29 am

Re: Support for DVB Subtitles (Bitmap based)

Post by Ritsuka »

Can you provide a short sample file to reproduce the issue?
Deleted User 11865

Re: Support for DVB Subtitles (Bitmap based)

Post by Deleted User 11865 »

Just posting here to keep track of this thread. A sample of the source would indeed be useful.
lumbermatt
Posts: 3
Joined: Sun Mar 05, 2023 8:59 pm

Re: Support for DVB Subtitles (Bitmap based)

Post by lumbermatt »

I uploaded you a sample file here : https://ufile.io/1zxibujb

As this is video material broadcast on TV and to avoid copyright infringement, the archive is protected by a password which I have sent you separately in a private message.
User avatar
Ritsuka
HandBrake Team
Posts: 1650
Joined: Fri Jan 12, 2007 11:29 am

Re: Support for DVB Subtitles (Bitmap based)

Post by Ritsuka »

I broke it when I tried to fix some SSA subtitles files. Samples with zero duration should be dropped. I'll try to make a fix soon.
lumbermatt
Posts: 3
Joined: Sun Mar 05, 2023 8:59 pm

Re: Support for DVB Subtitles (Bitmap based)

Post by lumbermatt »

Following the commit about the subtitles ('libhb: allows subtitles with zero duration only if the source format is SSA'), I recompiled Handbrake (20230307062323-dbeaa4698-master) and gave it a try and it works flawlessly :D
The subtitle track remains unchanged in the resulting MKV. I extracted it and compared it with the original one, it's identical and the subtitles work with MPlayer .

Many thanks to the developers!
Post Reply