How can I get the duration in seconds of a MP4 with VBA in MacOs?

60 Views Asked by At

I want to get the duration of an .mp4 video using VBA in MacOS.

Function GetMP4Length(filePath As String) As Double
    Dim durationOutput As String
    Dim durationInSeconds As Double
    
    ' Invalid procedure call or argument (Error 5)
    durationOutput = MacScript("do shell script ""mdls -name kMDItemDurationSeconds " & "'" & Replace("'/Users/simonsanchez/Downloads/My Folder/my file.mp4'", " ", "\\ ") & "'" & """")
    durationInSeconds = Val(Split(durationOutput, "=")(1))

    GetMP4FileLength = durationInSeconds
End Function

I'm getting the error: Invalid procedure call or argument (Error 5)

This is what I have, I've hard-coded the path as an example.

I've tried running this on ScriptEditor and it works fine.

0

There are 0 best solutions below