Get video duration programmatically

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

  1. macrumors 6502

    Macman1993

    Joined:
    Nov 23, 2007
    #1
    Hi,
    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.

    Thanks
     
  2. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    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