Created
June 28, 2019 14:13
-
-
Save m-decoster/c26f85842a880a46c2f25bd3b1e68d2c to your computer and use it in GitHub Desktop.
Remove part of an MKV file
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
#!/usr/bin/env bash | |
# Very simple script if you have to do this operation quite often, but is not exactly checking a lot of edge cases | |
# USE WITH CARE! | |
# Requires ffmpeg (apt install ffmpeg) | |
# Requires mkvmerge (apt install mkvtoolnix) | |
# Call as ./cut_out_mkv.sh INPUT_FILE.mkv 00:00:10 00:00:15 OUTPUT_FILE.mkv to e.g. | |
# remove 5 seconds from the video starting at the tenth second | |
# argument 1: input file name | |
# Copy first part (argument 2: format HH:MM:SS) | |
ffmpeg -i $1 -ss 00:00:00 -to $2 p1.mkv | |
# Copy second part (argument 3: format HH:MM:SS) | |
ffmpeg -i $1 -ss $3 -p2.mkv | |
# Merge (argument 4: output file name) | |
mkvmerge -o $4 p1.mkv +p2.mkv | |
rm p1.mkv | |
rm p2.mkv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment