2023-03-24 15:14:15 +01:00
|
|
|
#!/bin/bash
|
2023-03-24 11:16:18 +01:00
|
|
|
|
2023-03-24 15:14:15 +01:00
|
|
|
# set shopt-options used by this shell-script
|
|
|
|
# Note, 0 (true) from shopt -q is "false" in a math context.
|
2023-03-24 11:16:18 +01:00
|
|
|
shopt -q globstar; globstar_set=$?
|
|
|
|
((globstar_set)) && shopt -s globstar
|
|
|
|
shopt -q extglob; extglob_set=$?
|
|
|
|
((extglob_set)) && shopt -s extglob
|
|
|
|
|
2023-03-24 15:14:15 +01:00
|
|
|
# return default shopt-options
|
|
|
|
function finish {
|
|
|
|
((globstar_set)) && shopt -u globstar
|
|
|
|
((extglob_set)) && shopt -u extglob
|
|
|
|
}
|
|
|
|
trap finish EXIT
|
2023-03-24 11:16:18 +01:00
|
|
|
|
2023-03-24 15:14:15 +01:00
|
|
|
# setting default extension to all
|
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|
extension="*"
|
|
|
|
else
|
|
|
|
extension=$@
|
|
|
|
fi
|
2023-03-24 11:16:18 +01:00
|
|
|
|
2023-03-24 15:14:15 +01:00
|
|
|
for file in **/*.@(${extension// /|}); do
|
|
|
|
ffmpeg -threads 4 -i $file -c:a libopus -b:a 128k "${file%.*}.opus" && rm "$file"
|
|
|
|
done
|
2023-03-24 11:16:18 +01:00
|
|
|
|
|
|
|
exit 0
|