-0.4 C
United States of America
Monday, November 25, 2024

macos – Is there a straightforward approach on a Mac to separate an audio file at outlined intervals?


I’ve written an AppleScript that can accomplish precisely what I described in my authentic put up. It makes use of ffmpeg, as prompt in a earlier reply by consumer Allan.


Notice: In case you would not have ffmpeg at the moment put in in your laptop, my script is nugatory.

I put in ffmpeg by way of Homebrew. Homebrew may be very straightforward to put in; instructions might be discovered on the prime of this web page (the official Homebrew web site).

After putting in Homebrew, run these strains individually in Terminal to put in ffmpeg in your system:

brew set up ffmpeg
brew hyperlink ffmpeg

Now, it is possible for you to to utilize my script.


Notes about my code:

  • Regardless that this was not completely mandatory for my functions, ffmpeg additionally offers the consumer with whole management over filenames, file varieties, bit fee, the output listing, and many others., which is gravy.

  • Sure features of my script are tailor-made to my private preferences (e.g., together with the present date within the identify of the output listing), so clearly modify the code as you see match.

  • I’ve accomplished my greatest to incorporate some error dealing with to catch sure potential errors, however that is clearly removed from all-inclusive.

  • I do not envision myself needing to do that audio splitting job that always, so a easy .scpt file created in Script Editor is ok by me.

    • In case you want to transform this script to a launchable, standalone utility, you’ll be able to simply achieve this in Automator (by inserting a “Run AppleScript” motion into your workflow and pasting the complete code).

      • In that case, you may need to regulate the app in order that the consumer can merely drag the supply audio file onto the app icon to provoke the app (as a substitute of getting to offer the file path of this file in a dialog).
  • It’s solely potential, if laborious, to program a VBR (variable bit fee) encoding possibility for the ensuing information into the script. I selected not to take action as a result of, for my functions, this capability will not be significantly wanted. It might be considerably sophisticated to put in writing, since not all audio codecs might be encoded in VBR (solely Opus, Vorbis, MP3, WMA, and AAC audio information can).

  • Lastly, I’m 100% sure that the code comprises not less than some shortcomings, blind spots, and/or bugs, so I apologize prematurely.


I’m not in a position to paste your entire script straight on this reply. The size of the code exceeds the utmost character restrict for Stack Change solutions.

You possibly can view and obtain the complete code on this Pastebin web page.

Utilizing the linked script, the consumer can intuitively cut up up any audio file into quite a few information based mostly on an outlined interval, whereas requiring minimal effort and time from the consumer.

Notice that when the consumer doesn’t select the supply bit fee because the bit fee for the ensuing information, the script can take some time. It’s because ffmpeg is gradual at re-encoding. However, thankfully, the consumer can merely set it, and direct their consideration to one thing else because it completes.


Notice that the format of two strains that Allan offered of their reply is inaccurate.

After a number of hours of troubleshooting my AppleScript file, I noticed that my AppleScript file was not the problem.

-t displays the length of the ensuing audio file, not the ending time stamp.

Allan’s pattern code ought to learn:

$ ffmpeg -i source_audio_file.mp3 -ss 0 -t 120 segment_1.mp3
$ ffmpeg -i source_audio_file.mp3 -ss 120 -t 120 segment_2.mp3
$ ffmpeg -i source_audio_file.mp3 -ss 240 -t 120 segment_3.mp3

Right here is the related passage from the ffmpeg documentation:

-t length (enter/output)

When used as an output possibility (earlier than an output url), cease writing the output after its length reaches length.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles