Fix audio bitrate/codec settings

This commit is contained in:
GenZmeY 2018-09-19 01:58:13 +03:00 committed by GitHub
parent 19c97a0fa5
commit 29acdb0553
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,7 +9,7 @@ ScriptDir=$(dirname $(readlink -e "$0"))
ExtRegex='.*\(mkv\|mp4\|wmv\|avi\)'
RateAbbr="ntsc|pal|qntsc|qpal|sntsc|spal|film|ntsc-film"
CopyACodec="FLAC|vorbis"
CopyACodec="FLAC|vorbis|flac"
FFmpeg=$(which 'ffmpeg')
Wrapper=$(which 'x264-10bit')
@ -182,18 +182,22 @@ auto_bitrate ()
auto_audio ()
{
local Info="$1"
local OnlyCopy=$(echo "$Info" | grep -Po '($CopyACodec)')
local ABitrate=$(echo "$Info" | sed -r 's/.+ ([0-9]+) kb\/s.*/\1/g')
local Arg="-acodec"
local Codec="codec"
local Bitrate=""
if [[ $ABitrate -lt 128 ]]; then
ABitrate="128"
if ! echo "$Info" | grep -Po "($CopyACodec)"; then
Codec="libvorbis"
Bitrate=$(echo "$Info" | sed -r 's/.+ ([0-9]+) kb\/s.*/\1/g' | grep -Po '[0-9]+ kb/s')
if ! [[ -z $Bitrate ]]; then
if [[ $Bitrate -lt 128 ]]; then
Bitrate="128"
fi
Bitrate="-b:a ${Bitrate}k"
fi
fi
if [[ -z "$OnlyCopy" ]]; then
echo "-acodec libvorbis -b:a ${ABitrate}k"
else
echo "-acodec copy"
fi
echo "$Arg $Codec $Bitrate"
}
# Check FFmpeg and Wrapper
@ -254,6 +258,8 @@ do
# Uncomment for fast debug:
# VCodec="copy"
# For metadata:
# -metadata:s:v language="jpn" -metadata:s:a language="jpn" \
if $Nice $Jobs $Exec \
-i "$InputFile" \