Skip to content

Instantly share code, notes, and snippets.

@jmrr
Created October 4, 2016 16:30
Show Gist options
  • Save jmrr/19a8a9da7d6177b2b305fd8ff0ab883a to your computer and use it in GitHub Desktop.
Save jmrr/19a8a9da7d6177b2b305fd8ff0ab883a to your computer and use it in GitHub Desktop.
Raw audio extractor using ffmpeg inspired by @terdon from stackexchange
#!/bin/bash
# Specify destination folder
mkdir -p output
# Select extensions. Videos must be in the current dir
extension=flv
for vid in *.$extension; do
codec="$(ffprobe -v error -select_streams a:0 -show_entries stream=codec_name -print_format csv=p=0 "$vid")"
case "$codec" in
mp3 ) filetype=mp3 ;;
vorbis ) filetype=ogg ;;
* ) filetype= ;;
esac
if [ "$filetype" ]; then
ffmpeg -i "$vid" -vn -acodec copy output/"${vid%.*}"."$filetype"
else
ffmpeg -i "$vid" -vn -acodec libvorbis output/"${vid%.*}".ogg
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment