3

I am using macOS 10.3.6 (High Sierra) and while ago I had a 4 CD box set of some music, ripped the tracks to MP3 and simply stored the files on my system. I had to manually tag and add metadata to each of the 100+ tracks (don’t ask) and I got rid of the original CDs a while ago as well (don’t ask either) so I can’t easily re-rip them.

So here is the problem: Apparently the MP3 tool I used at the time added a fraction of a second “pop” to the beginning of each track. I was unaware—or not paying attention—at the time, but each of the 100+ tracks has that annoying pop right at the beginning of the track.

I read this thread on Stack Overflow, “Click sound at the beginning when using LAME” and while the advice is solid—explaining how sometimes LAME might accidentally encode an audio file’s header as pure audio—the reality is the solutions presented would force me to stream the already encoded MP3 via something like fseek and then re-encode the MP3 (aka: transcode it) which is far from ideal.

So is there any way I could trim about 1/8th of a second off of these already encoded MP3s to get rid of the “pop” and avoid transcoding the MP3s?

I am looking specifically for a relatively simple macOS-based solution that—at most—would only require a new tool (if required) be installed via Homebrew. Not asking for a full script but at least a tool and config tip to point me in the right direction.

Giacomo1968
  • 58,727

1 Answers1

4

Okay, so I managed to solve this using the magic of FFmpeg (which I already have installed on macOS via Homebrew). Specifically the -ss (aka: seeking) parameter coupled with the copy option applied to the audio stream works like a charm! The command can be distilled into this:

ffmpeg -ss 0.125 -i "input.mp3" -acodec copy "output.mp3"

Setting the -ss to 0.125 and then simply specifying input and output with a copy set to the -acodec is all that needs to be done.

And since—as explained in the question—in my case I have 100+ files to deal with I created a simple Bash script that will find all MP3s that should have 1/8th of the opening audio trimmed and dump them in an mp3/ subdirectory. Hope this helps someone in a similar situation!

find -E "path/to/audio/files" -type f -iregex ".*\.(MP3)$" |\
  while read full_audio_filepath
  do
 # Break up the full audio filepath stuff into different directory and filename components.
 audio_dirname=$(dirname "${full_audio_filepath}");
 audio_basename=$(basename "${full_audio_filepath}");
 audio_filename="${audio_basename%.*}";

 # Set the MP3 directory.
 mp3_dirpath="${audio_dirname}/mp3";
 mp3_filepath="${mp3_dirpath}/${audio_filename}.mp3";

 # Create the child MP3 directory.
 mkdir -p "${mp3_dirpath}";

 # And here is where the magic happens.
 ffmpeg -y -v quiet -ss 0.125 -i "$full_audio_filepath" -acodec copy "$mp3_filepath" < /dev/null;

done

Giacomo1968
  • 58,727