diff options
author | Jonas Smedegaard <dr@jones.dk> | 2021-02-07 18:59:52 +0100 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2021-02-07 19:33:15 +0100 |
commit | 192f507e8a32c6b14a9be6dbdde0be85da93bfb4 (patch) | |
tree | 44ed51fa27f181bb2703e3465e9b58c431735169 /localvideowebencode | |
parent | 3187ae033cf2eb0a583d4739193e3dff7f7fd0bc (diff) |
tidy: use avc (not h264) as internal key
Diffstat (limited to 'localvideowebencode')
-rwxr-xr-x | localvideowebencode | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/localvideowebencode b/localvideowebencode index b82ad26..bacf5dd 100755 --- a/localvideowebencode +++ b/localvideowebencode @@ -252,7 +252,7 @@ title=${title:-$stem} #use_ffmpeg_vp8=yes #use_ffmpeg_vp9=yes -#use_ffmpeg_h264=yes +#use_ffmpeg_avc=yes #use_vpxenc=yes # Avoid discrete audio encoders if possible: may cause sync problems #use_oggenc=yes @@ -269,17 +269,17 @@ title=${title:-$stem} # resolve quality/speed hints qkey_vp8=crf qkey_vp9=crf -qkey_h264=crf +qkey_avc=crf q_theora=5 q_vp8=33 cpu_vp8=2 q_vp9=33 cpu_vp9=2 -q_h264=23 -preset_h264=medium +q_avc=23 +preset_avc=medium profile_vp8=0 profile_vp9=0 -profile_h264=baseline +profile_avc=baseline case "$compression" in normal) :;; dirty) @@ -287,19 +287,19 @@ case "$compression" in q_theora=1 cpu_vp8=4 cpu_vp9=4 - preset_h264=veryfast + preset_avc=veryfast ;; hq) multipass=yes - no_multipass_h264=yes + no_multipass_avc=yes q_theora=6 cpu_vp8=0 cpu_vp9=1 - preset_h264=veryslow + preset_avc=veryslow ;; exact) multipass=yes - no_multipass_h264=yes + no_multipass_avc=yes ;; quality) no_bitrate=yes @@ -317,21 +317,21 @@ if [ auto = "$gpu" ]; then case "$vainfo" in '') gpu=;; *) - for vformat in vp8 vp9 h264; do + for vformat in vp8 vp9 avc; do eval "no_gpu_decoder_$vformat=yes" eval "no_gpu_encoder_$vformat=yes" done case $(vainfo --display drm --device "$gpudevice" 2>/dev/null | grep -Po 'VAProfile\S+\s*:\s*VAEntrypointVLD') in *VAProfileVP8Version0_3*) no_gpu_decoder_vp8=;; *VAProfileVP9Profile0*) no_gpu_decoder_vp9=;; - *VAProfileH264ConstrainedBaseline*) no_gpu_decoder_h264=;; + *VAProfileH264ConstrainedBaseline*) no_gpu_decoder_avc=;; esac case $(vainfo --display drm --device "$gpudevice" 2>/dev/null | grep -Po 'VAProfile\S+\s*:\s*VAEntrypointEncSlice') in *VAProfileVP8Version0_3*) no_gpu_encoder_vp8=;; *VAProfileVP9Profile0*) no_gpu_encoder_vp9=;; - *VAProfileH264ConstrainedBaseline*) no_gpu_encoder_h264=;; + *VAProfileH264ConstrainedBaseline*) no_gpu_encoder_avc=;; esac - if [ -n "$no_gpu_decoder_vp8$no_gpu_decoder_vp9$no_gpu_decoder_h264" ]; then + if [ -n "$no_gpu_decoder_vp8$no_gpu_decoder_vp9$no_gpu_decoder_avc" ]; then case "$vainfo" in # TODO *"Intel iHD driver"*) gpu=qsv;; *) gpu=vaapi;; @@ -345,18 +345,18 @@ case "$gpu" in multipass= preset_vp8=medium preset_vp9=medium - preset_h264= - profile_h264=578 - qkey_h264=qp + preset_avc= + profile_avc=578 + qkey_avc=qp ;; vaapi) multipass= - preset_h264= - profile_h264=578 - qkey_h264=qp + preset_avc= + profile_avc=578 + qkey_avc=qp case "$compression" in dirty) - preset_h264= + preset_avc= ;; esac ;; @@ -488,11 +488,11 @@ fi # compute average bitrate from reference data and "power of .75" rule if [ -n "$_pixels" ] && [ -n "$_frames" ]; then - bitrate_h264=$(perl -E '$refsize=640*360;' \ + bitrate_avc=$(perl -E '$refsize=640*360;' \ -E "say int( +(($_pixels/\$refsize)**0.75*\$refsize*$_frames*$refbpp) )") - bitrate_theora=$bitrate_h264 # FIXME - bitrate_vp8=$(perl -E "say int( +($bitrate_h264*$factor_vp8) )") #" - bitrate_vp9=$(perl -E "say int( +($bitrate_h264*$factor_vp9) )") #" + bitrate_theora=$bitrate_avc # FIXME + bitrate_vp8=$(perl -E "say int( +($bitrate_avc*$factor_vp8) )") #" + bitrate_vp9=$(perl -E "say int( +($bitrate_avc*$factor_vp9) )") #" fi # default per-codec-channel bitrates @@ -562,15 +562,15 @@ fi encoder_vp8=libvpx encoder_vp9=libvpx-vp9 -encoder_h264=libx264 -for vformat in vp8 vp9 h264; do +encoder_avc=libx264 +for vformat in vp8 vp9 avc; do [ -z "$no_bitrate" ] || eval "no_bitrate_$vformat=yes" eval "[ -n \"$no_bitrate\$no_bitrate_$vformat\" ] || do_bitrate_$vformat=yes" eval "[ -z \"$no_q\$no_q_$vformat\" ] || q_$vformat=" [ -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" - [ h264 = "$vformat" ] || eval "[ -n \"$use_vpxenc\$use_ffmpeg_$vformat\" ] || use_melt_$vformat=yes" + [ avc = "$vformat" ] || eval "[ -n \"$use_vpxenc\$use_ffmpeg_$vformat\" ] || use_melt_$vformat=yes" [ -z "$multipass" ] || eval "[ -n \"\$no_multipass_$vformat\" ] || multipast_$vformat=yes" eval "[ -n \"\$multipass_$vformat\" ] || singlepast_$vformat=yes" done @@ -580,10 +580,10 @@ if [ -n "$use_ffmpeg_vp8$use_ffmpeg_vp9$use_vpxenc" ]; then [ -z "$use_oggenc$use_opusenc" ] || use_wav=yes [ -z "$use_ffmpeg_ogg$use_ffmpeg_opus" ] || use_matroska=yes fi -if [ -n "$use_ffmpeg_h264" ]; then +if [ -n "$use_ffmpeg_avc" ]; then use_matroska=yes else - use_melt_h264=yes + use_melt_avc=yes fi [ -z "$gpu" ] || echo >&2 "GPU platform enabled: $gpu" @@ -643,8 +643,8 @@ _vpxenc_vp8="--codec=vp8${do_bitrate_vp8:+ $_vpxenc_bitrate_vp8} --end-usage=${n _melt_vp9="vcodec=$encoder_vp9${pre_vp9:+ vpreset=$pre_vp9}${preset_vp9:+ preset=$preset_vp9}${do_bitrate_vp9:+ $_melt_bitrate_vp9}${q_vp9:+ ${no_bitrate_vp9:+vb=0 }$qkey_vp9=$q_vp9} $_melt_misc_vp9" _ffmpeg_vp9="-c:v $encoder_vp9${pre_vp9:+ -vpre $pre_vp9}${preset_vp9:+ -preset $preset_vp9}${do_bitrate_vp9:+ $_ffmpeg_bitrate_vp9}${q_vp9:+ ${no_bitrate_vp9:+-b:v 0 }-$qkey_vp9 $q_vp9} $_ffmpeg_misc_vp9" _vpxenc_vp9="--codec=vp9${do_bitrate_vp9:+ $_vpxenc_bitrate_vp9} --end-usage=${no_q_vp9:+vbr}${q_vp9:+cq --cq-level=$q_vp9} $_vpxenc_misc_vp9" -_melt_h264="vcodec=$encoder_h264${preset_h264:+ vpreset=$preset_h264}${profile_h264:+ vprofile=$profile_h264}${x264tune:+ tune=$x264tune}${do_bitrate_h264:+ maxrate=$bitrate_h264${no_gpu:+ bufsize=$((bitrate_h264*2))}}${q_h264:+ $qkey_h264=$q_h264} threads=0${no_gpu:+ movflags=+faststart}" -_ffmpeg_h264="-c:v $encoder_h264${preset_h264:+ -preset $preset_h264}${profile_h264:+ -profile:v $profile_h264}${x264tune:+ -tune $x264tune}${do_bitrate_h264:+ -maxrate $bitrate_h264${no_gpu:+ -bufsize $((bitrate_h264*2))}}${q_h264:+ -$qkey_h264 $q_h264}${no_gpu:+ -movflags +faststart}" +_melt_avc="vcodec=$encoder_avc${preset_avc:+ vpreset=$preset_avc}${profile_avc:+ vprofile=$profile_avc}${x264tune:+ tune=$x264tune}${do_bitrate_avc:+ maxrate=$bitrate_avc${no_gpu:+ bufsize=$((bitrate_avc*2))}}${q_avc:+ $qkey_avc=$q_avc} threads=0${no_gpu:+ movflags=+faststart}" +_ffmpeg_avc="-c:v $encoder_avc${preset_avc:+ -preset $preset_avc}${profile_avc:+ -profile:v $profile_avc}${x264tune:+ -tune $x264tune}${do_bitrate_avc:+ -maxrate $bitrate_avc${no_gpu:+ -bufsize $((bitrate_avc*2))}}${q_avc:+ -$qkey_avc $q_avc}${no_gpu:+ -movflags +faststart}" _melt_pcm="$_melt_downmix acodec=pcm_s16le" _melt_vorbis="$_melt_downmix acodec=libvorbis aq=$quality_vorbis" _ffmpeg_vorbis="$_ffmpeg_downmix -c:a libvorbis -aq $quality_vorbis" @@ -680,9 +680,9 @@ _ffmpeg_webm_keepvideo_opus="-f webm $_ffmpeg_video -c:v copy ${silence:+-an}${c _melt_webm_vp9="f=webm $_melt_video $_melt_vp9 ${silence:+an=1 audio_off=1}${channels:+$_melt_opus}" _ffmpeg_webm_vp9="-f webm $_ffmpeg_video $_ffmpeg_vp9 ${silence:+-an}${channels:+$_ffmpeg_opus}" _ffmpeg_webm_onlyvideo_vp9="-f webm $_ffmpeg_video $_ffmpeg_vp9 -an" -_melt_mp4="f=mp4 $_melt_video $_melt_h264 ${silence:+an=1 audio_off=1}${channels:+${use_mp3:+$_melt_mp3}${use_aac:+$_melt_aac}}" -_ffmpeg_mp4="-f mp4 $_ffmpeg_video $_ffmpeg_h264 ${silence:+-an}${channels:+${use_mp3:+$_ffmpeg_mp3}${use_aac:+$_ffmpeg_aac}}" -_ffmpeg_mp4_onlyvideo="-f mp4 $_ffmpeg_video $_ffmpeg_h264 -an" +_melt_mp4="f=mp4 $_melt_video $_melt_avc ${silence:+an=1 audio_off=1}${channels:+${use_mp3:+$_melt_mp3}${use_aac:+$_melt_aac}}" +_ffmpeg_mp4="-f mp4 $_ffmpeg_video $_ffmpeg_avc ${silence:+-an}${channels:+${use_mp3:+$_ffmpeg_mp3}${use_aac:+$_ffmpeg_aac}}" +_ffmpeg_mp4_onlyvideo="-f mp4 $_ffmpeg_video $_ffmpeg_avc -an" _ffmpeg_mp4_keepvideo="-f mp4 $_ffmpeg_video -c:v copy ${silence:+-an}${channels:+$_ffmpeg_mp3}" _ffmpeg_mp4_keepvideo_aac="-f mp4 $_ffmpeg_video -c:v copy ${silence:+-an}${channels:+$_ffmpeg_aac}" _melt_img="f=image2 $_melt_video" @@ -699,7 +699,7 @@ if [ -n "$loudness" ] && [ -z "$silence$_melt_loudness" ]; then echo >&2 "Loudness data: $_melt_loudness" fi -if [ -n "${webm:+$multipass_vp8}${vp9:+$multipass_vp9}${mp4:+$multipass_h264}" ]; then +if [ -n "${webm:+$multipass_vp8}${vp9:+$multipass_vp9}${mp4:+$multipass_avc}" ]; then if [ -n "${webm:+$use_vpxenc}${vp9:+$use_vpxenc}" ]; then echo >&2 "Analyzing video complexity, as discrete processes..." $melt $_melt_infiles $filters $_melt_stdout \ @@ -708,24 +708,24 @@ if [ -n "${webm:+$multipass_vp8}${vp9:+$multipass_vp9}${mp4:+$multipass_h264}" ] -p 2 --pass=1 --fpf=${stem}_vp8.log -o /dev/null"} \ ${vp9:+"$vpxenc_chained - $_vpxenc_vp9 \ -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}} - elif [ -n "${webm:+$use_ffmpeg_vp8}${vp9:+$use_ffmpeg_vp9}${mp4:+$use_ffmpeg_h264}" ]; then + ${mp4:+${use_ffmpeg_avc:+$_ffmpeg_rawvideo $_ffmpeg_avc -an \ + -pass 1 -passlogfile ${stem}_avc /dev/null}} + elif [ -n "${webm:+$use_ffmpeg_vp8}${vp9:+$use_ffmpeg_vp9}${mp4:+$use_ffmpeg_avc}" ]; 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 \ + ${mp4:+${use_melt_avc:+-consumer avformat:$stem.mp4 $_melt_mp4 \ pass=1 passlogfile=${stem}_vp8}} \ | $ffmpeg_chained $_ffmpeg_stdin \ ${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}}} + ${mp4:+${use_ffmpeg_avc:+${use_ffmpeg_avc:+$_ffmpeg_rawvideo $_ffmpeg_avc -an \ + -pass 1 -passlogfile ${stem}_avc /dev/null}}} else echo >&2 "Analyzing video complexity, at once..." $melt $_melt_infiles $filters \ @@ -733,12 +733,12 @@ if [ -n "${webm:+$multipass_vp8}${vp9:+$multipass_vp9}${mp4:+$multipass_h264}" ] 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 \ + ${mp4:+${use_melt_avc:+-consumer avformat:$stem.mp4 $_melt_mp4 \ pass=1 passlogfile=${stem}_vp8}} fi fi -if [ -n "${webm:+$use_vpxenc$use_ffmpeg_vp8$use_oggenc}${vp9:+$use_vpxenc$use_ffmpeg_vp9$use_opusenc}${mp4:+$use_ffmpeg_h264}" ]; then +if [ -n "${webm:+$use_vpxenc$use_ffmpeg_vp8$use_oggenc}${vp9:+$use_vpxenc$use_ffmpeg_vp9$use_opusenc}${mp4:+$use_ffmpeg_avc}" ]; then echo >&2 "Encoding video${channels:+ and extracting audio}, as discrete files..." $melt $_melt_infiles \ ${channels:+$audioprefilters \ @@ -746,7 +746,7 @@ if [ -n "${webm:+$use_vpxenc$use_ffmpeg_vp8$use_oggenc}${vp9:+$use_vpxenc$use_ff results="$_melt_loudness"}} \ $filters${channels:+ $_melt_postfilters_audio} \ ${ogg:+-consumer avformat:$stem.ogv $_melt_ogg} \ - ${mp4:+${use_melt_h264:+-consumer avformat:$stem.mp4 $_melt_mp4}} \ + ${mp4:+${use_melt_avc:+-consumer avformat:$stem.mp4 $_melt_mp4}} \ ${channels:+${use_wav:+-consumer avformat:$stem.wav \ $_melt_wav}} \ ${channels:+${use_matroska:+-consumer avformat:$stem.mkv \ @@ -769,9 +769,9 @@ if [ -n "${webm:+$use_vpxenc$use_ffmpeg_vp8$use_oggenc}${vp9:+$use_vpxenc$use_ff ${singlepass_vp9:+-p 1} \ ${multipass_vp9:+-p 2 --pass=2 --fpf=${stem}_vp9.log} \ -o ${stem}_vp9${channels:+_silent}.webm"}} \ - ${mp4:+${use_ffmpeg_h264:+"$ffmpeg_chained \ + ${mp4:+${use_ffmpeg_avc:+"$ffmpeg_chained \ $_ffmpeg_stdin $_ffmpeg_mp4_onlyvideo \ - ${multipass_h264:+-pass 2 -passlogfile ${stem}_h264} \ + ${multipass_avc:+-pass 2 -passlogfile ${stem}_avc} \ ${stem}${channels:+_silent}.mp4"}} if [ -n "${webm:+$use_vpxenc$use_ffmpeg_vp8$use_oggenc}" ] && [ -n "$channels" ]; then echo >&2 "Encoding Vorbis audio and muxing with VP8 video..." @@ -801,7 +801,7 @@ if [ -n "${webm:+$use_vpxenc$use_ffmpeg_vp8$use_oggenc}${vp9:+$use_vpxenc$use_ff $_ffmpeg_webm_keepvideo_opus ${stem}_vp9.webm fi fi - if [ -n "${mp4:+$use_ffmpeg_h264}" ] && [ -n "$channels" ]; then + if [ -n "${mp4:+$use_ffmpeg_avc}" ] && [ -n "$channels" ]; then if [ -n "$use_mp3" ]; then echo "Encoding MP3 audio and muxing with H.264/AVC video..." $ffmpeg_alone $_ffmpeg_mp4_in -i ${stem}_silent.mp4 \ |