tags:

views:

411

answers:

5

Does anybody know a ready-made, reliable way to tell the dimensions (width x height) of a MP4 encoded using the H.264 codec without ffmpeg or similar extensions, in pure PHP?

Thanks for all the answers folks. The bounty is running out and I will not have time to check the offered solutions before it does. I will accept the solution that I feel has the greatest likelihood to work.

A: 

Native PHP does not support anything like this, ffmpeg is only one library that come on my mind.

Nazariy
+1  A: 

What comes to mind:

  • mediainfo a huge project with GUI, but also has a CLI
  • mp4info (part of the seemingly defunct mp4mpeg project) is almost perfect for this
  • ffmpeg although this is overkill for the task. then again, you very well may need it for other tasks
Stu Thompson
+1  A: 

getID3 is pure php and extracts an amazing amount of information from media files of all sorts. It will depend on what encoded your file in the first place as to what metadata is available and how reliable it is. getID3 has a nice demo page with lots of different file types. I tried to post more links but as a newbie I only get one.

Bobbin
Thanks for the link, but as far as I can see, getID3 doesn't do MP4.
Pekka
On the demo page (http://www.getid3.org/demo/) there are two .mp4 files e.g. http://www.getid3.org/demo/MP4%20-%20aac.mp4.html. As I mentioned it will depend on what was used to encode your mp4, if it was Quicktime I bet getID3 would work. Without more information or an example file it is difficult to tell. What encoded your file?
Bobbin
+2  A: 

It sounds like http://code.google.com/p/php-mp4info/ might be your answer. It reads MP4's but it doesn't mention anything about H.264.

also, what OS are you using?

Ramblingwood
Wow, this looks good! Chances are that the dimensions are stored in the metadata no matter what encoding is used. I will take a look into that. The site will be running on Linux.
Pekka
the only place I see this falling short is if a video doesn't have the metadata properly emebeded.
Ramblingwood
See my edited question above.
Pekka
Good luck. If you get it figured out would you mine posting it here?
Ramblingwood
+1  A: 

ffmpeg and php: http://www.lampdeveloper.co.uk/linux/detecting-a-videos-dimensions-using-php-and-ffmpeg.html

Steve Graham
the question mentions "without ffmpeg" :)
Gregory Pakosz
whoops. i clearly misread the question!
Steve Graham