summaryrefslogtreecommitdiff
path: root/localvideowebencode
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2021-02-06 18:44:26 +0100
committerJonas Smedegaard <dr@jones.dk>2021-02-06 18:44:26 +0100
commit7ad108b6999ba5728be79cf094e9cb4f2441c9b3 (patch)
tree1087e3406187db60e1a2ffc7a8f3a55937401f37 /localvideowebencode
parentb1644d4090dcb9570d9b0a3e60ef5e16bb3d9bf1 (diff)
use melt for GPU-accelerated and dual-pass encoding
Diffstat (limited to 'localvideowebencode')
-rwxr-xr-xlocalvideowebencode45
1 files changed, 29 insertions, 16 deletions
diff --git a/localvideowebencode b/localvideowebencode
index f3332d7..89b6a01 100755
--- a/localvideowebencode
+++ b/localvideowebencode
@@ -568,11 +568,7 @@ for vformat in vp8 vp9 h264; do
[ -z "$q" ] || eval "q_$vformat=$q"
eval "[ -n \"\$q_$vformat\" ] || no_q_$vformat=yes"
[ -z "$gpu" ] || eval "[ -n \"\$no_gpu_encoder_$vformat\" ] || encoder_$vformat=${vformat}_$gpu"
-
- # melt supports dual-pass only for h.264
- [ h264 = "$vformat" ] || [ -n "$use_vpxenc" ] || eval "[ -z \"$multipass\" ] || use_ffmpeg_$vformat=yes"
- # melt (before v6.26) does not support encode-only hardware acceleration
- [ h264 = "$vformat" ] || [ -n "$use_vpxenc$gpu_vaapi" ] || eval "[ -z \"$multipass\" ] || use_ffmpeg_$vformat=yes"
+ [ h264 = "$vformat" ] || eval "[ -n \"$use_vpxenc\$use_ffmpeg_$vformat\" ] || use_melt_$vformat=yes"
done
if [ -n "$use_ffmpeg_vp8$use_ffmpeg_vp9$use_vpxenc" ]; then
[ -n "$use_oggenc" ] || use_ffmpeg_ogg=yes
@@ -699,9 +695,9 @@ if [ -n "$loudness" ] && [ -z "$silence$_melt_loudness" ]; then
echo >&2 "Loudness data: $_melt_loudness"
fi
-if [ -n "$multipass" ] && [ -n "${webm:+$use_vpxenc$use_ffmpeg_vp8$use_oggenc}${vp9:+$use_vpxenc$use_ffmpeg_vp9$use_opusenc}${mp4:+$use_ffmpeg_h264}" ]; then
- echo >&2 "Analyzing video complexity..."
- if [ -n "$use_vpxenc" ]; then
+if [ -n "$multipass" ]; then
+ if [ -n "${webm:+$use_vpxenc}${vp9:+$use_vpxenc}" ]; then
+ echo >&2 "Analyzing video complexity, as discrete processes..."
$melt $_melt_infiles $filters $_melt_stdout \
| pee \
${webm:+"$vpxenc_chained - $_vpxenc_vp8 \
@@ -710,15 +706,31 @@ if [ -n "$multipass" ] && [ -n "${webm:+$use_vpxenc$use_ffmpeg_vp8$use_oggenc}${
-p 2 --pass=1 --fpf=${stem}_vp9.log -o /dev/null"} \
${mp4:+${use_ffmpeg_h264:+$_ffmpeg_rawvideo $_ffmpeg_h264 -an \
-pass 1 -passlogfile ${stem}_h264 /dev/null}}
- else
+ elif [ -n "${webm:+$use_ffmpeg_vp8}${vp9:+$use_ffmpeg_vp9}${mp4:+$use_ffmpeg_h264}" ]; then
+ echo >&2 "Analyzing video complexity, integrated with ffmpeg"
$melt $_melt_infiles $filters $_melt_stdout \
+ ${webm:+${use_melt_vp8:+-consumer avformat:$stem.webm $_melt_webm \
+ pass=1 passlogfile=${stem}_vp8}} \
+ ${vp9:+${use_melt_vp9:+-consumer avformat:${stem}_vp9.webm $_melt_webm_vp9 \
+ pass=1 passlogfile=${stem}_vp9}} \
+ ${mp4:+${use_melt_h264:+-consumer avformat:$stem.mp4 $_melt_mp4 \
+ pass=1 passlogfile=${stem}_vp8}} \
| $ffmpeg_chained $_ffmpeg_stdin \
- ${webm:+$_ffmpeg_rawvideo $_ffmpeg_vp8 -an \
- -pass 1 -passlogfile ${stem}_vp8 /dev/null} \
- ${vp9:+$_ffmpeg_rawvideo $_ffmpeg_vp9 -an \
- -pass 1 -passlogfile ${stem}_vp9 /dev/null} \
- ${mp4:+${use_ffmpeg_h264:+$_ffmpeg_rawvideo $_ffmpeg_h264 -an \
- -pass 1 -passlogfile ${stem}_h264 /dev/null}}
+ ${webm:+${use_ffmpeg_vp8:+$_ffmpeg_rawvideo $_ffmpeg_vp8 -an \
+ -pass 1 -passlogfile ${stem}_vp8 /dev/null}} \
+ ${vp9:+${use_ffmpeg_vp9:+$_ffmpeg_rawvideo $_ffmpeg_vp9 -an \
+ -pass 1 -passlogfile ${stem}_vp9 /dev/null}} \
+ ${mp4:+${use_ffmpeg_h264:+${use_ffmpeg_h264:+$_ffmpeg_rawvideo $_ffmpeg_h264 -an \
+ -pass 1 -passlogfile ${stem}_h264 /dev/null}}}
+ else
+ echo >&2 "Analyzing video complexity, at once..."
+ $melt $_melt_infiles $filters \
+ ${webm:+${use_melt_vp8:+-consumer avformat:$stem.webm $_melt_webm \
+ pass=1 passlogfile=${stem}_vp8}} \
+ ${vp9:+${use_melt_vp9:+-consumer avformat:${stem}_vp9.webm $_melt_webm_vp9 \
+ pass=1 passlogfile=${stem}_vp9}} \
+ ${mp4:+${use_melt_h264:+-consumer avformat:$stem.mp4 $_melt_mp4 \
+ pass=1 passlogfile=${stem}_vp8}}
fi
fi
@@ -810,7 +822,8 @@ else
${multipass:+pass=2 passlogfile=${stem}_vp8}} \
${vp9:+-consumer avformat:${stem}_vp9.webm $_melt_webm_vp9 \
${multipass:+pass=2 passlogfile=${stem}_vp9}} \
- ${mp4:+-consumer avformat:$stem.mp4 $_melt_mp4}
+ ${mp4:+-consumer avformat:$stem.mp4 $_melt_mp4
+ ${multipass:+pass=2 passlogfile=${stem}_vp8}}
fi
# cleanup encoding cruft