How to go from .srt subtitles and a .ts video to a .ts video with dvb_subtitles?

Viewed 1603

I'm trying to get from a .srt subtitle file + a .ts video file => a .ts video file with a dvb_subtitle.

My .srt:

1
00:00:00,000 --> 00:00:05,000
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vel hendrerit massa.

2
00:00:05,000 --> 00:00:10,000
Aliquam dolor sapien, molestie ac sagittis eu, tempus nec est.

3
00:00:10,000 --> 00:00:28,000
Morbi id sem eu sapien consectetur imperdiet. Morbi sed purus et sapien interdum placerat vitae quis orci.

My .ts: sample_1920x1080.ts from https://filesamples.com/formats/ts

SubtitleEdit command: .\SubtitleEdit.exe /convert 'test_subtitles.srt' Blu-raysup /resolution:1920x1080 /overwrite. This creates a test_subtitles.sup file as expected.

I then use ffmpeg to include the .sup subtitles, like this: .\ffmpeg.exe -y -i 'sample_1920x1080.ts' -fix_sub_duration -i 'test_subtitles.sup' -map 0:v -map 1:s -vcodec copy -acodec copy -scodec dvbsub -copyts -muxdelay 0 -max_delay 0 'output.ts'. This works, but the results are sometimes not very readable. Here's a screenshot:

Screenshot of VLC showing that the subtitles are hard to read

Do I have any other options here? Or options within subtitleedit/ffmpeg to f.ex. make the subtitles be bigger?

(I've posted this to the SubtitleEdit Github repository as well: https://github.com/SubtitleEdit/subtitleedit/issues/4539.)

UPDATE:

I learned from the author of SubtitleEdit that it's indeed possible to increase the font size if using the graphical user interface of SubtitleEdit (see here. However, I wish to do this using a command line tool.

2 Answers

EDIT 19.12.2020:

The idea from my last comment - a Python script that replaces the font size in Settings.xml of SubtitleEdit, to be called before your scripts:

https://github.com/Twenkid/Python-Various/blob/main/Exercise/SubtitleEdit/sub.py

python sub.py C:\SE3518\Settings.xml 44

etc.

...

Have you tried to scale the dvb track? That thread suggests it is possible: ffmpeg and dvb subtitles scaling

That part by Maknol (I haven't tried it though):

-filter_complex "[0:s:0] scale=-1:2400 [sub],[0:v][sub] overlay=x=150:y=-80"

where:

scale - size of subtitle

overlay x= - vertical

overlay y= - horizontal

EDIT: I managed to scale the .sup subtitles with ffmpeg, but so far it worked in two passes, see below.

My sequence was:

  1. Your command, producing a stream with the subtitles:

ffmpeg -i sample_1920x1080.ts -fix_sub_duration -i test_subtitles.sup -map 0:v -map 1:s -vcodec copy -acodec copy -scodec dvbsub -copyts -muxdelay 0 -max_delay 0 outputA.ts

  1. Scale the subtitles and adjust their position (however it requires reencoding due to the filter_complex)

ffmpeg -i outputA.ts -metadata title="Scale" -filter_complex "[0:s:0] scale=-1:1400 [sub],[0:v][sub] overlay=x=-250:y=-300" -c:v libx264 -b:v 5M -preset fast -aspect 16:9 -c:a copy output_Scaled.ts

Initial size:

enter image description here

My initial subtitles were bigger (font size 25) and the scaling coefficient here is small = 1400/1080

Scaled:

enter image description here

...

If I tried to do it in one pass, my syntax rendered the default size + overlayed the scaled ones (and displays only one item, not all).

That's the attempt for one pass:

#At once overlays them ... ffmpeg -i sample_1920x1080.ts -fix_sub_duration -i test_subtitles.sup -scodec dvbsub -map 0:v -map 1:s -metadata title="Scale" -filter_complex "[1:s] scale=-1:1400 [sub],[0:v][sub] overlay=x=-250:y=-300" -c:v libx264 -crf 20 -preset veryfast -aspect 16:9 -c:a aac -strict experimental -b:a 192k outputSTACK_SUP.ts

It produces something like that:

enter image description here

Unfortunately, it had to be done with ffmpeg like this:

ffmpeg -i ./sample_1280x720.ts -i ./sample.srt -map 0 -map 1 -c copy -c:s dvd_subtitle ./out.ts

but ffmpeg wont accept it with this error:

Subtitle encoding currently only possible from text to text or bitmap to bitmap

.srt format is text based and .sup format is image based.

so as long as ffmpeg refuses to encode subtitle into video.

we can using -vf (video filter), Hardcoding (srt) subtitle into video:

ffmpeg -i ./sample_1280x720.ts -vf subtitles=sample.srt:force_style='Fontsize=24' ./out.ts

We Can define font size with Fontsize option.

enter image description here

but if have the sup and want to burn into video, you may use this:

ffmpeg -i ./sample_1280x720.ts -i ./sample.sup  -filter_complex "[0:v][1:s]overlay" ./out.ts
Related