Added default option for multiple audio channels

This commit is contained in:
Leaced 2023-03-24 17:03:07 +01:00 committed by GitHub
parent 3005a70e6f
commit a7f83a231e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -28,6 +28,12 @@ echo "extension is $extension"
for file in **/*.@($extension); do for file in **/*.@($extension); do
channels=$(ffprobe "$file" -show_entries stream=channels -select_streams a -of compact=p=0:nk=1 -v 0) channels=$(ffprobe "$file" -show_entries stream=channels -select_streams a -of compact=p=0:nk=1 -v 0)
streams=$(echo "$channels" | wc -l)
if [ streams -gt 1 ]; then
echo "Error: Automatic Bitrate is not supported for files with multiple audiostreams. The default bitrate of 128k will be used"
channels="2"
fi
case $channels in case $channels in
1) bitrate="64k";; 1) bitrate="64k";;
2) bitrate="128k";; 2) bitrate="128k";;
@ -37,7 +43,7 @@ for file in **/*.@($extension); do
esac esac
# https://wiki.xiph.org/Opus_Recommended_Settings # https://wiki.xiph.org/Opus_Recommended_Settings
ffmpeg -threads 4 -v 0 -i "$file" -c:a libopus -b:a $bitrate "${file%.*}.opus" && rm "$file" ffmpeg -threads 4 -v 0 -i "$file" -map 0 -c:a libopus -b:a $bitrate "${file%.*}.opus" && rm "$file"
done done
exit 0 exit 0