Skip to content

Instantly share code, notes, and snippets.

@macmichael01
Last active February 14, 2025 20:25
Show Gist options
  • Select an option

  • Save macmichael01/548d984b1c4af7d2ca41960056ee287e to your computer and use it in GitHub Desktop.

Select an option

Save macmichael01/548d984b1c4af7d2ca41960056ee287e to your computer and use it in GitHub Desktop.
#!/bin/bash
# A simple script that takes an mp4, grabs the audio, and converts to an mp3.
# Toss this script into a directory with mp4 to be converted into audio files.
# Ensure that you have ffmpeg installed located here: https://ffmpeg.org/download.html
# Loop through all MP4 files in the current directory
for file in *.mp4; do
# Check if the file exists (to avoid error if no MP4 files)
if [[ -f "$file" ]]; then
echo "Converting $file to MP3..."
# Extract audio and convert to MP3
ffmpeg -i "$file" -vn -acodec libmp3lame -ab 192k "${file%.mp4}.mp3"
fi
done
echo "Conversion complete."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment