Advanced Search

Results 1 to 3 of 3

Thread: Determine the Video Duration

  1. #1
    Join Date
    Dec 2007
    Posts
    123
    Thanks
    17
    Thanked 1 Time in 1 Post

    Question Determine the Video Duration

    Hi

    Using PHP, is there anyway we can know the length of a video (not size but duration of the video) that has been uploaded?



    Any help is appreciated.


    Thanks

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,154
    Thanks
    260
    Thanked 690 Times in 678 Posts

    Default

    PHP does not have this feature built in. You can theoretically get the image data and attempt to find out (this would be hard) or you can attempt to use a library that already exists. Using ffmpeg and perhaps some other things you can probably figure out information. There might also be metadata in the file though this could be misleading.

    Of course the simple answer is to check for filesize if you are worried about space, though that won't do much toward telling you how long the video is because there are various formats.

    The real question is what format(s) the video will use. Once you know that, you can start to work out how to handle the information.

    However, as a general warning, this won't be easy. In fact, it might be easier if you can install a program on the server that can read the videos natively then use an exec() command in PHP to ask that program how long the video is.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. The Following User Says Thank You to djr33 For This Useful Post:

    cancer10 (04-13-2011)

  4. #3
    Join Date
    Dec 2007
    Posts
    123
    Thanks
    17
    Thanked 1 Time in 1 Post

    Default

    Quote Originally Posted by djr33 View Post
    PHP does not have this feature built in. You can theoretically get the image data and attempt to find out (this would be hard) or you can attempt to use a library that already exists. Using ffmpeg and perhaps some other things you can probably figure out information. There might also be metadata in the file though this could be misleading.

    Of course the simple answer is to check for filesize if you are worried about space, though that won't do much toward telling you how long the video is because there are various formats.

    The real question is what format(s) the video will use. Once you know that, you can start to work out how to handle the information.

    However, as a general warning, this won't be easy. In fact, it might be easier if you can install a program on the server that can read the videos natively then use an exec() command in PHP to ask that program how long the video is.
    HI djr33

    I see your point.

    Thanks for replying.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •