Determine Length (in Minutes) of an Audio File - Then Feed to

Hi, thanks in advance for any help, here’s my goal. I’m making a macro to take low-volume MP3 files and triple the volume, to make them more audible. I have most of it done, but need a hint in one area of this if possible.


1 - Drop an MP3 file in a Dropbox folder
2 - This kicks off KM Macro on a remote Mac, to open the file in Quicktime Player
3 - Macro then opens Audio Hijack, and open the session "Triple Volume"
4 - Macro then starts playing the MP3 in Quicktime Player
5 - Audio Hijack simultaneously starts recording the triple-volumed file from Quicktime Player, tripling the volume, and dumping to an MP3 on the Desktop called “FileName_VolumeTripled”.

(so far so good… here’s where I need help)

When the MP3 ends in Quicktime Player, or any approximate time thereafter, I need to tell KM to clean up and close apps - i.e. save the file, close the applications, import into iTunes, etc. I know how to do all those steps, but the problem is that the MP3 files will be of various lengths. So one may be 39 minutes, one 64 minutes, one 10 minutes, etc. So I can’t just put in there “Pause 60 Minutes” or something between the first part and the second parts of the macro because the MP3 duration will vary.

Is there any way to capture the length of an MP3 file, feed that in as a variable X, then tell KM to pause X minutes between parts 1 and part 2 of the Macro?

I looked to Get File Attribute for a way to do this, but I couldn’t come up with anything.

I thought of (and dismissed) the idea of “Prompt for User Input” at the beginning of the Macro where I could put in a variable each time to indicate the number of minutes to run between sections. The reason this won’t work in this case, is that I’ll kick off the Macro by dropping an MP3 in a Dropbox folder, but the actual Macro that does the work will be initiated from a remote Mac, not the Mac at which I’m sitting.

Another idea I had, was that maybe somehow I could have the KM Macro watch Quicktime Player and somehow recognize when the file has stopped playing (like, if Quicktime Condition = “Stopped” or something, which, I realize at this point I’m making stuff up). But I found myself at a dead end there too.

I’d like to avoid AppleScript if at all possible…

Any ideas here? I feel like I’m missing something fairly simple! Thanks --Tim

This page has some insight:
Q: Get durations of audio files

It’ll need to be modified to better suite your purposes.

Edit: just saw you’d like to avoid AppleScript. Whoops!

This might be helpful? I don't script — this was laudably supplied by another forum member (sorry, don't remember — it was c. Sept, 2015). I was able to use it to append the duration of movie files to their file names (which was my goal). The core part could likely be easily adapted.

Note that the variable saved, "MovieDuration", is in seconds, and reports (for me) to two decimal places (e.g.: 647.18).

(Kudos to Peter for making getting and posting images of Actions so easy :blush: .)

1 Like

This will work when run from an Execute a Shell Script action:

mdls -raw -name kMDItemDurationSeconds "<POSIX Path>"

It looks like this job could done much more efficiently with a command-line-tool:

lame --scale 3 Because.mp3 Because_loud.mp3

I use Macports to install such things.