Created
August 14, 2020 17:18
-
-
Save shoreline-chrism/49d8b3c99179831a9ebd5df129d72ade to your computer and use it in GitHub Desktop.
Convert and optimize source video file to web ready webm and 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
#!/bin/bash | |
# Optimize and optionally downsize videos to WEBM and MP4 | |
# Requires ffmpeg installed in your PATH or in CWD | |
read -e -p "Source file: " SOURCE | |
read -e -p "Output filename base: " OUTPUTBASE | |
read -p 'Video width (no px): ' -e -i '1280' VIDEOWIDTH | |
read -p 'Video height (no px): ' -e -i '720' VIDEOHEIGHT | |
ffmpeg -i "$SOURCE" -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis -vf scale="$VIDEOWIDTH:$VIDEOHEIGHT" "$OUTPUTBASE.webm" ; | |
ffmpeg -i "$SOURCE" -vcodec h264 -acodec copy -vf scale="$VIDEOWIDTH:$VIDEOHEIGHT" "$OUTPUTBASE.mp4" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment