From 3e1b37780bfafdb62df8f3da1168e96c16615d3c Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Fri, 26 Sep 2014 16:51:52 +0200 Subject: Fix avoid upscale mono to stereo on audio style "music", or apply bogus audio bitrate when channels are unresolved. --- localvideowebencode | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'localvideowebencode') diff --git a/localvideowebencode b/localvideowebencode index 8b3a3fd..770e083 100755 --- a/localvideowebencode +++ b/localvideowebencode @@ -309,9 +309,10 @@ bitrate_vorbis=64 bitrate_opus=64 bitrate_aac=96 +channels=-1 +maxchannels=2 case "$audio" in music) - channels=2 opusapp=audio ;; hqspeech) @@ -335,11 +336,12 @@ case "$audio" in channels=0 ;; '') - channels=$(avprobe -v warning -show_streams "$infile_first" | perl -ne 's/channels=// and print $_') + : ;; *) exit1 "Unknown audio style \"$audio\".";; esac -[ $channels -le 2 ] || channels=2 +[ $channels -ge 0 ] || channels=$(avprobe -v warning -show_streams "$infile_first" | perl -ne 's/channels=// and print $_' || echo -1) +[ $channels -le $maxchannels ] || channels=$maxchannels [ $channels -gt 0 ] || channels= # TODO: Check and fail if all needed tools are not available @@ -357,9 +359,9 @@ _melt_vp9="$_melt_video f=webm vcodec=libvpx-vp9 vpre=libvpx-$webmpreset${bitrat _melt_audio="${channels:+ac=$channels}" # limit (i.e. avoid peaks "clipping") _melt_postfilters_audio="${limit:+-filter ladspa.1077}" -_melt_vorbis="$_melt_audio acodec=libvorbis ab=$(($channels*$bitrate_vorbis))k" -_melt_opus="$_melt_audio acodec=libopus ab=$(($channels*$bitrate_opus))k${bitrate_fixed:+ vbr=constrained}${opusapp:+ application=$opusapp}" -_melt_aac="$_melt_audio acodec=aac ab=$(($channels*$bitrate_aac))k" +_melt_vorbis="$_melt_audio acodec=libvorbis${channels:+ ab=$(($channels*$bitrate_vorbis))k}" +_melt_opus="$_melt_audio acodec=libopus${channels:+ ab=$(($channels*$bitrate_opus))k}${bitrate_fixed:+ vbr=constrained}${opusapp:+ application=$opusapp}" +_melt_aac="$_melt_audio acodec=aac${channels:+ ab=$(($channels*$bitrate_aac))k}" avconv="avconv -threads auto -y -v warning" _avconv_vp8="-c:v libvpx -pre:v libvpx-$webmpreset${bitrate:+ -b:v $bitrate}${bitrate_fixed:+ -minrate $bitrate -maxrate $bitrate}${bitrate_fixed:- -crf 10} -cpu-used 3" -- cgit v1.2.3