⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 module.audio-video.mpeg.php

📁 CMS系统 提供学习研究修改最好了 比流行的一些CMS简单 但是更容易理解 是帮助你学习PHPCMS系统的好东东哦
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php//////////////////////////////////////////////////////////////////// getID3() by James Heinrich <info@getid3.org>               ////  available at http://getid3.sourceforge.net                 ////            or http://www.getid3.org                         ///////////////////////////////////////////////////////////////////// See readme.txt for more details                             /////////////////////////////////////////////////////////////////////                                                             //// module.audio-video.mpeg.php                                 //// module for analyzing MPEG files                             //// dependencies: module.audio.mp3.php                          ////                                                            ////////////////////////////////////////////////////////////////////getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.mp3.php', __FILE__, true);define('GETID3_MPEG_VIDEO_PICTURE_START',   "\x00\x00\x01\x00");define('GETID3_MPEG_VIDEO_USER_DATA_START', "\x00\x00\x01\xB2");define('GETID3_MPEG_VIDEO_SEQUENCE_HEADER', "\x00\x00\x01\xB3");define('GETID3_MPEG_VIDEO_SEQUENCE_ERROR',  "\x00\x00\x01\xB4");define('GETID3_MPEG_VIDEO_EXTENSION_START', "\x00\x00\x01\xB5");define('GETID3_MPEG_VIDEO_SEQUENCE_END',    "\x00\x00\x01\xB7");define('GETID3_MPEG_VIDEO_GROUP_START',     "\x00\x00\x01\xB8");define('GETID3_MPEG_AUDIO_START',           "\x00\x00\x01\xC0");class getid3_mpeg{	function getid3_mpeg(&$fd, &$ThisFileInfo) {		if ($ThisFileInfo['avdataend'] <= $ThisFileInfo['avdataoffset']) {			$ThisFileInfo['error'][] = '"avdataend" ('.$ThisFileInfo['avdataend'].') is unexpectedly less-than-or-equal-to "avdataoffset" ('.$ThisFileInfo['avdataoffset'].')';			return false;		}		$ThisFileInfo['fileformat'] = 'mpeg';		fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);		$MPEGstreamData       = fread($fd, min(100000, $ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']));		$MPEGstreamDataLength = strlen($MPEGstreamData);		$foundVideo = true;		$VideoChunkOffset = 0;		while (substr($MPEGstreamData, $VideoChunkOffset++, 4) !== GETID3_MPEG_VIDEO_SEQUENCE_HEADER) {			if ($VideoChunkOffset >= $MPEGstreamDataLength) {				$foundVideo = false;				break;			}		}		if ($foundVideo) {			// Start code                       32 bits			// horizontal frame size            12 bits			// vertical frame size              12 bits			// pixel aspect ratio                4 bits			// frame rate                        4 bits			// bitrate                          18 bits			// marker bit                        1 bit			// VBV buffer size                  10 bits			// constrained parameter flag        1 bit			// intra quant. matrix flag          1 bit			// intra quant. matrix values      512 bits (present if matrix flag == 1)			// non-intra quant. matrix flag      1 bit			// non-intra quant. matrix values  512 bits (present if matrix flag == 1)			$ThisFileInfo['video']['dataformat'] = 'mpeg';			$VideoChunkOffset += (strlen(GETID3_MPEG_VIDEO_SEQUENCE_HEADER) - 1);			$FrameSizeDWORD = getid3_lib::BigEndian2Int(substr($MPEGstreamData, $VideoChunkOffset, 3));			$VideoChunkOffset += 3;			$AspectRatioFrameRateDWORD = getid3_lib::BigEndian2Int(substr($MPEGstreamData, $VideoChunkOffset, 1));			$VideoChunkOffset += 1;			$assortedinformation = getid3_lib::BigEndian2Bin(substr($MPEGstreamData, $VideoChunkOffset, 4));			$VideoChunkOffset += 4;			$ThisFileInfo['mpeg']['video']['raw']['framesize_horizontal'] = ($FrameSizeDWORD & 0xFFF000) >> 12; // 12 bits for horizontal frame size			$ThisFileInfo['mpeg']['video']['raw']['framesize_vertical']   = ($FrameSizeDWORD & 0x000FFF);       // 12 bits for vertical frame size			$ThisFileInfo['mpeg']['video']['raw']['pixel_aspect_ratio']   = ($AspectRatioFrameRateDWORD & 0xF0) >> 4;			$ThisFileInfo['mpeg']['video']['raw']['frame_rate']           = ($AspectRatioFrameRateDWORD & 0x0F);			$ThisFileInfo['mpeg']['video']['framesize_horizontal'] = $ThisFileInfo['mpeg']['video']['raw']['framesize_horizontal'];			$ThisFileInfo['mpeg']['video']['framesize_vertical']   = $ThisFileInfo['mpeg']['video']['raw']['framesize_vertical'];			$ThisFileInfo['mpeg']['video']['pixel_aspect_ratio']      = $this->MPEGvideoAspectRatioLookup($ThisFileInfo['mpeg']['video']['raw']['pixel_aspect_ratio']);			$ThisFileInfo['mpeg']['video']['pixel_aspect_ratio_text'] = $this->MPEGvideoAspectRatioTextLookup($ThisFileInfo['mpeg']['video']['raw']['pixel_aspect_ratio']);			$ThisFileInfo['mpeg']['video']['frame_rate']              = $this->MPEGvideoFramerateLookup($ThisFileInfo['mpeg']['video']['raw']['frame_rate']);			$ThisFileInfo['mpeg']['video']['raw']['bitrate']                =        getid3_lib::Bin2Dec(substr($assortedinformation,  0, 18));			$ThisFileInfo['mpeg']['video']['raw']['marker_bit']             = (bool) getid3_lib::Bin2Dec(substr($assortedinformation, 18,  1));			$ThisFileInfo['mpeg']['video']['raw']['vbv_buffer_size']        =        getid3_lib::Bin2Dec(substr($assortedinformation, 19, 10));			$ThisFileInfo['mpeg']['video']['raw']['constrained_param_flag'] = (bool) getid3_lib::Bin2Dec(substr($assortedinformation, 29,  1));			$ThisFileInfo['mpeg']['video']['raw']['intra_quant_flag']       = (bool) getid3_lib::Bin2Dec(substr($assortedinformation, 30,  1));			if ($ThisFileInfo['mpeg']['video']['raw']['intra_quant_flag']) {				// read 512 bits				$ThisFileInfo['mpeg']['video']['raw']['intra_quant']          = getid3_lib::BigEndian2Bin(substr($MPEGstreamData, $VideoChunkOffset, 64));				$VideoChunkOffset += 64;				$ThisFileInfo['mpeg']['video']['raw']['non_intra_quant_flag'] = (bool) getid3_lib::Bin2Dec(substr($ThisFileInfo['mpeg']['video']['raw']['intra_quant'], 511,  1));				$ThisFileInfo['mpeg']['video']['raw']['intra_quant']          =        getid3_lib::Bin2Dec(substr($assortedinformation, 31,  1)).substr(getid3_lib::BigEndian2Bin(substr($MPEGstreamData, $VideoChunkOffset, 64)), 0, 511);				if ($ThisFileInfo['mpeg']['video']['raw']['non_intra_quant_flag']) {					$ThisFileInfo['mpeg']['video']['raw']['non_intra_quant'] = substr($MPEGstreamData, $VideoChunkOffset, 64);					$VideoChunkOffset += 64;				}			} else {				$ThisFileInfo['mpeg']['video']['raw']['non_intra_quant_flag'] = (bool) getid3_lib::Bin2Dec(substr($assortedinformation, 31,  1));				if ($ThisFileInfo['mpeg']['video']['raw']['non_intra_quant_flag']) {					$ThisFileInfo['mpeg']['video']['raw']['non_intra_quant'] = substr($MPEGstreamData, $VideoChunkOffset, 64);					$VideoChunkOffset += 64;				}			}			if ($ThisFileInfo['mpeg']['video']['raw']['bitrate'] == 0x3FFFF) { // 18 set bits				$ThisFileInfo['warning'][] = 'This version of getID3() ['.GETID3_VERSION.'] cannot determine average bitrate of VBR MPEG video files';				$ThisFileInfo['mpeg']['video']['bitrate_mode'] = 'vbr';			} else {				$ThisFileInfo['mpeg']['video']['bitrate']      = $ThisFileInfo['mpeg']['video']['raw']['bitrate'] * 400;				$ThisFileInfo['mpeg']['video']['bitrate_mode'] = 'cbr';				$ThisFileInfo['video']['bitrate']              = $ThisFileInfo['mpeg']['video']['bitrate'];			}			$ThisFileInfo['video']['resolution_x']       = $ThisFileInfo['mpeg']['video']['framesize_horizontal'];			$ThisFileInfo['video']['resolution_y']       = $ThisFileInfo['mpeg']['video']['framesize_vertical'];			$ThisFileInfo['video']['frame_rate']         = $ThisFileInfo['mpeg']['video']['frame_rate'];			$ThisFileInfo['video']['bitrate_mode']       = $ThisFileInfo['mpeg']['video']['bitrate_mode'];			$ThisFileInfo['video']['pixel_aspect_ratio'] = $ThisFileInfo['mpeg']['video']['pixel_aspect_ratio'];			$ThisFileInfo['video']['lossless']           = false;			$ThisFileInfo['video']['bits_per_sample']    = 24;		} else {			$ThisFileInfo['error'][] = 'Could not find start of video block in the first 100,000 bytes (or before end of file) - this might not be an MPEG-video file?';		}		//0x000001B3 begins the sequence_header of every MPEG video stream.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -