View Full Version : Get video duration programmatically

Feb 23, 2012, 10:25 PM
I need the duration of a video that the user will provide in a program I'm writing (written in objective-c). Does anyone know a good way to do this? The video's will be in either flv or mp4 format, and I am using ffmpeg in my program already so if anyone knows a trick to get the duration with ffmpeg it would be greatly appreciated. Otherwise any general way of getting the duration would be great.


Feb 24, 2012, 10:16 AM
From googling, looks like you can call it with -i argument, and then it'll output some info including the duration, which you can then parse as a string. You can use NSTask to execute it.