summaryrefslogtreecommitdiff
path: root/localvideowebencode
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2014-09-26 16:51:52 +0200
committerJonas Smedegaard <dr@jones.dk>2014-09-26 16:52:05 +0200
commit3e1b37780bfafdb62df8f3da1168e96c16615d3c (patch)
tree28180a4a94b0c10b84d39af5d63cb0636e2e0307 /localvideowebencode
parent084d15113beb7551eb6375c90cf97ee2e2c911b4 (diff)
Fix avoid upscale mono to stereo on audio style "music", or apply bogus audio bitrate when channels are unresolved.
Diffstat (limited to 'localvideowebencode')
-rwxr-xr-xlocalvideowebencode14
1 files changed, 8 insertions, 6 deletions
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"