generated from me/template-mit
Testing some changes to process-video to see if uploads can get more compressed than we're already doing.
This commit is contained in:
+50
-3
@@ -420,7 +420,12 @@ function process-video {
|
|||||||
if [[ -z $size ]]; then
|
if [[ -z $size ]]; then
|
||||||
size="720"
|
size="720"
|
||||||
fi
|
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
|
if [[ -z $passes ]]; then
|
||||||
passes=1
|
passes=1
|
||||||
@@ -431,15 +436,35 @@ function process-video {
|
|||||||
pass="-pass 2"
|
pass="-pass 2"
|
||||||
fi
|
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 ##
|
## Main ##
|
||||||
# More information on two-pass processing with ffmpeg
|
# More information on two-pass processing with ffmpeg
|
||||||
# https://cinelerra-gg.org/download/CinelerraGG_Manual/Two_pass_Encoding_with_FFmp.html
|
# https://cinelerra-gg.org/download/CinelerraGG_Manual/Two_pass_Encoding_with_FFmp.html
|
||||||
if [[ $passes == 2 ]]; then
|
if [[ $passes == 2 ]]; then
|
||||||
set -x
|
set -x
|
||||||
ffmpeg -nostdin -hide_banner -loglevel quiet \
|
$time ffmpeg -nostdin $quiet \
|
||||||
-i "$file" $size $video $audio \
|
-i "$file" $size $video $audio \
|
||||||
-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" \
|
||||||
-vcodec libx264 -movflags +faststart \
|
-vcodec libx264 -movflags +faststart \
|
||||||
|
$v2 \
|
||||||
-pass 1 -f mp4 /dev/null -y
|
-pass 1 -f mp4 /dev/null -y
|
||||||
status=$?
|
status=$?
|
||||||
set +x
|
set +x
|
||||||
@@ -451,10 +476,11 @@ function process-video {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
set -x &&
|
set -x &&
|
||||||
ffmpeg -nostdin -hide_banner -loglevel quiet \
|
$time ffmpeg -nostdin $quiet \
|
||||||
-i "$file" $size $video $audio \
|
-i "$file" $size $video $audio \
|
||||||
-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" \
|
||||||
-vcodec libx264 -movflags +faststart \
|
-vcodec libx264 -movflags +faststart \
|
||||||
|
$v2 \
|
||||||
$pass "$newfile"
|
$pass "$newfile"
|
||||||
status="$?"
|
status="$?"
|
||||||
set +x
|
set +x
|
||||||
@@ -477,6 +503,11 @@ function process-video {
|
|||||||
echo "ERROR: New file not created or has a 0 size." >&2
|
echo "ERROR: New file not created or has a 0 size." >&2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
unset PV_VERTICAL_ASPECT_RATIO
|
||||||
|
unset PV_V2
|
||||||
|
unset PV_TIME
|
||||||
|
unset PV_CBR
|
||||||
|
|
||||||
echo -e "\n`date` - Finished with status '$status'."
|
echo -e "\n`date` - Finished with status '$status'."
|
||||||
return $status
|
return $status
|
||||||
}
|
}
|
||||||
@@ -484,6 +515,22 @@ alias pv="process-video"
|
|||||||
alias fn='basename `pwd`' # Folder Name
|
alias fn='basename `pwd`' # Folder Name
|
||||||
alias qpv='pv ./raw/YouCut*.mp4 `fn`.mp4' # Quick Process Video
|
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
|
# Allow converting video to audio and other smaller
|
||||||
# tasks than what process-video is intended to do.
|
# tasks than what process-video is intended to do.
|
||||||
function basic-process-usage {
|
function basic-process-usage {
|
||||||
|
|||||||
Reference in New Issue
Block a user