From 0473f784ce405b351d4e097bce1f1adfa2d9bff1 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Tue, 30 Jun 2026 19:32:43 -0700 Subject: [PATCH] Testing some changes to process-video to see if uploads can get more compressed than we're already doing. --- rc_shared.sh | 53 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/rc_shared.sh b/rc_shared.sh index 12554d2..ac4153f 100644 --- a/rc_shared.sh +++ b/rc_shared.sh @@ -420,7 +420,12 @@ function process-video { if [[ -z $size ]]; then size="720" fi - size="-filter:v scale=-1:$size" + # Lanczos is good for upscaling, but this is usually used for downscaling. + if [[ ! -z "$PV_VERTICAL_ASPECT_RATIO" ]]; then + size="-filter:v scale=$size:-1" #:flags=lanczos" + else + size="-filter:v scale=-1:$size" #:flags=lanczos" + fi if [[ -z $passes ]]; then passes=1 @@ -431,15 +436,35 @@ function process-video { pass="-pass 2" fi + v2="" + if [[ ! -z "$PV_V2" ]]; then + v2="-preset veryslow -c:a aac -ar 48000" # -profile:v high + fi + + time="" + if [[ ! -z "$PV_TIME" ]]; then + time="`which time`" + fi + + quiet="-hide_banner -loglevel quiet" + if [[ ! -z "$PV_TIME" && -z "$time" ]]; then + quiet="" + fi + + if [[ ! -z "$PV_CBR" ]]; then + video="-crf 18 -preset veryslow" + fi + ## Main ## # More information on two-pass processing with ffmpeg # https://cinelerra-gg.org/download/CinelerraGG_Manual/Two_pass_Encoding_with_FFmp.html if [[ $passes == 2 ]]; then set -x - ffmpeg -nostdin -hide_banner -loglevel quiet \ + $time ffmpeg -nostdin $quiet \ -i "$file" $size $video $audio \ -filter:a "dynaudnorm=f=33:g=65:p=0.66:m=33.3" \ -vcodec libx264 -movflags +faststart \ + $v2 \ -pass 1 -f mp4 /dev/null -y status=$? set +x @@ -451,10 +476,11 @@ function process-video { fi set -x && - ffmpeg -nostdin -hide_banner -loglevel quiet \ + $time ffmpeg -nostdin $quiet \ -i "$file" $size $video $audio \ -filter:a "dynaudnorm=f=33:g=65:p=0.66:m=33.3" \ -vcodec libx264 -movflags +faststart \ + $v2 \ $pass "$newfile" status="$?" set +x @@ -477,6 +503,11 @@ function process-video { echo "ERROR: New file not created or has a 0 size." >&2 fi + unset PV_VERTICAL_ASPECT_RATIO + unset PV_V2 + unset PV_TIME + unset PV_CBR + echo -e "\n`date` - Finished with status '$status'." return $status } @@ -484,6 +515,22 @@ alias pv="process-video" alias fn='basename `pwd`' # Folder Name alias qpv='pv ./raw/YouCut*.mp4 `fn`.mp4' # Quick Process Video +alias set-pv-short='export PV_VERTICAL_ASPECT_RATIO="y" ' +alias pvs='set-pv-short; pv ' + +alias set-pv2='export PV_V2="y" ' +alias pv2='set-pv2; pv ' +alias pvs2='set-pv-short; set-pv2; pv ' + +alias set-pv-time='export PV_TIME="y" ' +alias tpv='set-tpv; pv ' +alias tpv2='set-tpv; set-pv2; pv ' +alias tpvs='set-tpv; set-pv-short; pv ' +alias tpvs2='set-tpv; set-pv-short; set-pv2; pv ' + +alias set-pv-verbose='export PV_VERBOSE="y" ' +alias set-pv-all="" + # Allow converting video to audio and other smaller # tasks than what process-video is intended to do. function basic-process-usage {