Last active
April 22, 2025 14:29
-
-
Save danikaze/5e890487751103b8b638863698f95212 to your computer and use it in GitHub Desktop.
ffmpeg ops
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Add subtitles from a .srt (i.e. extracted before) to a .mkv file | |
# | |
ffmpeg.exe \ | |
-i video.mkv # input 0 = video to use | |
-sub_charenc 'UTF-8' # support for UTF8 on subs | |
-f srt # subtitle format srt (change to ass when needed) | |
-i sub-file1.srt # input 1 = subs1 | |
-i sub-file2.srt # input 2 = subs2 | |
-map 0 # use input 0 (video) | |
-map 1:0 -map 2:0 # add the input 1 and 2 (subs) to input 0 (video) | |
-c:v copy -c:a copy -c:s srt # just copy the sources | |
# Provide metadata/names for the subtitle tracks | |
"-metadata:s:s:0" "language=eng" "-metadata:s:s:0" "handler_name=English" | |
"-metadata:s:s:1" "language=es" "-metadata:s:s:1" "handler_name=Spanish" | |
out.mkv |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Extract a subtitle from a .mkv file | |
# | |
# -map X:s:Y means (https://trac.ffmpeg.org/wiki/Map) | |
# * X: Input index | |
# * s: subitle (v for video, a for audio) | |
# * Y: Stream index | |
# 0:s:0 = the 1st subtitle of the 1st stream | |
ffmpeg.exe -i INPUT_FILE.mkv -map 0:s:0 OUTPUT.srt | |
# To display 2 subs at the same time (i.e. 2 langs) use | |
# https://srtmerge.github.io/ to merge 2 .srt files (i.e. JP+EN into one) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remove an audio track from a .mkv file | |
# | |
# 0:a:1 = the 2nd audio of the 1st stream | |
ffmpeg.exe -i INPUT_FILE -map 0 -map -0:a:1 -c copy OUTPUT_FILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment