Get video duration programmatically

Discussion in 'Mac Programming' started by Macman1993, Feb 23, 2012.

  1. Macman1993 macrumors 6502


    Nov 23, 2007
    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.

  2. kainjow Moderator emeritus


    Jun 15, 2000
    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.

Share This Page