generated from me/template-mit
pv3, fix indentation. pv-test, fix VBR on AV1 to be more testable while also adding capped CRF as an option (changes not yet fully tested).
This commit is contained in:
+101
-57
@@ -823,7 +823,7 @@ function pv-test {
|
|||||||
|
|
||||||
# Loop Data #
|
# Loop Data #
|
||||||
|
|
||||||
declare -l {vpreset,crf,vbr,abr,achannel,afreq}s="default"
|
declare -l {vpreset,crf,vbr,abr,achannel,afreq,over,under}s="default"
|
||||||
|
|
||||||
echo -e " * * Loop Settings * * \n"
|
echo -e " * * Loop Settings * * \n"
|
||||||
|
|
||||||
@@ -852,6 +852,20 @@ function pv-test {
|
|||||||
fi
|
fi
|
||||||
echo -e " video bitrates: '$vbrs'\n"
|
echo -e " video bitrates: '$vbrs'\n"
|
||||||
|
|
||||||
|
if [[ "$vcodecs" == *"libsvtav1"* ]]; then
|
||||||
|
read -p "Please provide any over percentages for libsvtav1: [default] " test_overs
|
||||||
|
if [[ -n "$test_overs" ]]; then
|
||||||
|
overs="$test_overs"
|
||||||
|
fi
|
||||||
|
echo -e " over percentages: '$overs'\n"
|
||||||
|
|
||||||
|
read -p "Please provide any under percentages for libsvtav1: [default] " test_unders
|
||||||
|
if [[ -n "$test_unders" ]]; then
|
||||||
|
unders="$test_unders"
|
||||||
|
fi
|
||||||
|
echo -e " under percentages: '$unders'\n"
|
||||||
|
fi
|
||||||
|
|
||||||
acodecs="aac libopus"
|
acodecs="aac libopus"
|
||||||
read -p "Please provide the audio codecs to test: [$acodecs] " test_acodecs
|
read -p "Please provide the audio codecs to test: [$acodecs] " test_acodecs
|
||||||
if [[ -n "$test_acodecs" ]]; then
|
if [[ -n "$test_acodecs" ]]; then
|
||||||
@@ -920,9 +934,10 @@ function pv-test {
|
|||||||
echo -e " * Testing with 'pv2' complete! * \n"
|
echo -e " * Testing with 'pv2' complete! * \n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# TBD - Do multiplication with `wc` rather than a loop here.
|
||||||
count=0
|
count=0
|
||||||
for vcodec in $vcodecs; do for vpreset in $vpresets; do
|
for vcodec in $vcodecs; do for vpreset in $vpresets; do for crf in $crfs; do
|
||||||
for crf in $crfs; do for vbr in $vbrs; do
|
for vbr in $vbrs; do for over in $overs; do for under in $under; do
|
||||||
for acodec in $acodecs; do for abr in $abrs;
|
for acodec in $acodecs; do for abr in $abrs;
|
||||||
do for achannel in $achannels; do for afreq in $afreqs; do
|
do for achannel in $achannels; do for afreq in $afreqs; do
|
||||||
for ext in $exts; do
|
for ext in $exts; do
|
||||||
@@ -930,8 +945,8 @@ function pv-test {
|
|||||||
done
|
done
|
||||||
done done
|
done done
|
||||||
done done
|
done done
|
||||||
done done
|
done done done
|
||||||
done done
|
done done done
|
||||||
plural=""
|
plural=""
|
||||||
if (( $count != 1 )); then
|
if (( $count != 1 )); then
|
||||||
plural="s"
|
plural="s"
|
||||||
@@ -940,8 +955,8 @@ function pv-test {
|
|||||||
|
|
||||||
count=0
|
count=0
|
||||||
unset vcodec vpreset crf vbr acodec abr ext
|
unset vcodec vpreset crf vbr acodec abr ext
|
||||||
for vcodec in $vcodecs; do for vpreset in $vpresets; do
|
for vcodec in $vcodecs; do for vpreset in $vpresets; do for crf in $crfs; do
|
||||||
for crf in $crfs; do for vbr in $vbrs; do
|
for vbr in $vbrs; do for over in $overs; do for under in $under; do
|
||||||
for acodec in $acodecs; do for abr in $abrs;
|
for acodec in $acodecs; do for abr in $abrs;
|
||||||
do for achannel in $achannels; do for afreq in $afreqs; do
|
do for achannel in $achannels; do for afreq in $afreqs; do
|
||||||
for ext in $exts; do
|
for ext in $exts; do
|
||||||
@@ -972,9 +987,38 @@ function pv-test {
|
|||||||
if [[ "$crf" != "default" ]]; then
|
if [[ "$crf" != "default" ]]; then
|
||||||
bitrate="-crf $crf"
|
bitrate="-crf $crf"
|
||||||
fi
|
fi
|
||||||
|
declare {o,u}fn=""
|
||||||
if [[ "$vbr" != "default" ]]; then
|
if [[ "$vbr" != "default" ]]; then
|
||||||
if [[ "$vcodec" == "libsvtav1" ]]; then
|
if [[ "$vcodec" == "libsvtav1" ]]; then
|
||||||
bitrate="$bitrate -svtav1-params rc=1:tbr=$vbr:overshoot-pct=0:undershoot-pct=100"
|
#bitrate="$bitrate -svtav1-params rc=1:tbr=$vbr:overshoot-pct=0:undershoot-pct=100"
|
||||||
|
|
||||||
|
declare {o,u}=""
|
||||||
|
if [[ "$over" != "default" ]]; then
|
||||||
|
o=":overshoot-pct=$over"
|
||||||
|
ofn="-o$over"
|
||||||
|
fi
|
||||||
|
if [[ "$under" != "default" ]]; then
|
||||||
|
u=":undershoot-pct=$under"
|
||||||
|
ufn="-u$under"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$crf" == "default" ]]; then
|
||||||
|
# Variable Bitrate, rate passed should be the TARGET, not the max.
|
||||||
|
# Can control the params which allow the target to go up and down, but defaults are okay.
|
||||||
|
# Seems better to not try and force this to imitate "-b:v -minrate -maxrate -bufsize"
|
||||||
|
# Will definitely want to use a slower preset to ensure the quality stays consistent.
|
||||||
|
|
||||||
|
# Can be done like this if not changing over or under.
|
||||||
|
#bitrate="-b:v $vbr"
|
||||||
|
|
||||||
|
# rc=1, over defaults to 25, under defaults to 50
|
||||||
|
# rc=2, over defaults to 25, under defaults to 25
|
||||||
|
bitrate="-svtav1-params rc=1:tbr=${vbr}${o}${u}"
|
||||||
|
else
|
||||||
|
# Capped CRF, when both a CRF and bitrate are passed.
|
||||||
|
# Better to use high CRF with low BR than high BR with low CRF (produces artifacts/tearing).
|
||||||
|
bitrate="-svtav1-params rc=0:crf=${crf}:mbr=${vbr}${o}${u}"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
bitrate="$bitrate -b:v $vbr -minrate 0 -maxrate $vbr -bufsize $vbr"
|
bitrate="$bitrate -b:v $vbr -minrate 0 -maxrate $vbr -bufsize $vbr"
|
||||||
fi
|
fi
|
||||||
@@ -1003,7 +1047,7 @@ function pv-test {
|
|||||||
frequency="-ar $afreq"
|
frequency="-ar $afreq"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
newfile="_${size_in}p_${vcodec}-${vpreset}-${crf}-${vbr}_${acodec}-${abr}-${achannel}-${afreq}.${ext}"
|
newfile="_${size_in}p_${vcodec}-${vpreset}-${crf}-${vbr}${ofn}${ufn}_${acodec}-${abr}-${achannel}-${afreq}.${ext}"
|
||||||
echo -e " * Parameters for this test: $newfile * \n"
|
echo -e " * Parameters for this test: $newfile * \n"
|
||||||
|
|
||||||
if [[ -e "$newfile" ]]; then
|
if [[ -e "$newfile" ]]; then
|
||||||
@@ -1052,8 +1096,8 @@ function pv-test {
|
|||||||
done
|
done
|
||||||
done done
|
done done
|
||||||
done done
|
done done
|
||||||
done done
|
done done done
|
||||||
done done
|
done done done
|
||||||
|
|
||||||
## Finish ##
|
## Finish ##
|
||||||
|
|
||||||
@@ -1066,62 +1110,62 @@ function pv-test {
|
|||||||
|
|
||||||
# 20260914 - After playing with pv-test for a while.
|
# 20260914 - After playing with pv-test for a while.
|
||||||
function pv3 {
|
function pv3 {
|
||||||
org="$1"
|
org="$1"
|
||||||
out="$2"
|
out="$2"
|
||||||
echo "Processing '$org' to '$out' using AV1 and OPUS."
|
echo "Processing '$org' to '$out' using AV1 and OPUS."
|
||||||
|
|
||||||
## Versions ##
|
## Versions ##
|
||||||
|
|
||||||
# v0
|
# v0
|
||||||
scale=-1:720
|
scale=-1:720
|
||||||
preset=0 # took 20 minutes where preset 2 was under 2 minutes
|
preset=0 # took 20 minutes where preset 2 was under 2 minutes
|
||||||
crf=18
|
crf=18
|
||||||
vbr=2000k # this is creating 2Mbps files, not maxxing at 2.
|
vbr=2000k # this is creating 2Mbps files, not maxxing at 2.
|
||||||
overshoot=0
|
overshoot=0
|
||||||
undershoot=100
|
undershoot=100
|
||||||
|
|
||||||
# v1
|
# v1
|
||||||
preset=2 # WAY faster and still great.
|
preset=2 # WAY faster and still great.
|
||||||
crf=28 # much smaller filesize
|
crf=28 # much smaller filesize
|
||||||
|
|
||||||
# v2
|
# v2
|
||||||
# Try to mimic h264 better.
|
# Try to mimic h264 better.
|
||||||
vbr=1000k
|
vbr=1000k
|
||||||
overshoot=100
|
overshoot=100
|
||||||
|
|
||||||
# v3
|
# v3
|
||||||
# Fix weird aspect ratios.
|
# Fix weird aspect ratios.
|
||||||
scale="1280:720,setsar=1"
|
scale="1280:720,setsar=1"
|
||||||
|
|
||||||
## Main ##
|
## Main ##
|
||||||
|
|
||||||
echo -e "\n * Original File * \n"
|
echo -e "\n * Original File * \n"
|
||||||
ffprobe -i "$org"
|
ffprobe -i "$org"
|
||||||
|
|
||||||
echo -e "\n * Starting Processing *\n"
|
echo -e "\n * Starting Processing *\n"
|
||||||
date
|
date
|
||||||
set -x
|
set -x
|
||||||
ffmpeg -nostdin -hide_banner -loglevel level+warning \
|
ffmpeg -nostdin -hide_banner -loglevel level+warning \
|
||||||
-i "$org" \
|
-i "$org" \
|
||||||
-c:v libsvtav1 \
|
-c:v libsvtav1 \
|
||||||
-preset $preset \
|
-preset $preset \
|
||||||
-filter:v scale=$scale \
|
-filter:v scale=$scale \
|
||||||
-crf $crf \
|
-crf $crf \
|
||||||
-svtav1-params rc=1:tbr=${vbr}:overshoot-pct=${overshoot}:undershoot-pct=${undershoot} \
|
-svtav1-params rc=1:tbr=${vbr}:overshoot-pct=${overshoot}:undershoot-pct=${undershoot} \
|
||||||
-c:a libopus \
|
-c:a libopus \
|
||||||
-filter:a dynaudnorm=f=33:g=65:p=0.66:m=33.3 \
|
-filter:a dynaudnorm=f=33:g=65:p=0.66:m=33.3 \
|
||||||
-movflags +faststart \
|
-movflags +faststart \
|
||||||
"$out"
|
"$out"
|
||||||
status="$?"
|
status="$?"
|
||||||
set +x
|
set +x
|
||||||
|
|
||||||
if [[ "$status" != 0 || ! -s "$out" ]]; then
|
if [[ "$status" != 0 || ! -s "$out" ]]; then
|
||||||
echo "Failed, deleting output."
|
echo "Failed, deleting output."
|
||||||
mv -v "$out" ~/TRASH/
|
mv -v "$out" ~/TRASH/
|
||||||
return $status
|
return $status
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "\n * Success! *"
|
echo -e "\n * Success! *"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user