Skip to content

Instantly share code, notes, and snippets.

@JohannSuarez
Created June 14, 2023 00:36
Show Gist options
  • Save JohannSuarez/8ecc6c6f3eb29d81649d4c9bde2d9138 to your computer and use it in GitHub Desktop.
Save JohannSuarez/8ecc6c6f3eb29d81649d4c9bde2d9138 to your computer and use it in GitHub Desktop.
Split Audio Into Smaller Files
#!/bin/bash
if [ $# -eq 0 ]; then
echo "Usage: $0 <input_song>"
exit 1
fi
input_song="$1"
extension="${input_song##*.}"
if [[ "$extension" != "mp3" && "$extension" != "wav" ]]; then
echo "Unsupported file format. Please provide an MP3 or WAV file."
exit 1
fi
output_format="mp3"
if [ "$extension" = "wav" ]; then
output_format="wav"
fi
ffmpeg -i "$input_song" -f segment -segment_time 10 -codec:a copy output_%03d.$output_format
k
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment