#!/bin/bash if [[ -z "$1" ]]; then printf 'Need an input file.\n' >&2 exit 1 fi if [[ ! -f "$1" ]]; then printf '%s doesnt exist.\n' >&2 "$1" exit 1 fi full_filename="$1" filename=$(basename -- "$1") output_file="${filename%.*}.webm" log1="/dev/shm/${filename%.*}.log1" log2="/dev/shm/${filename%.*}.log2" read width height < <(mediainfo --Output=JSON "$full_filename" | jq -r '.media.track[] | select(."@type"=="Video") | .Width + " " + .Height') aomenc -o "$output_file" --codec=av1 --passes=3 --pass=1 --fpf="$log1" \ -v --webm -u 0 -t 24 --enable-dnl-denoising=0 --denoise-noise-level=5 \ --target-bitrate=50000 "$full_filename" -w "$width" -h "$height" if [[ $? != 0 ]]; then printf 'oops\n' >&2 exit 1 fi aomenc -o "$output_file" --codec=av1 --passes=3 --pass=2 --fpf="$log1" \ -spf "$log2" -v --webm -u 0 -t 24 --enable-dnl-denoising=0 \ --denoise-noise-level=5 --target-bitrate=50000 "$full_filename" if [[ $? != 0 ]]; then printf 'oops\n' >&2 exit 1 fi aomenc -o "$output_file" --codec=av1 --passes=3 --pass=3 --fpf="$log1" \ -spf "$log2" -v --webm -u 0 -t 24 --enable-dnl-denoising=0 \ --denoise-noise-level=5 --target-bitrate=50000 "$full_filename" if [[ $? != 0 ]]; then printf 'oops\n' >&2 exit 1 fi