-
-
Save SudhansuuRanjan/23da7d65afd59788bc74f20cc77f57e4 to your computer and use it in GitHub Desktop.
Resize videos keeping the aspect ratio (shows black bar padding where needed)
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
| #!/bin/bash | |
| input="input.mp4" | |
| output="output.mp4" | |
| color="black" | |
| while getopts ":i:o:w:h:c:" opt; do | |
| case $opt in | |
| i) input="$OPTARG" | |
| ;; | |
| o) output="$OPTARG" | |
| ;; | |
| w) width="$OPTARG" | |
| ;; | |
| h) height="$OPTARG" | |
| ;; | |
| c) color="$OPTARG" | |
| ;; | |
| \?) echo "Invalid option -$OPTARG" >&2 | |
| ;; | |
| esac | |
| done | |
| ffmpeg -i $input -vf "scale=w=${width}:h=${height}:force_original_aspect_ratio=decrease,pad=${width}:${height}:(ow-iw)/2:(oh-ih)/2:color=${color}" $output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment