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.


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

     # 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}");

     # Set the MP3 directory.

     # 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;

  • You could simplify this (and speed it up significantly!) by using GNU parallel and recursive globbing with Bash, i.e. run shopt -s globstar and then parallel 'ffmpeg -i {} … {//}/mp3/{/}' ::: **/*.mp3. See the parallel tutorial for what these replacement strings (e.g. {//}) mean. Use the --dry-run option for parallel to show what it would run. – slhck Jul 22 '18 at 17:06
  • @slhck Good tip! To be honest, this process was quite fast for my needs. That said, I will clarify I am on macOS 10.33.6 (High Sierra) but encourage you to post your own variant of an answer using parallel. – JakeGould Jul 22 '18 at 17:20
  • 1
    True, the process is I/O-bound since it's not really encoding anything. I didn't want to post a separate answer since the core of the question is about ffmpeg and not so much about batch processing. PS: Under macOS you can easily install GNU parallel through Homebrew (brew install parallel). – slhck Jul 22 '18 at 17:33
  • @slhck Thanks for the tip! Will investigate. – JakeGould Jul 22 '18 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.