This is an old revision of the document!
Table of Contents
DVD Subtitles
Detect VobSub
The MPG will need to be probed deeper than normal to check for VobSub streams because they only are detected once they show up in the video.
An example:
ffprobe -probesize 67108864 -analyzeduration 60000000 dvd_video.mpg
Input #0, mpeg, from '1.665.2138.17690.TNTGO.mpg': Duration: 00:11:09.02, start: 0.045500, bitrate: 5708 kb/s Stream #0:0[0x1bf]: Data: dvd_nav_packet Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, progressive), 720x480 [SAR 32:27 DAR 16:9], 29.92 fps, 59.94 tbr, 90k tbn, 59.94 tbc Stream #0:2[0x82]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s Stream #0:3[0x81]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s Stream #0:4[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s Stream #0:5[0x21]: Subtitle: dvd_subtitle Stream #0:6[0x20]: Subtitle: dvd_subtitle Stream #0:7[0x23]: Subtitle: dvd_subtitle Stream #0:8[0x22]: Subtitle: dvd_subtitle
For a DVD directly:
dvd_copy -o - | ffprobe -probesize 67108864 -analyzeduration 60000000 -
Detect CC
For DVDs, closed captioning streams are embedded in the video stream.
The fastest way is to see if it has closed captioning is using ffprobe and looking for Closed Captions
in the output:
ffprobe dvd_copy.mpg
Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, top first), 720x480 [SAR 32:27 DAR 16:9], Closed Captions, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
Use ffprobe's INI style output to look for it as well:
ffprobe -v 0 -show_streams -show_entries stream=start_pts -select_streams s -f lavfi -i movie=dvd_copy.mpg[out+subcc]
See if a DVD has closed captioning:
dvd_copy -o - | ffprobe -v 0 -show_streams -show_entries stream=start_pts -select_streams s -f lavfi -i movie=pipe\\\\:0[out+subcc]
When splitting the streams using lavfi
device, ffmpeg will “create” a subtitle stream, even if one is not present. To make sure one exists or not, a closer look at the stream itself is actually needed.
This one has a starting presentation timestamp (PTS) that's a positive value, so it's safe to say that one exists.
[STREAM] start_pts=25257 DISPOSITION:default=0 DISPOSITION:dub=0 DISPOSITION:original=0 DISPOSITION:comment=0 DISPOSITION:lyrics=0 DISPOSITION:karaoke=0 DISPOSITION:forced=0 DISPOSITION:hearing_impaired=0 DISPOSITION:visual_impaired=0 DISPOSITION:clean_effects=0 DISPOSITION:attached_pic=0 DISPOSITION:timed_thumbnails=0 [/STREAM]
Here's one without it present:
[STREAM] start_pts=N/A DISPOSITION:default=0 DISPOSITION:dub=0 DISPOSITION:original=0 DISPOSITION:comment=0 DISPOSITION:lyrics=0 DISPOSITION:karaoke=0 DISPOSITION:forced=0 DISPOSITION:hearing_impaired=0 DISPOSITION:visual_impaired=0 DISPOSITION:clean_effects=0 DISPOSITION:attached_pic=0 DISPOSITION:timed_thumbnails=0 [/STREAM]
Extract CC
Use ffmpeg to extract the closed captioning stream from a DVD using dvd_copy:
dvd_copy -o - | ffmpeg -f lavfi -i movie=pipe\\\\:0[out+subcc] -map 0:s subtitles.srt
Extract CC subtitles from an MPG:
dvd_copy -o dvd_copy.mpg ffmpeg -f lavfi -i move=dvd_copy.mpg[out+subcc] -map 0:s subtitles.srt
Since the closed captioning is embedded in the video stream, you can re-encode that at the same time. It won't see any other streams though (audio, vobsub).
ffmpeg -f lavfi -i move=dvd_copy.mpg[out+subcc] -map 0:v -map 0:s video.mkv