Skip to content

Instantly share code, notes, and snippets.

@shoreline-chrism
Created August 14, 2020 17:18
Show Gist options
  • Save shoreline-chrism/49d8b3c99179831a9ebd5df129d72ade to your computer and use it in GitHub Desktop.
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
#!/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