module.audio-video.riff.php

来自「CMS系统 提供学习研究修改最好了 比流行的一些CMS简单 但是更容易理解 是」· PHP 代码 · 共 1,186 行 · 第 1/5 页

PHP
1,186
字号
					$thisfile_riff_audio['total_samples']    =         getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_COMM_0_data,  2,  4), false);					$thisfile_riff_audio['bits_per_sample']  =         getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_COMM_0_data,  6,  2), true);					$thisfile_riff_audio['sample_rate']      = (int) getid3_lib::BigEndian2Float(substr($thisfile_riff_RIFFsubtype_COMM_0_data,  8, 10));					if ($thisfile_riff[$RIFFsubtype]['COMM'][0]['size'] > 18) {						$thisfile_riff_audio['codec_fourcc'] =                                   substr($thisfile_riff_RIFFsubtype_COMM_0_data, 18,  4);						$CodecNameSize                       =         getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_COMM_0_data, 22,  1), false);						$thisfile_riff_audio['codec_name']   =                                   substr($thisfile_riff_RIFFsubtype_COMM_0_data, 23,  $CodecNameSize);						switch ($thisfile_riff_audio['codec_name']) {							case 'NONE':								$thisfile_audio['codec']    = 'Pulse Code Modulation (PCM)';								$thisfile_audio['lossless'] = true;								break;							case '':								switch ($thisfile_riff_audio['codec_fourcc']) {									// http://developer.apple.com/qa/snd/snd07.html									case 'sowt':										$thisfile_riff_audio['codec_name'] = 'Two\'s Compliment Little-Endian PCM';										$thisfile_audio['lossless'] = true;										break;									case 'twos':										$thisfile_riff_audio['codec_name'] = 'Two\'s Compliment Big-Endian PCM';										$thisfile_audio['lossless'] = true;										break;									default:										break;								}								break;							default:								$thisfile_audio['codec']    = $thisfile_riff_audio['codec_name'];								$thisfile_audio['lossless'] = false;								break;						}					}					$thisfile_audio['channels']        = $thisfile_riff_audio['channels'];					if ($thisfile_riff_audio['bits_per_sample'] > 0) {						$thisfile_audio['bits_per_sample'] = $thisfile_riff_audio['bits_per_sample'];					}					$thisfile_audio['sample_rate']     = $thisfile_riff_audio['sample_rate'];					if ($thisfile_audio['sample_rate'] == 0) {						$ThisFileInfo['error'][] = 'Corrupted AIFF file: sample_rate == zero';						return false;					}					$ThisFileInfo['playtime_seconds'] = $thisfile_riff_audio['total_samples'] / $thisfile_audio['sample_rate'];				}				if (isset($thisfile_riff[$RIFFsubtype]['COMT'])) {					$offset = 0;					$CommentCount                                           = getid3_lib::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, 2), false);					$offset += 2;					for ($i = 0; $i < $CommentCount; $i++) {						$ThisFileInfo['comments_raw'][$i]['timestamp']      = getid3_lib::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, 4), false);						$offset += 4;						$ThisFileInfo['comments_raw'][$i]['marker_id']      = getid3_lib::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, 2), true);						$offset += 2;						$CommentLength                                      = getid3_lib::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, 2), false);						$offset += 2;						$ThisFileInfo['comments_raw'][$i]['comment']        =                           substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, $CommentLength);						$offset += $CommentLength;						$ThisFileInfo['comments_raw'][$i]['timestamp_unix'] = getid3_lib::DateMac2Unix($ThisFileInfo['comments_raw'][$i]['timestamp']);						$thisfile_riff['comments']['comment'][] = $ThisFileInfo['comments_raw'][$i]['comment'];					}				}				$CommentsChunkNames = array('NAME'=>'title', 'author'=>'artist', '(c) '=>'copyright', 'ANNO'=>'comment');				foreach ($CommentsChunkNames as $key => $value) {					if (isset($thisfile_riff[$RIFFsubtype][$key][0]['data'])) {						$thisfile_riff['comments'][$value][] = $thisfile_riff[$RIFFsubtype][$key][0]['data'];					}				}				break;			case '8SVX':				$thisfile_audio['bitrate_mode']    = 'cbr';				$thisfile_audio_dataformat         = '8svx';				$thisfile_audio['bits_per_sample'] = 8;				$thisfile_audio['channels']        = 1; // overridden below, if need be				$ThisFileInfo['mime_type']                = 'audio/x-aiff';				if (isset($thisfile_riff[$RIFFsubtype]['BODY'][0]['offset'])) {					$thisfile_avdataoffset = $thisfile_riff[$RIFFsubtype]['BODY'][0]['offset'] + 8;					$thisfile_avdataend    = $thisfile_avdataoffset + $thisfile_riff[$RIFFsubtype]['BODY'][0]['size'];					if ($thisfile_avdataend > $ThisFileInfo['filesize']) {						$ThisFileInfo['warning'][] = 'Probable truncated AIFF file: expecting '.$thisfile_riff[$RIFFsubtype]['BODY'][0]['size'].' bytes of audio data, only '.($ThisFileInfo['filesize'] - $thisfile_avdataoffset).' bytes found';					}				}				if (isset($thisfile_riff[$RIFFsubtype]['VHDR'][0]['offset'])) {					// shortcut					$thisfile_riff_RIFFsubtype_VHDR_0 = &$thisfile_riff[$RIFFsubtype]['VHDR'][0];					$thisfile_riff_RIFFsubtype_VHDR_0['oneShotHiSamples']  =   getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'],  0, 4));					$thisfile_riff_RIFFsubtype_VHDR_0['repeatHiSamples']   =   getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'],  4, 4));					$thisfile_riff_RIFFsubtype_VHDR_0['samplesPerHiCycle'] =   getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'],  8, 4));					$thisfile_riff_RIFFsubtype_VHDR_0['samplesPerSec']     =   getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 12, 2));					$thisfile_riff_RIFFsubtype_VHDR_0['ctOctave']          =   getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 14, 1));					$thisfile_riff_RIFFsubtype_VHDR_0['sCompression']      =   getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 15, 1));					$thisfile_riff_RIFFsubtype_VHDR_0['Volume']            = getid3_lib::FixedPoint16_16(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 16, 4));					$thisfile_audio['sample_rate'] = $thisfile_riff_RIFFsubtype_VHDR_0['samplesPerSec'];					switch ($thisfile_riff_RIFFsubtype_VHDR_0['sCompression']) {						case 0:							$thisfile_audio['codec']    = 'Pulse Code Modulation (PCM)';							$thisfile_audio['lossless'] = true;							$ActualBitsPerSample               = 8;							break;						case 1:							$thisfile_audio['codec']    = 'Fibonacci-delta encoding';							$thisfile_audio['lossless'] = false;							$ActualBitsPerSample               = 4;							break;						default:							$ThisFileInfo['warning'][] = 'Unexpected sCompression value in 8SVX.VHDR chunk - expecting 0 or 1, found "'.sCompression.'"';							break;					}				}				if (isset($thisfile_riff[$RIFFsubtype]['CHAN'][0]['data'])) {					$ChannelsIndex = getid3_lib::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['CHAN'][0]['data'], 0, 4));					switch ($ChannelsIndex) {						case 6: // Stereo							$thisfile_audio['channels'] = 2;							break;						case 2: // Left channel only						case 4: // Right channel only							$thisfile_audio['channels'] = 1;							break;						default:							$ThisFileInfo['warning'][] = 'Unexpected value in 8SVX.CHAN chunk - expecting 2 or 4 or 6, found "'.$ChannelsIndex.'"';							break;					}				}				$CommentsChunkNames = array('NAME'=>'title', 'author'=>'artist', '(c) '=>'copyright', 'ANNO'=>'comment');				foreach ($CommentsChunkNames as $key => $value) {					if (isset($thisfile_riff[$RIFFsubtype][$key][0]['data'])) {						$thisfile_riff['comments'][$value][] = $thisfile_riff[$RIFFsubtype][$key][0]['data'];					}				}				$thisfile_audio['bitrate'] = $thisfile_audio['sample_rate'] * $ActualBitsPerSample * $thisfile_audio['channels'];				if (!empty($thisfile_audio['bitrate'])) {					$ThisFileInfo['playtime_seconds'] = ($thisfile_avdataend - $thisfile_avdataoffset) / ($thisfile_audio['bitrate'] / 8);				}				break;			case 'CDXA':				$ThisFileInfo['mime_type']      = 'video/mpeg';				if (!empty($thisfile_riff['CDXA']['data'][0]['size'])) {					$GETID3_ERRORARRAY = &$ThisFileInfo['warning'];					if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.mpeg.php', __FILE__, false)) {						$dummy = $ThisFileInfo;						$dummy['error'] = array();						$mpeg_scanner = new getid3_mpeg($fd, $dummy);						if (empty($dummy['error'])) {							$ThisFileInfo['audio']   = $dummy['audio'];							$ThisFileInfo['video']   = $dummy['video'];							$ThisFileInfo['mpeg']    = $dummy['mpeg'];							$ThisFileInfo['warning'] = $dummy['warning'];						}					}				}				break;			default:				$ThisFileInfo['error'][] = 'Unknown RIFF type: expecting one of (WAVE|RMP3|AVI |CDDA|AIFF|AIFC|8SVX|CDXA), found "'.$RIFFsubtype.'" instead';				unset($ThisFileInfo['fileformat']);				break;		}		if (isset($thisfile_riff_WAVE['DISP']) && is_array($thisfile_riff_WAVE['DISP'])) {			$thisfile_riff['comments']['title'][] = trim(substr($thisfile_riff_WAVE['DISP'][count($thisfile_riff_WAVE['DISP']) - 1]['data'], 4));		}		if (isset($thisfile_riff_WAVE['INFO']) && is_array($thisfile_riff_WAVE['INFO'])) {			$RIFFinfoKeyLookup = array(				'IARL'=>'archivallocation',				'IART'=>'artist',				'ICDS'=>'costumedesigner',				'ICMS'=>'commissionedby',				'ICMT'=>'comment',				'ICNT'=>'country',				'ICOP'=>'copyright',				'ICRD'=>'creationdate',				'IDIM'=>'dimensions',				'IDIT'=>'digitizationdate',				'IDPI'=>'resolution',				'IDST'=>'distributor',				'IEDT'=>'editor',				'IENG'=>'engineers',				'IFRM'=>'accountofparts',				'IGNR'=>'genre',				'IKEY'=>'keywords',				'ILGT'=>'lightness',				'ILNG'=>'language',				'IMED'=>'orignalmedium',				'IMUS'=>'composer',				'INAM'=>'title',				'IPDS'=>'productiondesigner',				'IPLT'=>'palette',				'IPRD'=>'product',				'IPRO'=>'producer',				'IPRT'=>'part',				'IRTD'=>'rating',				'ISBJ'=>'subject',				'ISFT'=>'software',				'ISGN'=>'secondarygenre',				'ISHP'=>'sharpness',				'ISRC'=>'sourcesupplier',				'ISRF'=>'digitizationsource',				'ISTD'=>'productionstudio',				'ISTR'=>'starring',				'ITCH'=>'encoded_by',				'IWEB'=>'url',				'IWRI'=>'writer'			);			foreach ($RIFFinfoKeyLookup as $key => $value) {				if (isset($thisfile_riff_WAVE['INFO'][$key])) {					foreach ($thisfile_riff_WAVE['INFO'][$key] as $commentid => $commentdata) {						if (trim($commentdata['data']) != '') {							$thisfile_riff['comments'][$value][] = trim($commentdata['data']);						}					}				}			}

⌨️ 快捷键说明

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