-
-
Save yongjhih/8077a89f4032b78a95e5a5c1f0e6d9f1 to your computer and use it in GitHub Desktop.
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 | |
| # ref. https://github.com/mariomaric/EncodeForYouTube/blob/master/encode4yt.sh | |
| size="1280x720" | |
| # Check if second argument is provided | |
| if [ -z "$2" ] | |
| then | |
| # Create variable with PNG image location | |
| background="/tmp/background.png" | |
| # Create background image using filename as white text on black background | |
| convert \ | |
| -size "$size" \ | |
| -background black -fill white \ | |
| -depth 8 -type Grayscale \ | |
| "$background" | |
| else | |
| # Use second argument as a background image | |
| if [ -f "$2" ] | |
| then | |
| background="$2" | |
| else | |
| echo "$2 not found." | |
| exit 1 | |
| fi | |
| fi | |
| ffmpeg -i "$1" "${1%.*}".jpg | |
| if [ !-f "${1%.*}".jpg ]; then | |
| ffmpeg -f image2 -loop 1 -framerate 1 -i "${1%.*}".jpg -i "$1" -acodec copy -shortest -s "$size" "${1%.*}".mp4 | |
| else | |
| ffmpeg -f image2 -loop 1 -framerate 1 -i "$background" -i "$1" -acodec copy -shortest -s "$size" "${1%.*}".mp4 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment