0

Any ideas how this can be done? I use flv & mp4 video, so both options are welcome.

I had an idea to calculate bitrate per second against file size of a video what is my last option but hope there is better solution.

Thx.

Xfile
  • 674
  • 8
  • 19
  • bitrate v.s. filesize would only be useful if it was a constant bitrate file. all bets are off when it's a variable bitrate. you could scan the first 'x' blocks and use them as an average, but you'll inevitably get a file where those 'x' blocks were the outliers. – Marc B Jan 03 '13 at 16:42
  • Yeah I know "bitrate v.s. filesize" idea is against variable bitrate videos produced (it will calculate somewhat incorrect duration at the end), but just had an idea it would be quickest way (for both files, any type of a file actually including mp3). 5-20 seconds (for a 5 mins web video ie) here and there wouldn't bother anyone I guess. Well.. not much I hope :) – Xfile Jan 03 '13 at 17:10

2 Answers2

0

Sounds like http://code.google.com/p/php-mp4info/ might be the answer. It is a simple PHP class to read MP4 meta data from MP4 based files, such as MP4, M4V and F4V.

user1909426
  • 1,658
  • 8
  • 20
0

You will most likely need a 3rd party class such as GetID3 or an extension like ffmpeg.

$meta= new \getID3();
$file = $meta->analyze($filename);

echo("Duration: ".$file['playtime_string'].
" / Dimensions: ".$file['video']['resolution_x']." wide by ".$file['video']['resolution_y']." tall".
" / Filesize: ".$file['filesize']." bytes<br />");

See How to get video duration, dimension and size in PHP? for more details.

Community
  • 1
  • 1