Skip to content

Instantly share code, notes, and snippets.

@bvibber
Created February 9, 2022 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bvibber/91eea4183950bf580c0b5e98b98e7754 to your computer and use it in GitHub Desktop.
Save bvibber/91eea4183950bf580c0b5e98b98e7754 to your computer and use it in GitHub Desktop.
run-rav1e.sh
# currently broken in the 2-pass settings?
INFILE="$1"
FILE_HEIGHT=`ffprobe -hide_banner -show_entries stream=height -of csv=p=0:s=x "$INFILE"`
function ffmpeg() {
LD_LIBRARY_PATH=/opt/ffmpeg/lib /opt/ffmpeg/bin/ffmpeg "$@"
}
function run() {
WIDTH="$1"
HEIGHT="$2"
BITRATE="$3"
TILES="$4"
if [ "$FILE_HEIGHT" -ge "$HEIGHT" ]
then
ffmpeg -i "$INFILE" \
-vf scale="$WIDTH":-1 \
-f webm \
-an \
-strict -2 \
-vcodec librav1e -tile-columns "$TILES" \
-pass 1 -passlogfile pass-rav1e.log \
-speed 2 \
-g 240 \
-b:v "$BITRATE" \
-y /dev/null \
&& \
ffmpeg -i "$INFILE" \
-vf scale="$WIDTH":-1 \
-f webm \
-strict -2 \
-acodec libopus -ar 48000 -ac 2 -b:a 96k \
-vcodec librav1e -tile-columns "$TILES" \
-pass 2 -passlogfile pass-rav1e.log \
-speed 1 \
-g 240 \
-b:v "$BITRATE" \
-y "$INFILE.rav1e.${HEIGHT}p.webm"
fi
}
run 426 240 100k 1
run 640 360 225k 2
run 854 480 400k 2
run 1280 720 800k 3
run 1920 1080 1600k 3
run 2560 1440 2400k 4
run 3840 2160 4800k 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment