I've written an AppleScript that will accomplish exactly what I described in my original post. It makes use of
ffmpeg, as suggested in a previous answer by user Allan.
Note: If you do not have
ffmpeg currently installed on your computer, my script is worthless.
ffmpeg via Homebrew. Homebrew is very easy to install; directions can be found at the top of this page (the official Homebrew website).
After installing Homebrew, run these lines individually in Terminal to install
ffmpeg on your system:
brew install ffmpeg
brew link ffmpeg
Now, you will be able to make use of my script.
Notes about my code:
Even though this was not totally necessary for my purposes,
ffmpeg also provides the user with total control over filenames, file types, bit rate, the output directory, etc., which is gravy.
Certain aspects of my script are tailored to my personal preferences (e.g., including the current date in the name of the output directory), so obviously modify the code as you see fit.
I've done my best to include some error handling to catch certain potential errors, but this is obviously far from all-inclusive.
I don't envision myself needing to do this audio splitting task that often, so a simple .scpt file created in Script Editor is fine by me.
It is entirely possible, if laborious, to program a VBR (variable bit rate) encoding option for the resulting files into the script. I chose not to do so because, for my purposes, this ability is not particularly needed. It would be somewhat complicated to write, since not all audio formats can be encoded in VBR (only Opus, Vorbis, MP3, WMA, and AAC audio files can).
Finally, I am 100% certain that the code contains at least some shortcomings, blind spots, and/or bugs, so I apologize in advance.
I am not able to paste the entire script directly in this answer. The length of the code exceeds the maximum character limit for Stack Exchange answers.
You can view and download the full code on this Pastebin page.
Using the linked script, the user can intuitively split up any audio file into numerous files based on a defined interval, while requiring minimal time and effort from the user.
Note that when the user does not choose the source bit rate as the bit rate for the resulting files, the script can take a while. This is because
ffmpeg is slow at re-encoding. But, fortunately, the user can simply set it, and direct their attention to something else as it completes.
Note that the format of two lines that Allan provided in their answer is incorrect.
After several hours of troubleshooting my AppleScript file, I realized that my AppleScript file was not the issue.
-t reflects the duration of the resulting audio file, not the ending time stamp.
Allan's sample code should read:
$ 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
Here is the relevant passage from the
-t duration (input/output)
When used as an output option (before an output url), stop writing the output after its duration reaches duration.