Skip to content

Instantly share code, notes, and snippets.

@dimon4ezzz
Created May 26, 2020 11:44
Show Gist options
  • Save dimon4ezzz/146b0c5449b08918e4f2cc078392485c to your computer and use it in GitHub Desktop.
Save dimon4ezzz/146b0c5449b08918e4f2cc078392485c 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