/ convert-song
convert-song
1 #!/bin/bash 2 # 3 # convert-song - Convert an mp3 file to m4a format with reduced bitrate 4 # 5 # Converts an mp3 to an m4a (AAC) and reduces the bitrate to 128 kbps. 6 # Drops video streams (useful for mp3s with embedded artwork). 7 # 8 # Usage: convert-song <input.mp3> 9 # 10 # Requirements: ffmpeg 11 12 set -euo pipefail 13 14 input="$1" 15 if ! [ -r "$input" ]; then 16 if ! [ -z "$input" ]; then 17 echo "[error] File not found: $input" 18 else 19 echo "usage: $0 <input mp3>" 20 echo 21 echo "Converts an mp3 to an m4a (AAC) and reduces the bitrate to 128 kbps." 22 fi 23 exit 1 24 fi 25 26 # -vn drops video on the floor, required for source mp3s with artwork 27 ffmpeg -i "$input" -vn -c:a aac -b:a 128k "${input%.mp3}.m4a"