Skip to content

Instantly share code, notes, and snippets.

@Bioblaze
Forked from dimon4ezzz/mp4-to-mp3-extractor.sh
Created June 26, 2020 05:26
Show Gist options
  • Save Bioblaze/cf61dc5ce1d26c3b55bdc7faca166235 to your computer and use it in GitHub Desktop.
Save Bioblaze/cf61dc5ce1d26c3b55bdc7faca166235 to your computer and use it in GitHub Desktop.
the script extracts mp4 files to compressed mp3 audio
#!/bin/bash
# all mp4 files in this directory
for file in ./*.mp4; do
# create new mp3 name
audio="${file%.mp4}.mp3"
# if .mp4 is file and .mp3 does not exists
if [ -f $file ] && [ ! -e $audio ]; then
# ffmpeg will convert mp4 to mp3 with the strongest compressing (-q:a 9)
# will show only panic logs
ffmpeg -hide_banner -loglevel panic -i $file -vn -codec:a libmp3lame -q:a 9 $audio
# show done message
echo "extract from $file to $audio is done"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment