Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
subtitles [2019/06/29 04:16]
beandog
subtitles [2020/10/26 18:49] (current)
beandog [Detect CC]
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, ''​mediainfo''​ may or may not display it, while other applications (mplayer, mpv, HandBrake) will. It can be disabled in encoding with ''​-a53cc 0''​ for libx264. Using ''​libx265''​ does not encode the CC at all.
 ==== 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 ''​-sn''​ will not disable them. They must be selected using lavfi and modified / ignored that way.
  
 The fastest way is to see if it has closed captioning is using ffprobe and looking for ''​Closed Captions''​ in the output: The fastest way is to see if it has closed captioning is using ffprobe and looking for ''​Closed Captions''​ in the output:
Line 100: Line 103:
 [/STREAM] [/STREAM]
 </​code>​ </​code>​
- 
  
 ==== Extract CC ==== ==== Extract CC ====
Line 114: Line 116:
 <​code>​ <​code>​
 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
 </​code>​ </​code>​
  
Line 120: Line 122:
  
 <​code>​ <​code>​
-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
 </​code>​ </​code>​
  
 +==== 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**
 +
 +<​code>​
 +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
 +</​code>​
 ==== Default Subtitles ==== ==== Default Subtitles ====
  
Line 195: Line 206:
 <​code>​ <​code>​
 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:​s:​0 0 -disposition:​s:​1 0 -disposition:​s:​2 default dvd_copy.mkv 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:​s:​0 0 -disposition:​s:​1 0 -disposition:​s:​2 default dvd_copy.mkv
 +</​code>​
 +
 +<​code>​
 +mediainfo dvd_copy.mkv
 +</​code>​
 +
 +<​code>​
 +Text #1
 +ID                                       : 3
 +Format ​                                  : VobSub
 +Codec ID                                 : S_VOBSUB
 +Codec ID/​Info ​                           : Picture based subtitle format used on DVDs
 +Duration ​                                : 26 s 660 ms
 +Default ​                                 : No
 +Forced ​                                  : No
 +
 +Text #2
 +ID                                       : 4
 +Format ​                                  : VobSub
 +Codec ID                                 : S_VOBSUB
 +Codec ID/​Info ​                           : Picture based subtitle format used on DVDs
 +Duration ​                                : 26 s 660 ms
 +Default ​                                 : No
 +Forced ​                                  : No
 +
 +Text #3
 +ID                                       : 5
 +Format ​                                  : VobSub
 +Codec ID                                 : S_VOBSUB
 +Codec ID/​Info ​                           : Picture based subtitle format used on DVDs
 +Duration ​                                : 27 s 661 ms
 +Default ​                                 : Yes
 +Forced ​                                  : No
 +</​code>​
 +
 +If you want to disable default for all subtitle tracks, use mkvpropedit (part of mkvtoolnix package), editing them individually:​
 +
 +<​code>​
 +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
 </​code>​ </​code>​

Navigation