Last active
August 30, 2016 15:41
-
-
Save KrashLeviathan/ed70081b5edc23fb4c7f6b40336be8bb to your computer and use it in GitHub Desktop.
Convert all MKV files in a folder to MP4
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
#!/usr/bin/env bash | |
# 16:9 ratio suggestion | |
$max_width=768 | |
$max_height=432 | |
# 4:3 | |
# $max_width=640 | |
# $max_height=480 | |
for file in *mkv; do | |
# EXPLANATION OF FLAGS | |
# -y Overwrites existing files by the same name without asking. | |
# -i The input file. | |
# -strict -2 Lets ffmpeg use experimental codecs, which it won't by default. | |
# -r Sets the frame rate of the output file. | |
# -v scale=<width>:<height> Sets the width/height of the output. Nested if statements make sure it only scales | |
# the video DOWN to the desired size, not up. | |
ffmpeg -y \ | |
-i "$file" \ | |
-strict -2 \ | |
-r 30 \ | |
-vf "scale='if(gt(a,$max_width/$max_height),$max_width,-1)':'if(gt(a,$max_width/$max_height),-1,$max_height)'" \ | |
"$file.mp4" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment