[Cin] Adding soft subtitles to a DVD video

Terje J. Hanssen terjejhanssen at gmail.com
Thu Feb 15 21:01:56 CET 2024



Den 13.02.2024 18:02, skrev Terje J. Hanssen:
>
>
> Den 13.02.2024 16:49, skrev Terje J. Hanssen:
>>
>>
>> Den 13.02.2024 14:31, skrev Terje J. Hanssen:
>>>
>>>
>>> Den 13.02.2024 03:26, skrev Andrew Randrianasulu:
>>>>
>>>>
>>>> вт, 13 февр. 2024 г., 05:20 Andrew Randrianasulu 
>>>> <randrianasulu at gmail.com>:
>>>>
>>>>
>>>>
>>>>     вт, 13 февр. 2024 г., 03:42 Terje J. Hanssen
>>>>     <terjejhanssen at gmail.com>:
>>>>
>>>>
>>>>
>>>>         Den 12.02.2024 00:07, skrev Andrew Randrianasulu:
>>>>>
>>>>>
>>>>>         пн, 12 февр. 2024 г., 02:02 Terje J. Hanssen
>>>>>         <terjejhanssen at gmail.com>:
>>>>>
>>>>>
>>>>>
>>>>>             Den 11.02.2024 04:36, skrev Terje J. Hanssen:
>>>>>>
>>>>>>
>>>>>>             Den 11.02.2024 00:57, skrev Andrew Randrianasulu:
>>>>>>>
>>>>>>>
>>>>>>>             сб, 10 февр. 2024 г., 21:10 Terje J. Hanssen via Cin
>>>>>>>             <cin at lists.cinelerra-gg.org>:
>>>>>>>
>>>>>>>                 There are two things I want to add to my current
>>>>>>>                 intermediate DVD mpg video files created with
>>>>>>>                 ffmpeg, and/or to the DVD tree structure created
>>>>>>>                 with DeVeDeNG:
>>>>>>>
>>>>>>>                     1. Create and add a Navigation menu in the
>>>>>>>                     beginning
>>>>>>>                     This will be an upcoming, separate topic
>>>>>>>
>>>>>>>                     2. Create and add Soft Subtitles as simple
>>>>>>>                     text info commentaries to the video content
>>>>>>>                     This is the topic for this post.
>>>>>>>
>>>>>>>
>>>>>>>                 The reason that I want *Soft* Subtitles as a
>>>>>>>                 separate text file stream related to timing, is
>>>>>>>                 because this should be possible to *add* or
>>>>>>>                 import to an existing video file  without the
>>>>>>>                 need to re-encode. It should also be flexible to
>>>>>>>                 display on or off during playback, if I have
>>>>>>>                 understood this correct so far.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>             IIRC you can't add text-based subtitles to DVD
>>>>>>>             video. Blu-ray yes, dvd no (both can use palletized
>>>>>>>             reduced-color graphical subtitles) ... so at least
>>>>>>>             rendering text as palletized picture and then muxing
>>>>>>>             it into mpeg stream is unavoidable step,as far as I
>>>>>>>             understand.
>>>>>>
>>>>>>             I have prepared a new video file and will try to add
>>>>>>             sub-titles to-morrow
>>>>>>             http://www.g-raffa.eu/Cinelerra/HOWTO/subtitles.html#_how_to_create_soft_subtitles
>>>>>>
>>>>>>
>>>>>
>>>>>             There are written several articles and answers to
>>>>>             forum topics about adding soft subtitles to video.
>>>>>             My best but only partly working attempt so far, is by
>>>>>             applying this solution on StackOverflow:
>>>>>
>>>>>             /Use ffmpeg to add text subtitles: NOTE: This solution
>>>>>             adds the subtitles to the video as a separate optional
>>>>>             (and user-controlled) subtitle track.
>>>>>             https://stackoverflow.com/questions/8672809/use-ffmpeg-to-add-text-subtitles
>>>>>
>>>>>             /1) First I created a DVD-video compliant MPG file
>>>>>             with pcm audio from DV source (as previously)
>>>>>
>>>>>             ffmpeg -hide_banner -i DV09-1993.dv -f dvd -target
>>>>>             pal-dvd -aspect 4:3 -b:v 8M -maxrate 8M -minrate 8M
>>>>>             -bufsize 20M -muxrate 20M -mbd rd -trellis 1 -cmp 0
>>>>>             -subcmp 2 -c:a pcm_dvd DV09-1993.mpg
>>>>>
>>>>>
>>>>>             2) Created the attached srt subtitle file:
>>>>>
>>>>>                 DVD-09-1993_subtitle.srt
>>>>>
>>>>>
>>>>>
>>>>>             3) Added (muxed) the soft, external subtitle file (2)
>>>>>             as a separate track to the mpg video file (1)
>>>>>
>>>>>             ffmpeg -hide_banner -i DV09-1993.mpg -i
>>>>>             DVD-09-1993_subtitle.srt -c:v copy -c:a copy -c:s copy
>>>>>             DV09-1993+srt.mpg
>>>>>
>>>>>                 [mpeg @ 0x55aac13139c0] start time for stream 0 is
>>>>>                 not set in estimate_timings_from_pts
>>>>>                 Input #0, mpeg, from 'DV09-1993.mpg':
>>>>>                   Duration: 00:28:04.44, start: 0.540000, bitrate:
>>>>>                 9701 kb/s
>>>>>                   Stream #0:0[0x1bf]: Data: dvd_nav_packet
>>>>>                   Stream #0:1[0x1e0]: Video: mpeg2video (Main),
>>>>>                 yuv420p(tv, progressive), 720x576 [SAR 16:15 DAR
>>>>>                 4:3], 25 fps, 25 tbr, 90k tbn
>>>>>                     Side data:
>>>>>                       cpb: bitrate max/min/avg: 9000000/0/0 buffer
>>>>>                 size: 1835008 vbv_delay: N/A
>>>>>                   Stream #0:2[0xa0]: Audio: pcm_dvd, 48000 Hz,
>>>>>                 stereo, s16, 1536 kb/s
>>>>>                 Input #1, srt, from 'DVD-09-1993_subtitle.srt':
>>>>>                   Duration: N/A, bitrate: N/A
>>>>>                   Stream #1:0: Subtitle: subrip
>>>>>
>>>>>                 [mpeg @ 0x55aac134b140] pcm_dvd in MPEG-1 system
>>>>>                 streams is not widely supported, consider using
>>>>>                 the vob or the dvd muxer to force a MPEG-2 program
>>>>>                 stream.
>>>>>                 Output #0, mpeg, to 'DV09-1993+srt.mpg':
>>>>>                   Metadata:
>>>>>                     encoder         : Lavf60.16.100
>>>>>                   Stream #0:0: Video: mpeg2video (Main),
>>>>>                 yuv420p(tv, progressive), 720x576 [SAR 16:15 DAR
>>>>>                 4:3], q=2-31, 25 fps, 25 tbr, 90k tbn
>>>>>                     Side data:
>>>>>                       cpb: bitrate max/min/avg: 9000000/0/0 buffer
>>>>>                 size: 1835008 vbv_delay: N/A
>>>>>                   Stream #0:1: Audio: pcm_dvd, 48000 Hz, stereo,
>>>>>                 s16, 1536 kb/s
>>>>>                   Stream #0:2: Subtitle: subrip
>>>>>                 Stream mapping:
>>>>>                   Stream #0:1 -> #0:0 (copy)
>>>>>                   Stream #0:2 -> #0:1 (copy)
>>>>>                   Stream #1:0 -> #0:2 (copy)
>>>>>                 Press [q] to stop, [?] for help
>>>>>                 [out#0/mpeg @ 0x55aac134af80] video:1644910kB
>>>>>                 audio:316303kB subtitle:0kB other streams:0kB
>>>>>                 global headers:0kB muxing overhead: 0.561824%
>>>>>                 size= 1972232kB time=00:28:04.44
>>>>>                 bitrate=9591.6kbits/s speed= 378x
>>>>>
>>>>>
>>>>>             4) Successful Playback of the final video and Audio
>>>>>             with subtitles using a "reinforced" FFplay command -
>>>>>             also found on StackOverflow
>>>>>             https://stackoverflow.com/questions/50175075/can-ffplay-view-subtitles
>>>>>
>>>>>             ffplay -hide_banner -vf
>>>>>             subtitles=DVD-09-1993_subtitle.srt DV09-1993+srt.mpg
>>>>>
>>>>>
>>>>>         isn't this command just uses external srt and not muxed one?
>>>>
>>>>         Yes, I think you'r right, and I wondered a bit about it,
>>>>         but had no keyboard shortcut for ffplay to test switching
>>>>         subtitles on and off.
>>>>
>>>>         So, afterwards I was more convinced - and fooled, when both
>>>>         Gnome Media player (Totem) and SMplayer automatically
>>>>         displayed the subtitles.
>>>>         But that was when the srt subtitle file had the same name
>>>>         as the mpg video file and was located in the same
>>>>         directory. But this worked as well with the first mpg file (1).
>>>>
>>>>         The command line "vlc dvd.mpg dvd.srt" also worked with
>>>>         audio. Why both VLC and MPlayer lost the audio with the srt
>>>>         muxed mpg file I have no idea about.
>>>>         -----------------------------
>>>>
>>>>         From your first reply:
>>>>
>>>>             rendering text as palletized picture and then muxing it
>>>>             into mpeg stream is unavoidable step,as far as I
>>>>             understand.
>>>>             But may be those DVD creation guis can do srt =>
>>>>             dvd_sub conversion for you ?
>>>>
>>>>
>>>>         Andrey mentioned the "srt2vobsub" program,  which seems to
>>>>         the same as the "srt2vob" script for DVD and "2dsub" for BD
>>>>         vobsub
>>>>         https://web.archive.org/web/20130728210155/https://code.google.com/p/srt2vob
>>>>
>>>>
>>>>         And from my reference to g-raffa:
>>>>
>>>>             PRE-RENDERED SUBTITLES
>>>>                 they are added (muxed) to the video stream as
>>>>             images with minimal information but can be separated
>>>>             (demuxed) when needed. They are used in DVDs        
>>>>             and they can be turned on and off.
>>>>                 Most DVD authoring applications are capable of
>>>>             transcoding external subtitles to pre-rendered
>>>>             subtitles and of muxing them to the video stream.
>>>>
>>>>
>>>>         Regarding the last sentece, this article describes the
>>>>         wanted solution - but on Linux ...?
>>>>         https://robots.net/tech/how-to-burn-dvd-with-subtitles-srt/
>>>>
>>>>         while another article points on Handbrake as the best
>>>>         solution for  most users (?)
>>>>         https://helpdeskgeek.com/how-to/how-to-burn-a-dvd-disc-with-subtitles/
>>>>
>>>>
>>>>         Re 8) above
>>>>         I also send a request to Raster soft why DeVeDeNG exits
>>>>         with an error before finishing the mpg video file and
>>>>         creating the iso.
>>>>
>>>>
>>>>     may be this tip from 2015 will help with devede-ng too?
>>>>
>>>>     https://momentstuff.wordpress.com/2015/10/29/subtitles-with-devede/
>>>>
>>>>
>>>>
>>>> also be aware about non-utf8 subtitles with this method (possibly 
>>>> rare nowadays but still). devede-ng should have dropdown menu for 
>>>> selecting it.
>>>>
>>>> https://groups.google.com/g/devede-forum/c/2Thoie_DSXQ
>>>>
>>>
>>> Now I have tried both ASII, UTF-8 and ISO-8859-1 encodings, but 
>>> still DevedeNG exists with error, also already when trying the 
>>> Preview button.
>>> DevedeNG 4.17 has a newer gui and I cannot see there is any Advanced 
>>> button for Mencoder.
>>> I also tried to add a pure dv clip and a srt subtitle file in 
>>> Devede, and got the error again.
>>>
>>>
>>
>> Checking the character set of my srt subtitle file:
>>
>>     file -bi dvd.srt
>>     text/plain; charset=us-ascii
>>
>> Looks like I am not able to change the charset to utf-8
>>
>>     iconv -f ascii -t utf-8 -o dvd_utf-8.srt dvd.srt
>>
>>     file -bi dvd_utf-8.srt
>>     text/plain; charset=us-ascii
>>
>> https://www.shellhacks.com/linux-check-change-file-encoding/
>>
>>
> Posted also on the DevedeNG forum
> https://groups.google.com/g/devede-forum/c/jpReMzCF2B0
>

