Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AAC to MP3 conversion for macos #104

Open
lemonhead94 opened this issue May 8, 2024 · 0 comments
Open

AAC to MP3 conversion for macos #104

lemonhead94 opened this issue May 8, 2024 · 0 comments

Comments

@lemonhead94
Copy link

lemonhead94 commented May 8, 2024

For me your way of combining the aac files did not work on macos arm, so I built this little bash script in order to create a single MP3 file.
Maybe it is useful for someone else just leaving this here :)

I also used -af "aresample=44100,lowpass=8000" to fix some of the package losses / audio hickups encountered in the downloaded aac files from scribd/everand

#!/bin/bash

# Define the path
output_name="AUDIOBOOK_NAME"
base_path="/downloads"
aac_path="/downloads/${output_name}"
output_file="/downloads/${output_name}.mp3"

list_file="${base_path}/mylist.txt"
output_aac="${base_path}/output.aac"

touch "${list_file}"

# demux the aac files into a common format
# so that there is no Error during demuxing: Input/output error
mkdir -p "${base_path}/demux"
find "${aac_path}" -name '*.aac' -print0 | xargs -0 -n 1 -P 9 -I {} sh -c '
  f="{}"
  o="/Users/jorit/Desktop/downloads/demux/$(basename "${f}" .aac).mp3"
  faad -o - "${f}" | ffmpeg -i pipe:0 -af 'aresample=44100,lowpass=8000' -c:a libmp3lame "${o}"
'

# Get all .mp3 files, sort them and add to the list file
ls -v "${base_path}"/demux/*.mp3 | sort -V | while IFS= read -r file; do
  printf "file '%s'\n" "${file}"
done > "${list_file}"

echo "Concatenating .aac files into output.mp3..."
# Use ffmpeg to concatenate them
ffmpeg -f concat -safe 0 -i mylist.txt -af "aresample=44100,lowpass=8000" -c:a libmp3lame "${output_name}.mp3"

# Clean up
rm "${list_file}"
rm -rf ./demux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant