本文整理汇总了PHP中getid3_riff::parseWAVEFORMATex方法的典型用法代码示例。如果您正苦于以下问题:PHP getid3_riff::parseWAVEFORMATex方法的具体用法?PHP getid3_riff::parseWAVEFORMATex怎么用?PHP getid3_riff::parseWAVEFORMATex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类getid3_riff
的用法示例。
在下文中一共展示了getid3_riff::parseWAVEFORMATex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Analyze
//.........这里部分代码省略.........
// 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['offset'] = $NextObjectOffset + $offset;
$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'] & 0x7f;
$StreamPropertiesObjectData['flags']['encrypted'] = (bool) ($StreamPropertiesObjectData['flags_raw'] & 0x8000);
$offset += 4;
// reserved - DWORD
$StreamPropertiesObjectData['type_specific_data'] = substr($ASFHeaderData, $offset, $StreamPropertiesObjectData['type_data_length']);
$offset += $StreamPropertiesObjectData['type_data_length'];
$StreamPropertiesObjectData['error_correct_data'] = substr($ASFHeaderData, $offset, $StreamPropertiesObjectData['error_data_length']);
$offset += $StreamPropertiesObjectData['error_data_length'];
switch ($StreamPropertiesObjectData['stream_type']) {
case GETID3_ASF_Audio_Media:
$thisfile_audio['dataformat'] = !empty($thisfile_audio['dataformat']) ? $thisfile_audio['dataformat'] : 'asf';
$thisfile_audio['bitrate_mode'] = !empty($thisfile_audio['bitrate_mode']) ? $thisfile_audio['bitrate_mode'] : 'cbr';
$audiodata = getid3_riff::parseWAVEFORMATex(substr($StreamPropertiesObjectData['type_specific_data'], 0, 16));
unset($audiodata['raw']);
$thisfile_audio = getid3_lib::array_merge_noclobber($audiodata, $thisfile_audio);
break;
case GETID3_ASF_Video_Media:
$thisfile_video['dataformat'] = !empty($thisfile_video['dataformat']) ? $thisfile_video['dataformat'] : 'asf';
$thisfile_video['bitrate_mode'] = !empty($thisfile_video['bitrate_mode']) ? $thisfile_video['bitrate_mode'] : 'cbr';
break;
case GETID3_ASF_Command_Media:
default:
// do nothing
break;
}
$thisfile_asf['stream_properties_object'][$StreamPropertiesObjectStreamNumber] = $StreamPropertiesObjectData;
unset($StreamPropertiesObjectData);
// clear for next stream, if any
break;
case GETID3_ASF_Header_Extension_Object:
// Header Extension Object: (mandatory, one only)
// Field Name Field Type Size (bits)
// Object ID GUID 128 // GUID for Header Extension object - GETID3_ASF_Header_Extension_Object
// Object Size QWORD 64 // size of Header Extension object, including 46 bytes of Header Extension Object header
// Reserved Field 1 GUID 128 // hardcoded: GETID3_ASF_Reserved_1
// Reserved Field 2 WORD 16 // hardcoded: 0x00000006
// Header Extension Data Size DWORD 32 // in bytes. valid: 0, or > 24. equals object size minus 46
// Header Extension Data BYTESTREAM variable // array of zero or more extended header objects
// shortcut
$thisfile_asf['header_extension_object'] = array();
$thisfile_asf_headerextensionobject =& $thisfile_asf['header_extension_object'];
$thisfile_asf_headerextensionobject['offset'] = $NextObjectOffset + $offset;
$thisfile_asf_headerextensionobject['objectid'] = $NextObjectGUID;
$thisfile_asf_headerextensionobject['objectid_guid'] = $NextObjectGUIDtext;
$thisfile_asf_headerextensionobject['objectsize'] = $NextObjectSize;
开发者ID:richardbota,项目名称:WordPress-Theme-Development-with-Bootstrap,代码行数:67,代码来源:module.audio-video.asf.php
示例2: Analyze
//.........这里部分代码省略.........
}
if (!empty($getid3_temp->info['warning'])) {
foreach ($getid3_temp->info['warning'] as $newerror) {
$this->warning($class . '() says: [' . $newerror . ']');
}
}
unset($getid3_temp, $getid3_audio);
break;
case 'A_AAC':
case 'A_AAC/MPEG2/LC':
case 'A_AAC/MPEG2/LC/SBR':
case 'A_AAC/MPEG4/LC':
case 'A_AAC/MPEG4/LC/SBR':
$this->warning($trackarray['CodecID'] . ' audio data contains no header, audio/video bitrates can\'t be calculated');
break;
case 'A_VORBIS':
if (!isset($trackarray['CodecPrivate'])) {
$this->warning('Unable to parse audio data [' . basename(__FILE__) . ':' . __LINE__ . '] because CodecPrivate data not set');
break;
}
$vorbis_offset = strpos($trackarray['CodecPrivate'], 'vorbis', 1);
if ($vorbis_offset === false) {
$this->warning('Unable to parse audio data [' . basename(__FILE__) . ':' . __LINE__ . '] because CodecPrivate data does not contain "vorbis" keyword');
break;
}
$vorbis_offset -= 1;
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'module.audio.ogg.php', __FILE__, true);
// create temp instance
$getid3_temp = new getID3();
// analyze
$getid3_ogg = new getid3_ogg($getid3_temp);
$oggpageinfo['page_seqno'] = 0;
$getid3_ogg->ParseVorbisPageHeader($trackarray['CodecPrivate'], $vorbis_offset, $oggpageinfo);
if (!empty($getid3_temp->info['ogg'])) {
$info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $getid3_temp->info['ogg'];
if (isset($getid3_temp->info['audio']) && is_array($getid3_temp->info['audio'])) {
foreach ($getid3_temp->info['audio'] as $key => $value) {
$track_info[$key] = $value;
}
}
}
// copy errors and warnings
if (!empty($getid3_temp->info['error'])) {
foreach ($getid3_temp->info['error'] as $newerror) {
$this->warning('getid3_ogg() says: [' . $newerror . ']');
}
}
if (!empty($getid3_temp->info['warning'])) {
foreach ($getid3_temp->info['warning'] as $newerror) {
$this->warning('getid3_ogg() says: [' . $newerror . ']');
}
}
if (!empty($getid3_temp->info['ogg']['bitrate_nominal'])) {
$track_info['bitrate'] = $getid3_temp->info['ogg']['bitrate_nominal'];
}
unset($getid3_temp, $getid3_ogg, $oggpageinfo, $vorbis_offset);
break;
case 'A_MS/ACM':
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'module.audio-video.riff.php', __FILE__, true);
$parsed = getid3_riff::parseWAVEFORMATex($trackarray['CodecPrivate']);
foreach ($parsed as $key => $value) {
if ($key != 'raw') {
$track_info[$key] = $value;
}
}
$info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $parsed;
break;
default:
$this->warning('Unhandled audio type "' . (isset($trackarray['CodecID']) ? $trackarray['CodecID'] : '') . '"');
break;
}
$info['audio']['streams'][] = $track_info;
break;
}
}
if (!empty($info['video']['streams'])) {
$info['video'] = self::getDefaultStreamInfo($info['video']['streams']);
}
if (!empty($info['audio']['streams'])) {
$info['audio'] = self::getDefaultStreamInfo($info['audio']['streams']);
}
}
// process attachments
if (isset($info['matroska']['attachments']) && $this->getid3->option_save_attachments !== getID3::ATTACHMENTS_NONE) {
foreach ($info['matroska']['attachments'] as $i => $entry) {
if (strpos($entry['FileMimeType'], 'image/') === 0 && !empty($entry['FileData'])) {
$info['matroska']['comments']['picture'][] = array('data' => $entry['FileData'], 'image_mime' => $entry['FileMimeType'], 'filename' => $entry['FileName']);
}
}
}
// determine mime type
if (!empty($info['video']['streams'])) {
$info['mime_type'] = $info['matroska']['doctype'] == 'webm' ? 'video/webm' : 'video/x-matroska';
} elseif (!empty($info['audio']['streams'])) {
$info['mime_type'] = $info['matroska']['doctype'] == 'webm' ? 'audio/webm' : 'audio/x-matroska';
} elseif (isset($info['mime_type'])) {
unset($info['mime_type']);
}
return true;
}
示例3: Analyze
//.........这里部分代码省略.........
// unsigned long SHNFileByteOffset;
// unsigned long SHNLastBufferReadPosition;
// unsigned short SHNByteGet;
// unsigned short SHNBufferOffset;
// unsigned short SHNFileBitOffset;
// unsigned long SHNGBuffer;
// unsigned short SHNBitShift;
// long CBuf0[3];
// long CBuf1[3];
// long Offset0[4];
// long Offset1[4];
// }TSeekEntry;
$SeekTableData = $this->fread($info['shn']['seektable']['length'] - 16);
$info['shn']['seektable']['entry_count'] = floor(strlen($SeekTableData) / 80);
//$info['shn']['seektable']['entries'] = array();
//$SeekTableOffset = 0;
//for ($i = 0; $i < $info['shn']['seektable']['entry_count']; $i++) {
// $SeekTableEntry['sample_number'] = getid3_lib::LittleEndian2Int(substr($SeekTableData, $SeekTableOffset, 4));
// $SeekTableOffset += 4;
// $SeekTableEntry['shn_file_byte_offset'] = getid3_lib::LittleEndian2Int(substr($SeekTableData, $SeekTableOffset, 4));
// $SeekTableOffset += 4;
// $SeekTableEntry['shn_last_buffer_read_position'] = getid3_lib::LittleEndian2Int(substr($SeekTableData, $SeekTableOffset, 4));
// $SeekTableOffset += 4;
// $SeekTableEntry['shn_byte_get'] = getid3_lib::LittleEndian2Int(substr($SeekTableData, $SeekTableOffset, 2));
// $SeekTableOffset += 2;
// $SeekTableEntry['shn_buffer_offset'] = getid3_lib::LittleEndian2Int(substr($SeekTableData, $SeekTableOffset, 2));
// $SeekTableOffset += 2;
// $SeekTableEntry['shn_file_bit_offset'] = getid3_lib::LittleEndian2Int(substr($SeekTableData, $SeekTableOffset, 2));
// $SeekTableOffset += 2;
// $SeekTableEntry['shn_gbuffer'] = getid3_lib::LittleEndian2Int(substr($SeekTableData, $SeekTableOffset, 4));
// $SeekTableOffset += 4;
// $SeekTableEntry['shn_bit_shift'] = getid3_lib::LittleEndian2Int(substr($SeekTableData, $SeekTableOffset, 2));
// $SeekTableOffset += 2;
// for ($j = 0; $j < 3; $j++) {
// $SeekTableEntry['cbuf0'][$j] = getid3_lib::LittleEndian2Int(substr($SeekTableData, $SeekTableOffset, 4));
// $SeekTableOffset += 4;
// }
// for ($j = 0; $j < 3; $j++) {
// $SeekTableEntry['cbuf1'][$j] = getid3_lib::LittleEndian2Int(substr($SeekTableData, $SeekTableOffset, 4));
// $SeekTableOffset += 4;
// }
// for ($j = 0; $j < 4; $j++) {
// $SeekTableEntry['offset0'][$j] = getid3_lib::LittleEndian2Int(substr($SeekTableData, $SeekTableOffset, 4));
// $SeekTableOffset += 4;
// }
// for ($j = 0; $j < 4; $j++) {
// $SeekTableEntry['offset1'][$j] = getid3_lib::LittleEndian2Int(substr($SeekTableData, $SeekTableOffset, 4));
// $SeekTableOffset += 4;
// }
//
// $info['shn']['seektable']['entries'][] = $SeekTableEntry;
//}
}
}
if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
$info['error'][] = 'PHP running in Safe Mode - backtick operator not available, cannot run shntool to analyze Shorten files';
return false;
}
if (GETID3_OS_ISWINDOWS) {
$RequiredFiles = array('shorten.exe', 'cygwin1.dll', 'head.exe');
foreach ($RequiredFiles as $required_file) {
if (!is_readable(GETID3_HELPERAPPSDIR . $required_file)) {
$info['error'][] = GETID3_HELPERAPPSDIR . $required_file . ' does not exist';
return false;
}
}
$commandline = GETID3_HELPERAPPSDIR . 'shorten.exe -x "' . $info['filenamepath'] . '" - | ' . GETID3_HELPERAPPSDIR . 'head.exe -c 64';
$commandline = str_replace('/', '\\', $commandline);
} else {
static $shorten_present;
if (!isset($shorten_present)) {
$shorten_present = file_exists('/usr/local/bin/shorten') || `which shorten`;
}
if (!$shorten_present) {
$info['error'][] = 'shorten binary was not found in path or /usr/local/bin';
return false;
}
$commandline = (file_exists('/usr/local/bin/shorten') ? '/usr/local/bin/' : '') . 'shorten -x ' . escapeshellarg($info['filenamepath']) . ' - | head -c 64';
}
$output = `{$commandline}`;
if (!empty($output) && substr($output, 12, 4) == 'fmt ') {
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'module.audio-video.riff.php', __FILE__, true);
$fmt_size = getid3_lib::LittleEndian2Int(substr($output, 16, 4));
$DecodedWAVFORMATEX = getid3_riff::parseWAVEFORMATex(substr($output, 20, $fmt_size));
$info['audio']['channels'] = $DecodedWAVFORMATEX['channels'];
$info['audio']['bits_per_sample'] = $DecodedWAVFORMATEX['bits_per_sample'];
$info['audio']['sample_rate'] = $DecodedWAVFORMATEX['sample_rate'];
if (substr($output, 20 + $fmt_size, 4) == 'data') {
$info['playtime_seconds'] = getid3_lib::LittleEndian2Int(substr($output, 20 + 4 + $fmt_size, 4)) / $DecodedWAVFORMATEX['raw']['nAvgBytesPerSec'];
} else {
$info['error'][] = 'shorten failed to decode DATA chunk to expected location, cannot determine playtime';
return false;
}
$info['audio']['bitrate'] = ($info['avdataend'] - $info['avdataoffset']) / $info['playtime_seconds'] * 8;
} else {
$info['error'][] = 'shorten failed to decode file to WAV for parsing';
return false;
}
return true;
}