While waiting hopefully on a possible DevedeNG softsub fix, I have had 
progress with successful hardsub instead.
That is making the soft subtitle.srt file hard coded into the video 
using the subtitle filter, in one single encoding step from DV to MPG.

Sample clip and code line as follows:

ffmpeg -hide_banner -i dv01_07.dv -vf  subtitles=dvd.srt -f dvd -target 
pal-dvd -aspect 4:3 -b:v 8M -maxrate 8M -minrate 8M -bufsize 20M 
-muxrate 20M -mbd rd -trellis 1 -cmp 0 -subcmp 2 -c:a pcm_dvd dvd0hsub.mpg

This dvd compliant mpg playback fine with fixed and crisp text fonts 
tested on the relevant previous listed players.

DevedeNG imports this mpg file and creates the DVD tree and iso. Then 
burned to DVD disc, this playback fine with my BD player.
(My DVD player which is in bad condition, is stuttering but show the 
video and subtitles)

References urls to the FFmpeg wiki, and similar to g-raffa (using Avidemux):
https://trac.ffmpeg.org/wiki/HowToBurnSubtitlesIntoVideo
http://www.g-raffa.eu/Cinelerra/HOWTO/subtitles.html#_ho_to_make_soft_subtitles_hard

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cinelerra-gg.org/pipermail/cin/attachments/20240215/da64db45/attachment-0001.htm>


More information about the Cin mailing list