Skip to content

Instantly share code, notes, and snippets.

@matthiasseghers
Last active September 7, 2023 21:57
Show Gist options
  • Save matthiasseghers/58b4e42268ed2c061c0b1e2156594485 to your computer and use it in GitHub Desktop.
Save matthiasseghers/58b4e42268ed2c061c0b1e2156594485 to your computer and use it in GitHub Desktop.
Batch convert PS5 webm (HDR) clips to mkv (SDR).
#!/bin/bash
function cleanup {
echo "Ctrl+C detected, stopping the script..."
exit 1
}
trap cleanup INT
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <input_folder>"
exit 1
fi
input_folder="$1"
output_folder="$input_folder"
# Check if there are any .webm files in the input folder
if ! ls "$input_folder"/*.webm >/dev/null 2>&1; then
echo "No .webm files found in the input folder."
exit 1
fi
for input_file in "$input_folder"/*.webm; do
if [ -e "$input_file" ]; then
# Get the filename without extension
filename=$(basename -- "$input_file")
filename_noext="${filename%.*}"
# Define the output file path
output_file="$output_folder/$filename_noext.mp4"
# Run your ffmpeg command
ffmpeg -i "$input_file" -vf "zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p" -c:v libx264 -crf 17 -preset slower "$output_file"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment