Forked from mattst/Test_CRF_Presets_For_Libx264_Encodes
Created
January 23, 2022 19:36
-
-
Save khadorkin/4727872028c37c1c44517577a6dafc44 to your computer and use it in GitHub Desktop.
Script to test encode speeds and file sizes for libx264 encodes with a range of CRF values and presets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
infile="TestClipTwoMin.mp4" | |
datafile="TestClipTwoMinData.csv" | |
crfs=("18" "19" "20" "21" "22" "23" "24" "25" "26" "27") | |
presets=("ultrafast" "superfast" "veryfast" "faster" "fast" "medium" "slow" "slower" "veryslow") | |
echo 'CRF,Preset,Time (Secs),Size (MB)' >> "$datafile" | |
for crf in "${crfs[@]}"; do | |
for preset in "${presets[@]}"; do | |
outfile=Out_CRF_"$crf"_Preset_"$preset".mp4 | |
time_start=$(date +%s.%N) | |
ffmpeg -i "$infile" -c:a copy -c:v libx264 -crf "$crf" -preset "$preset" "$outfile" | |
time_end=$(date +%s.%N) | |
# Dividing by 1 forces the scale to be used. | |
time=$(echo "scale = 2; ($time_end - $time_start)/1" | bc) | |
size_bytes=$(ls -l "$outfile" | awk '{ print $5 }') | |
size_mb=$(echo "scale = 2; $size_bytes / 1000000" | bc) | |
echo $crf,$preset,$time,$size_mb >> "$datafile" | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment