Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get video duration of file hosted on Amazon S3

I'm starting a portal which distributes videos. The idea is to upload the videos to Amazon S3 and gather the necessary data using PHP from my server. So far everything works fine... the only thing I could not manage to get is the duration of the video :-( Could anybody give me a hint on how to accomplish it?

Thanks, Miguel

UPDATE:

I finally opted to do it using FFmpeg. I have already installed FFmpeg on the server and I'm now trying to execute the command in the shell prior to execute it with PHP. I'm passing it the URL from Amazon (I tried both the cloudfront URL and the S3 URL) but it says that there is not such a directory or file. I've seen examples on the web using external files so I expected it to work.

The command I'm using is

ffmpeg -i https://s3-eu-west-1.amazonaws.com/path/to/file.m4v

Is there something I need to configure in order to use external URLs?

like image 663
Michi Avatar asked Nov 14 '22 17:11

Michi


1 Answers

If you don't want to use FFmpeg (or can't install it on your server) another option is to look for the duration in the video file's embedded metadata.

It is usually stored in one or more tags called "Duration" or "PlayDuration".

You can read the embedded metadata from the video file using something like ExifTool and then parse the output for the tags.

like image 104
Martin Wilson Avatar answered Dec 20 '22 05:12

Martin Wilson