27 lines
794 B
Bash
Executable File
27 lines
794 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# evaluate options through given arguments
|
|
file_suffix=
|
|
map=
|
|
while [[ $# > 0 ]]; do
|
|
case $1 in
|
|
-t | --type) file_suffix=$2; shift 2;;
|
|
-map ) map='-map 0:0'; shift;;
|
|
* ) break ;; # Anything else stops command line processing.
|
|
esac
|
|
done
|
|
|
|
# ensure existence of destination folder
|
|
dir="$(pwd)"
|
|
dest=${dir%/*}/${dir##*/}_ogg
|
|
if [[ !(-d $dest) ]]; then
|
|
mkdir "$dest"
|
|
fi
|
|
|
|
for file in ./*.$file_suffix; do
|
|
# `-vbr on -application audio` should be default, but let's be sure
|
|
echo "ffmpeg -i '$file' -c:a libopus -b:a 64k -vbr on -application audio $map '$dest/${file%$file_suffix}ogg'";
|
|
ffmpeg -i "$file" -c:a libopus -b:a 64k -vbr on -application audio $map "$dest/${file%$file_suffix}ogg";
|
|
done
|