0

In my application I need to check if a specific video file is in HD format. Can any one suggest how to do this in php?

jogojapan
  • 68,383
  • 11
  • 101
  • 131
Rahul Singh
  • 9
  • 1
  • 3
  • 2
    "HD format" is not really a thing. It's a marketing term that roughly just means any video with a vertical resolution higher than 480 px or so. –  Feb 26 '13 at 07:13
  • 1
    Voting to re-open. The answer shows that this can be answered in a reasonable (and useful!) way even though the term _HD format_ isn't 100% precisely defined. – jogojapan Mar 05 '13 at 02:25

3 Answers3

3

First, you need to define what you want to declare as high definition video. Wikipedia says:

High-definition video is video of higher resolution than is standard. While there is no specific meaning for high-definition, generally any video image with more than 480 horizontal lines (North America) or 570 lines (Europe) is considered high-definition. 720 scan lines is generally the minimum even though many systems greatly exceed that. Images of standard resolution captured at rates faster than normal (60 frames/second North America, 50 fps Europe), by a high-speed camera may be considered high-definition in some contexts.

The wikipedia article also has a table with max. resolutions used on different websites for HD streaming.

Using the PHP extension FFMPEG-PHP you can read the following (among others) values to determine resolution and bitrate of supported video formats:

$movie = new ffmpeg_movie('movie file.avi');

// how many frames per second?
$frameRate = $movie->getFrameRate();

// how many bits per second, strongly depends on codec (video compression)
$bitRate = $movie->getBitrate();

// height in px
$frameHeight = $movie->getFrameHeight();

// width in px
$frameWidth = $movie->getFrameWidth();
Michel Feldheim
  • 17,625
  • 5
  • 60
  • 77
0

For all HD files that you are looking at, there should be something that is unique about the HD videos that tells them apart of SD videos. Once you get that down pat, in PHP all you have to is check if the file you are looking at contains the "unique" thing.

Jake Smith
  • 9
  • 1
  • 1
  • 7
0

You can try getID3. It's a php media file parser that extracts information such as bitrate, file format, etc...

subroutines
  • 1,458
  • 1
  • 12
  • 16