Created
December 26, 2019 22:26
-
-
Save stesee/509ea73a1de00136e7e72cf486466b07 to your computer and use it in GitHub Desktop.
bash script extracting audio from mp4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#http://askubuntu.com/questions/221026/how-can-i-batch-extract-audio-from-mp4-files-with-ffmpeg-without-decompression#221069 | |
mkdir -p output | |
# current directory has to contain at least one .mp4 file | |
for vid in *.mp4; 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 ;; | |
aac ) filetype=m4a ;; | |
* ) 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