Last active
March 19, 2024 17:28
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.