You can use
which will return the length in milliseconds. You can use
to turn that into seconds. Finally, you can use
to return a more readable output.Note
: The $sound documentation says that the file should be mp3, ogg, or wma, but I have tested this with an mp4 and it has return the correct value. So, I would recommend looking up some dll or other alternatives, if this does not work for you.