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

📄 module.audio-video.asf.php

📁 一个用PHP编写的
💻 PHP
📖 第 1 页 / 共 5 页
字号:
<?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.asf.php                                  //// module for analyzing ASF, WMA and WMV files                 //// dependencies: module.audio-video.riff.php                   ////                                                            ////////////////////////////////////////////////////////////////////getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true);$GUIDarray = getid3_asf::KnownGUIDs();foreach ($GUIDarray as $GUIDname => $hexstringvalue) {	// initialize all GUID constants	define($GUIDname, getid3_asf::GUIDtoBytestring($hexstringvalue));}class getid3_asf{	function getid3_asf(&$fd, &$ThisFileInfo) {		// Shortcuts		$thisfile_audio = &$ThisFileInfo['audio'];		$thisfile_video = &$ThisFileInfo['video'];		$ThisFileInfo['asf'] = array();		$thisfile_asf        = &$ThisFileInfo['asf'];		$thisfile_asf['comments'] = array();		$thisfile_asf_comments    = &$thisfile_asf['comments'];		$thisfile_asf['header_object'] = array();		$thisfile_asf_headerobject     = &$thisfile_asf['header_object'];		// ASF structure:		// * Header Object [required]		//   * File Properties Object [required]   (global file attributes)		//   * Stream Properties Object [required] (defines media stream & characteristics)		//   * Header Extension Object [required]  (additional functionality)		//   * Content Description Object          (bibliographic information)		//   * Script Command Object               (commands for during playback)		//   * Marker Object                       (named jumped points within the file)		// * Data Object [required]		//   * Data Packets		// * Index Object		// Header Object: (mandatory, one only)		// Field Name                   Field Type   Size (bits)		// Object ID                    GUID         128             // GUID for header object - GETID3_ASF_Header_Object		// Object Size                  QWORD        64              // size of header object, including 30 bytes of Header Object header		// Number of Header Objects     DWORD        32              // number of objects in header object		// Reserved1                    BYTE         8               // hardcoded: 0x01		// Reserved2                    BYTE         8               // hardcoded: 0x02		$ThisFileInfo['fileformat'] = 'asf';		fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);		$HeaderObjectData = fread($fd, 30);		$thisfile_asf_headerobject['objectid']      = substr($HeaderObjectData, 0, 16);		$thisfile_asf_headerobject['objectid_guid'] = $this->BytestringToGUID($thisfile_asf_headerobject['objectid']);		if ($thisfile_asf_headerobject['objectid'] != GETID3_ASF_Header_Object) {			$ThisFileInfo['warning'][] = 'ASF header GUID {'.$this->BytestringToGUID($thisfile_asf_headerobject['objectid']).'} does not match expected "GETID3_ASF_Header_Object" GUID {'.$this->BytestringToGUID(GETID3_ASF_Header_Object).'}';			unset($ThisFileInfo['fileformat']);			unset($ThisFileInfo['asf']);			return false;			break;		}		$thisfile_asf_headerobject['objectsize']    = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 16, 8));		$thisfile_asf_headerobject['headerobjects'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 24, 4));		$thisfile_asf_headerobject['reserved1']     = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 28, 1));		$thisfile_asf_headerobject['reserved2']     = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 29, 1));		//$ASFHeaderData  = $HeaderObjectData;		$ASFHeaderData = fread($fd, $thisfile_asf_headerobject['objectsize'] - 30);		//$offset = 30;		$offset = 0;		for ($HeaderObjectsCounter = 0; $HeaderObjectsCounter < $thisfile_asf_headerobject['headerobjects']; $HeaderObjectsCounter++) {			$NextObjectGUID     = substr($ASFHeaderData, $offset, 16);			$offset += 16;			$NextObjectGUIDtext = $this->BytestringToGUID($NextObjectGUID);			$NextObjectSize = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));			$offset += 8;			switch ($NextObjectGUID) {				case GETID3_ASF_File_Properties_Object:					// File Properties Object: (mandatory, one only)					// Field Name                   Field Type   Size (bits)					// Object ID                    GUID         128             // GUID for file properties object - GETID3_ASF_File_Properties_Object					// Object Size                  QWORD        64              // size of file properties object, including 104 bytes of File Properties Object header					// File ID                      GUID         128             // unique ID - identical to File ID in Data Object					// File Size                    QWORD        64              // entire file in bytes. Invalid if Broadcast Flag == 1					// Creation Date                QWORD        64              // date & time of file creation. Maybe invalid if Broadcast Flag == 1					// Data Packets Count           QWORD        64              // number of data packets in Data Object. Invalid if Broadcast Flag == 1					// Play Duration                QWORD        64              // playtime, in 100-nanosecond units. Invalid if Broadcast Flag == 1					// Send Duration                QWORD        64              // time needed to send file, in 100-nanosecond units. Players can ignore this value. Invalid if Broadcast Flag == 1					// Preroll                      QWORD        64              // time to buffer data before starting to play file, in 1-millisecond units. If <> 0, PlayDuration and PresentationTime have been offset by this amount					// Flags                        DWORD        32              //					// * Broadcast Flag             bits         1  (0x01)       // file is currently being written, some header values are invalid					// * Seekable Flag              bits         1  (0x02)       // is file seekable					// * Reserved                   bits         30 (0xFFFFFFFC) // reserved - set to zero					// Minimum Data Packet Size     DWORD        32              // in bytes. should be same as Maximum Data Packet Size. Invalid if Broadcast Flag == 1					// Maximum Data Packet Size     DWORD        32              // in bytes. should be same as Minimum Data Packet Size. Invalid if Broadcast Flag == 1					// Maximum Bitrate              DWORD        32              // maximum instantaneous bitrate in bits per second for entire file, including all data streams and ASF overhead					// shortcut					$thisfile_asf['file_properties_object'] = array();					$thisfile_asf_filepropertiesobject      = &$thisfile_asf['file_properties_object'];					$thisfile_asf_filepropertiesobject['objectid']           = $NextObjectGUID;					$thisfile_asf_filepropertiesobject['objectid_guid']      = $NextObjectGUIDtext;					$thisfile_asf_filepropertiesobject['objectsize']         = $NextObjectSize;					$thisfile_asf_filepropertiesobject['fileid']             = substr($ASFHeaderData, $offset, 16);					$offset += 16;					$thisfile_asf_filepropertiesobject['fileid_guid']        = $this->BytestringToGUID($thisfile_asf_filepropertiesobject['fileid']);					$thisfile_asf_filepropertiesobject['filesize']           = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));					$offset += 8;					$thisfile_asf_filepropertiesobject['creation_date']      = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));					$thisfile_asf_filepropertiesobject['creation_date_unix'] = $this->FILETIMEtoUNIXtime($thisfile_asf_filepropertiesobject['creation_date']);					$offset += 8;					$thisfile_asf_filepropertiesobject['data_packets']       = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));					$offset += 8;					$thisfile_asf_filepropertiesobject['play_duration']      = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));					$offset += 8;					$thisfile_asf_filepropertiesobject['send_duration']      = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));					$offset += 8;					$thisfile_asf_filepropertiesobject['preroll']            = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));					$offset += 8;					$ThisFileInfo['playtime_seconds'] = ($thisfile_asf_filepropertiesobject['play_duration'] / 10000000) - ($thisfile_asf_filepropertiesobject['preroll'] / 1000);					$thisfile_asf_filepropertiesobject['flags_raw']          = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));					$offset += 4;					$thisfile_asf_filepropertiesobject['flags']['broadcast'] = (bool) ($thisfile_asf_filepropertiesobject['flags_raw'] & 0x0001);					$thisfile_asf_filepropertiesobject['flags']['seekable']  = (bool) ($thisfile_asf_filepropertiesobject['flags_raw'] & 0x0002);					$thisfile_asf_filepropertiesobject['min_packet_size']    = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));					$offset += 4;					$thisfile_asf_filepropertiesobject['max_packet_size']    = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));					$offset += 4;					$thisfile_asf_filepropertiesobject['max_bitrate']        = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));					$offset += 4;					//$ThisFileInfo['bitrate']                                 = $thisfile_asf_filepropertiesobject['max_bitrate'];					$ThisFileInfo['bitrate']                                 = ($thisfile_asf_filepropertiesobject['filesize'] * 8) / $ThisFileInfo['playtime_seconds'];					break;				case GETID3_ASF_Stream_Properties_Object:					// Stream Properties Object: (mandatory, one per media stream)					// Field Name                   Field Type   Size (bits)					// Object ID                    GUID         128             // GUID for stream properties object - GETID3_ASF_Stream_Properties_Object					// Object Size                  QWORD        64              // size of stream properties object, including 78 bytes of Stream Properties Object header					// Stream Type                  GUID         128             // GETID3_ASF_Audio_Media, GETID3_ASF_Video_Media or GETID3_ASF_Command_Media					// Error Correction Type        GUID         128             // GETID3_ASF_Audio_Spread for audio-only streams, GETID3_ASF_No_Error_Correction for other stream types					// Time Offset                  QWORD        64              // 100-nanosecond units. typically zero. added to all timestamps of samples in the stream					// Type-Specific Data Length    DWORD        32              // number of bytes for Type-Specific Data field					// Error Correction Data Length DWORD        32              // number of bytes for Error Correction Data field					// Flags                        WORD         16              //					// * Stream Number              bits         7 (0x007F)      // number of this stream.  1 <= valid <= 127					// * Reserved                   bits         8 (0x7F80)      // reserved - set to zero					// * Encrypted Content Flag     bits         1 (0x8000)      // stream contents encrypted if set					// Reserved                     DWORD        32              // reserved - set to zero					// Type-Specific Data           BYTESTREAM   variable        // type-specific format data, depending on value of Stream Type					// Error Correction Data        BYTESTREAM   variable        // error-correction-specific format data, depending on value of Error Correct Type					// There is one GETID3_ASF_Stream_Properties_Object for each stream (audio, video) but the					// stream number isn't known until halfway through decoding the structure, hence it					// it is decoded to a temporary variable and then stuck in the appropriate index later					$StreamPropertiesObjectData['objectid']           = $NextObjectGUID;					$StreamPropertiesObjectData['objectid_guid']      = $NextObjectGUIDtext;					$StreamPropertiesObjectData['objectsize']         = $NextObjectSize;					$StreamPropertiesObjectData['stream_type']        = substr($ASFHeaderData, $offset, 16);					$offset += 16;					$StreamPropertiesObjectData['stream_type_guid']   = $this->BytestringToGUID($StreamPropertiesObjectData['stream_type']);					$StreamPropertiesObjectData['error_correct_type'] = substr($ASFHeaderData, $offset, 16);					$offset += 16;					$StreamPropertiesObjectData['error_correct_guid'] = $this->BytestringToGUID($StreamPropertiesObjectData['error_correct_type']);					$StreamPropertiesObjectData['time_offset']        = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));					$offset += 8;					$StreamPropertiesObjectData['type_data_length']   = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));					$offset += 4;					$StreamPropertiesObjectData['error_data_length']  = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));					$offset += 4;					$StreamPropertiesObjectData['flags_raw']          = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));					$offset += 2;					$StreamPropertiesObjectStreamNumber               = $StreamPropertiesObjectData['flags_raw'] & 0x007F;					$StreamPropertiesObjectData['flags']['encrypted'] = (bool) ($StreamPropertiesObjectData['flags_raw'] & 0x8000);

⌨️ 快捷键说明

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