resolution_x, resolution_y

The place for "I can't figure out how to..." questions.
Post Reply
ricks
User
Posts: 3
Joined: Fri Aug 25, 2006 6:34 am

resolution_x, resolution_y

Post by ricks » Fri Aug 25, 2006 6:40 am

Hi everybody,

I want to read out the resolution_x and resolution_y of movies that user upload to my server (MPEG, WMV, MOV). And because this is the first time I have to use third party classes I need some help how to include it into my php script.

I really only need this information of the files. But I have no idea how to start these function when a file is uploaded.

Would be very nice if someone could give me an idea how to implement.

Thanks in advance!

Ricks

jhollin1138
User
Posts: 4
Joined: Mon Jul 18, 2005 2:00 pm
Location: Cleveland, Ohio USA

Post by jhollin1138 » Sat Sep 09, 2006 2:38 am

I'm not sure if you still need help but this is my function I use.

Code: Select all

################# Using getID3 to reterive Video Information ##################
function GetVideoInfo ($strFilePath) {

	// include getID3() library (can be in a different directory if full path is specified)
	include_once(DIR_GETID3.'/getid3.php');
 
	// Initialize getID3 engine
	$getID3 = new getID3;

	// Get information from the file
	$fileinfo = $getID3->analyze($strFilePath);
	getid3_lib::CopyTagsToComments($fileinfo);
 
	// Output results
	$arrVideoInformation = array(); 
	
	//Video Width, 0
	if (!empty($fileinfo['video']['resolution_x']))
	  $arrVideoInformation[0] = $fileinfo['video']['resolution_x'];
	
	//Video Heigth, 1
	if (!empty($fileinfo['video']['resolution_y']))
	  $arrVideoInformation[1] = $fileinfo['video']['resolution_y'];
	
	//Video Format, 2
	if (!empty($fileinfo['fileformat']))
	  $arrVideoInformation[2] = $fileinfo['fileformat'];
	
	//Video Running Time, 3
	if (!empty($fileinfo['playtime_string']))
	  $arrVideoInformation[3] = $fileinfo['playtime_string'];
	
	//Video File Size, 4
	if (!empty($fileinfo['filesize']))
	  $arrVideoInformation[4] = $fileinfo['filesize'];
	
	return $arrVideoInformation;
}
This code not only returns the width and height of a video, it also returns the video format, running time and file size.

To call this function, it would look something like this.

Code: Select all

$arrVideoInfo = spgm_GetVideoInfo($strVideoPath);
Then "$arrVideoInfo[0]" should contain the width and "$arrVideoInfo[1]" should contain the height.

jasonb
User
Posts: 2
Joined: Tue Sep 04, 2007 8:17 am

Post by jasonb » Tue Sep 04, 2007 8:21 am

You cannot always depend on $fileinfo['video']['resolution_x'] and $fileinfo['video']['resolution_y'] for video width and height. For video/x-ms-asf files, the width and height are stored in a different array.

James Heinrich
getID3() v1 developer
Posts: 1477
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Post by James Heinrich » Tue Sep 04, 2007 11:03 am

jasonb wrote:You cannot always depend on $fileinfo['video']['resolution_x'] and $fileinfo['video']['resolution_y'] for video width and height. For video/x-ms-asf files, the width and height are stored in a different array.
getID3 tries to always put something useful in those keys. But be aware that some file formats (especially WMV, RealVideo) often contain multiple video (and audio) streams at varying bitrates and resolutions.

If you're trying to familiarize yourself with the returned data structure (which can get fairly complex) for any file, it may be easiest to examine the file with /demo/demo.browse.php

Post Reply