scripts/ffmpeg_extract_audio.sh

20 lines
520 B
Bash
Raw Normal View History

2024-02-05 10:02:13 +01:00
#!/bin/sh
REC=0
if [[ "$1" == "-r" ]];
then
shift;
[[ ! -d "$1" ]] \
&& echo "Recursive mode argument must be a directory" \
&& exit -1
find "$1" -type f -exec $0 {} \;
else
IN="$1";
[[ ! -f "$IN" ]] && echo "$IN is not a file. Skipping." && exit -1;
OUT=${2:-$(echo "$1"|sed 's/\.[^\.]*$/\.mp3/')}
[[ -e "$OUT" ]] && echo "$OUT already exists. Skipping." && exit -1;
echo "$IN -> $OUT";
ffmpeg -i "$IN" -vn -ar 44100 -ac 2 -ab 192k -f mp3 "$OUT" > /dev/null 2>&1;
fi
exit 0