Created
November 14, 2020 00:27
-
-
Save acidDrain/40f8856351d8197a1c2fb44909cec260 to your computer and use it in GitHub Desktop.
Example of how to edit subtitles in a video / media file
This file contains 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
#!/bin/sh | |
# the below command exports only the subtitles/text from the mkv video to a plain-text srt file | |
ffmpeg -i video.mkv -an -vn -map 0:2 -c:s:0 srt sub.srt | |
# this command replaces any text in the subtitles matching "some text to change" with "new text" | |
sed -E 's/(some text to change)/new text/g' -i sub.srt | |
# this command mixes the subtitles back in with the video and audio into a new media file | |
ffmpeg -i video.mkv -i sub.srt -map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy -c:s copy video-new-subtitles.mkv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment