Skip to content

Instantly share code, notes, and snippets.

@kgriffs
Last active March 19, 2024 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kgriffs/8ebb4c32be7391e61a7ee098e9fc331f to your computer and use it in GitHub Desktop.
Save kgriffs/8ebb4c32be7391e61a7ee098e9fc331f to your computer and use it in GitHub Desktop.
Bash script to trip mp3s to one hour in length and convert to AAC
#!/bin/bash
# Set the directory where your MP3 files are located
input_dir="."
# Set the desired output bitrate (in bits per second)
output_bitrate="192k" # Adjust this value as needed
# Loop through each MP3 file in the directory
for file in "$input_dir"/*.mp3; do
# Extract the filename without extension
filename=$(basename -- "$file")
filename_no_ext="${filename%.*}"
# Output filename for the extended AAC file
output_file="${input_dir}/${filename_no_ext}_1_hour.aac"
# Use FFmpeg to extend the MP3 file to one hour with specified output quality and preserve metadata
ffmpeg -i "$file" -t 3600 -c:a aac_at -b:a "$output_bitrate" "$output_file"
done
@kgriffs
Copy link
Author

kgriffs commented Mar 19, 2024

Courtesy of ChatGPT with some tweaking by yours truly. I used this to make shorter versions of some nature recordings I purchased from https://relaxingnaturevideos.gumroad.com.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment