Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
subtitles [2019/06/29 10:03] – beandog | subtitles [2020/10/27 00:49] (current) – [Detect CC] beandog | ||
---|---|---|---|
Line 3: | Line 3: | ||
* [[ffmpeg]] | * [[ffmpeg]] | ||
+ | ** WARNING: ** ffmpeg automatically muxes the closed captioning in **with libx264** if it exists, and will not show up in the map output, meaning it cannot be disabled. Also, '' | ||
==== Detect VobSub ==== | ==== Detect VobSub ==== | ||
Line 36: | Line 37: | ||
For DVDs, closed captioning streams are embedded in the video stream. | For DVDs, closed captioning streams are embedded in the video stream. | ||
+ | |||
+ | By default, ffmpeg will copy the Closed Captions. Even passing '' | ||
The fastest way is to see if it has closed captioning is using ffprobe and looking for '' | The fastest way is to see if it has closed captioning is using ffprobe and looking for '' | ||
Line 100: | Line 103: | ||
[/STREAM] | [/STREAM] | ||
</ | </ | ||
- | |||
==== Extract CC ==== | ==== Extract CC ==== | ||
Line 114: | Line 116: | ||
< | < | ||
dvd_copy -o dvd_copy.mpg | dvd_copy -o dvd_copy.mpg | ||
- | ffmpeg -f lavfi -i move=dvd_copy.mpg[out+subcc] -map 0:s subtitles.srt | + | ffmpeg -f lavfi -i movie=dvd_copy.mpg[out+subcc] -map 0:s subtitles.srt |
</ | </ | ||
Line 120: | Line 122: | ||
< | < | ||
- | ffmpeg -f lavfi -i move=dvd_copy.mpg[out+subcc] -map 0:v -map 0:s video.mkv | + | ffmpeg -f lavfi -i movie=dvd_copy.mpg[out+subcc] -map 0:v -map 0:s video.mkv |
+ | </ | ||
+ | |||
+ | ==== Encode with existing Closed Captioning ==== | ||
+ | |||
+ | Since ffmpeg can input from two sources at once, you can input the same source twice, encode the audio and video from one, split the closed captioning data from the other, and mux them into one file all at once. | ||
+ | |||
+ | This will work **on a file but not with piped input** | ||
+ | |||
+ | < | ||
+ | ffmpeg -i dvd_copy.mpg -f lavfi -i movie=dvd_copy.mpg[out+subcc] -map 0:v -map 0:a -map 1:s? dvd_copy.mkv | ||
+ | </ | ||
+ | ==== Default Subtitles ==== | ||
+ | |||
+ | If any subtitles are copied from the DVD, ffmpeg will mark them all as enabled by default. This means that when playing it back with mpv or mplayer, it will display the subtitles automatically. | ||
+ | |||
+ | ffmpeg has the ability to toggle some off and some on, but not the ability to mark all of them as not default. | ||
+ | |||
+ | An example ... | ||
+ | |||
+ | Encode a video file using defaults for audio and video codec, and copying the first subtitle stream: | ||
+ | |||
+ | < | ||
+ | dvd_copy -o - | ffmpeg -probesize 67108864 -analyzeduration 60000000 -i - -map 0:v -map i:0x80 -map i:0x20 -scodec copy dvd_copy.mkv | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | mediainfo dvd_copy.mkv | ||
+ | </ | ||
+ | |||
+ | Here, '' | ||
+ | |||
+ | < | ||
+ | ... | ||
+ | Text | ||
+ | ID : 3 | ||
+ | Format | ||
+ | Codec ID : S_VOBSUB | ||
+ | Codec ID/ | ||
+ | Duration | ||
+ | Default | ||
+ | Forced | ||
+ | </ | ||
+ | |||
+ | If you were to copy multiple VobSub streams, it will set them all to default: | ||
+ | |||
+ | Switching to using an MPG file in the example here for simplicity. | ||
+ | |||
+ | < | ||
+ | ffmpeg -probesize 67108864 -analyzeduration 60000000 -i dvd_copy.mpg -map 0:v -map i:0x80 -map i:0x20 -map i:0x21 -scodec copy dvd_copy.mkv | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | mediainfo dvd_copy.mkv | ||
+ | </ | ||
+ | |||
+ | Both are set to default here: | ||
+ | |||
+ | < | ||
+ | Text #1 | ||
+ | ID : 3 | ||
+ | Format | ||
+ | Codec ID : S_VOBSUB | ||
+ | Codec ID/ | ||
+ | Duration | ||
+ | Default | ||
+ | Forced | ||
+ | |||
+ | Text #2 | ||
+ | ID : 4 | ||
+ | Format | ||
+ | Codec ID : S_VOBSUB | ||
+ | Codec ID/ | ||
+ | Duration | ||
+ | Default | ||
+ | Forced | ||
+ | </ | ||
+ | |||
+ | ffmpeg *does* let you set the disposition off for one or more, but not all. | ||
+ | |||
+ | Here's an example with three subtitles illustrating the point, where the first two will be disabled as default, and switching the third to enabled: | ||
+ | |||
+ | < | ||
+ | ffmpeg -probesize 67108864 -analyzeduration 60000000 -i dvd_copy.mpg -map 0:v -map i:0x80 -map i:0x20 -map i:0x21 -map i:0x22 -scodec copy -disposition: | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | mediainfo dvd_copy.mkv | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | Text #1 | ||
+ | ID : 3 | ||
+ | Format | ||
+ | Codec ID : S_VOBSUB | ||
+ | Codec ID/ | ||
+ | Duration | ||
+ | Default | ||
+ | Forced | ||
+ | |||
+ | Text #2 | ||
+ | ID : 4 | ||
+ | Format | ||
+ | Codec ID : S_VOBSUB | ||
+ | Codec ID/ | ||
+ | Duration | ||
+ | Default | ||
+ | Forced | ||
+ | |||
+ | Text #3 | ||
+ | ID : 5 | ||
+ | Format | ||
+ | Codec ID : S_VOBSUB | ||
+ | Codec ID/ | ||
+ | Duration | ||
+ | Default | ||
+ | Forced | ||
+ | </ | ||
+ | |||
+ | If you want to disable default for all subtitle tracks, use mkvpropedit (part of mkvtoolnix package), editing them individually: | ||
+ | |||
+ | < | ||
+ | mkvpropedit dvd_copy.mkv --edit track:s1 --set flag-default=0 --edit track:s2 --set flag-default=0 --edit track:s3 --set flag-default=0 | ||
</ | </ |