Skip to content

Instantly share code, notes, and snippets.

@fusetim
Created January 28, 2024 15:08
Show Gist options
  • Save fusetim/2e2781ab6dfe7d0c9ff077c0f01e0181 to your computer and use it in GitHub Desktop.
Save fusetim/2e2781ab6dfe7d0c9ff077c0f01e0181 to your computer and use it in GitHub Desktop.
FFmpeg, queue transcoding
# Edit LP=x if needed
ffmpeg -i input.mkv \
-c:v libsvtav1 -preset 8 -crf 28 -g 120 \
-pix_fmt yuv420p10le \
-svtav1-params "tune=0:enable-tf=0:enable-qm=1:qm-min=0:qm-max=15:scd=0:lp=4:pin=1:irefresh-type=2:film-grain=1:film-grain-denoise=0:lookahead=48:tile-rows=1:tile-columns=2:fast-decode=1" \
-c:a copy \
output.AV1.1080p.mkv
# DO NOT FORGET TO EDIT THE HDR10 metadata
# Edit LP=x if needed
ffmpeg -i input.mkv \
-c:v libsvtav1 -preset 8 -crf 28 -g 120 \
-pix_fmt yuv420p10le \
-colorspace bt2020nc -color_trc smpte2084 -color_primaries bt2020
-svtav1-params "tune=0:enable-tf=0:enable-qm=1:qm-min=0:qm-max=15:scd=0:lp=4:pin=1:irefresh-type=2:film-grain=1:film-grain-denoise=0:lookahead=48:tile-rows=1:tile-columns=2:fast-decode=1:color-primaries=9:transfer-characteristics=16:matrix-coefficients=9:mastering-display=G(0.1700,0.7970)B(0.1310,0.0460)R(0.7080,0.2920)WP(0.3127,0.3290)L(4000.0000,0.0050):content-light=725,162" \
-c:a copy \
output.AV1.4K.HDR10.mkv
#!/bin/bash
# Check if the correct number of arguments is provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <input_directory> <output_directory>"
exit 1
fi
input_dir=$1
output_dir=$2
# Check if input directory exists
if [ ! -d "$input_dir" ]; then
echo "Error: Input directory does not exist."
exit 1
fi
# Check if output directory exists, if not create it
if [ ! -d "$output_dir" ]; then
mkdir -p "$output_dir"
fi
# Iterate through each file in the input directory
for file in "$input_dir"/*; do
# Extract file name without extension
filename=$(basename -- "$file")
filename_noext="${filename%.*}"
# Construct output file path
output_file="$output_dir/$filename_noext.mkv"
# Run ffmpeg command
ffmpeg -i $file \
-c:v libsvtav1 -preset 8 -crf 28 -g 120 \
-pix_fmt yuv420p10le \
-svtav1-params "tune=0:enable-tf=0:enable-qm=1:qm-min=0:qm-max=15:scd=0:lp=4:pin=1:irefresh-type=2:film-grain=1:film-grain-denoise=0:lookahead=48:tile-rows=1:tile-columns=2:fast-decode=1" \
-c:a copy \
$output_file
echo "Conversion of $filename complete."
done
echo "All files converted successfully."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment