本文整理汇总了PHP中getid3_riff类的典型用法代码示例。如果您正苦于以下问题:PHP getid3_riff类的具体用法?PHP getid3_riff怎么用?PHP getid3_riff使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了getid3_riff类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Analyze
public function Analyze()
{
$getid3 = $this->getid3;
$getid3->include_module('audio-video.riff');
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
$shn_header = fread($getid3->fp, 8);
// Magic bytes: "ajkg"
$getid3->info['fileformat'] = 'shn';
$getid3->info['audio']['dataformat'] = 'shn';
$getid3->info['audio']['lossless'] = true;
$getid3->info['audio']['bitrate_mode'] = 'vbr';
$getid3->info['shn']['version'] = getid3_lib::LittleEndian2Int($shn_header[4]);
fseek($getid3->fp, $getid3->info['avdataend'] - 12, SEEK_SET);
$seek_table_signature_test = fread($getid3->fp, 12);
$getid3->info['shn']['seektable']['present'] = (bool) (substr($seek_table_signature_test, 4, 8) == 'SHNAMPSK');
if ($getid3->info['shn']['seektable']['present']) {
$getid3->info['shn']['seektable']['length'] = getid3_lib::LittleEndian2Int(substr($seek_table_signature_test, 0, 4));
$getid3->info['shn']['seektable']['offset'] = $getid3->info['avdataend'] - $getid3->info['shn']['seektable']['length'];
fseek($getid3->fp, $getid3->info['shn']['seektable']['offset'], SEEK_SET);
$seek_table_magic = fread($getid3->fp, 4);
if ($seek_table_magic != 'SEEK') {
throw new getid3_exception('Expecting "SEEK" at offset ' . $getid3->info['shn']['seektable']['offset'] . ', found "' . $seek_table_magic . '"');
}
$seek_table_data = fread($getid3->fp, $getid3->info['shn']['seektable']['length'] - 16);
$getid3->info['shn']['seektable']['entry_count'] = floor(strlen($seek_table_data) / 80);
}
$commandline = 'shorten -x ' . escapeshellarg(realpath($getid3->filename)) . ' - | head -c 64';
$output = `{$commandline}`;
if (@$output && substr($output, 12, 4) == 'fmt ') {
$fmt_size = getid3_lib::LittleEndian2Int(substr($output, 16, 4));
$decoded_wav_format_ex = getid3_riff::RIFFparseWAVEFORMATex(substr($output, 20, $fmt_size));
$getid3->info['audio']['channels'] = $decoded_wav_format_ex['channels'];
$getid3->info['audio']['bits_per_sample'] = $decoded_wav_format_ex['bits_per_sample'];
$getid3->info['audio']['sample_rate'] = $decoded_wav_format_ex['sample_rate'];
if (substr($output, 20 + $fmt_size, 4) == 'data') {
$getid3->info['playtime_seconds'] = getid3_lib::LittleEndian2Int(substr($output, 20 + 4 + $fmt_size, 4)) / $decoded_wav_format_ex['raw']['nAvgBytesPerSec'];
} else {
throw new getid3_exception('shorten failed to decode DATA chunk to expected location, cannot determine playtime');
}
$getid3->info['audio']['bitrate'] = ($getid3->info['avdataend'] - $getid3->info['avdataoffset']) / $getid3->info['playtime_seconds'] * 8;
} else {
throw new getid3_exception('shorten failed to decode file to WAV for parsing');
return false;
}
return true;
}
示例2: ParseRIFFdata
public function ParseRIFFdata(&$RIFFdata)
{
$info =& $this->getid3->info;
if ($RIFFdata) {
$tempfile = tempnam(GETID3_TEMP_DIR, 'getID3');
$fp_temp = fopen($tempfile, 'wb');
$RIFFdataLength = strlen($RIFFdata);
$NewLengthString = getid3_lib::LittleEndian2String($RIFFdataLength, 4);
for ($i = 0; $i < 4; $i++) {
$RIFFdata[$i + 4] = $NewLengthString[$i];
}
fwrite($fp_temp, $RIFFdata);
fclose($fp_temp);
$getid3_temp = new getID3();
$getid3_temp->openfile($tempfile);
$getid3_temp->info['filesize'] = $RIFFdataLength;
$getid3_temp->info['filenamepath'] = $info['filenamepath'];
$getid3_temp->info['tags'] = $info['tags'];
$getid3_temp->info['warning'] = $info['warning'];
$getid3_temp->info['error'] = $info['error'];
$getid3_temp->info['comments'] = $info['comments'];
$getid3_temp->info['audio'] = isset($info['audio']) ? $info['audio'] : array();
$getid3_temp->info['video'] = isset($info['video']) ? $info['video'] : array();
$getid3_riff = new getid3_riff($getid3_temp);
$getid3_riff->Analyze();
$info['riff'] = $getid3_temp->info['riff'];
$info['warning'] = $getid3_temp->info['warning'];
$info['error'] = $getid3_temp->info['error'];
$info['tags'] = $getid3_temp->info['tags'];
$info['comments'] = $getid3_temp->info['comments'];
unset($getid3_riff, $getid3_temp);
unlink($tempfile);
}
return false;
}
示例3: Analyze
public function Analyze()
{
$info =& $this->getid3->info;
// parse container
try {
$this->parseEBML($info);
} catch (Exception $e) {
$info['error'][] = 'EBML parser: ' . $e->getMessage();
}
// calculate playtime
if (isset($info['matroska']['info']) && is_array($info['matroska']['info'])) {
foreach ($info['matroska']['info'] as $key => $infoarray) {
if (isset($infoarray['Duration'])) {
// TimecodeScale is how many nanoseconds each Duration unit is
$info['playtime_seconds'] = $infoarray['Duration'] * ((isset($infoarray['TimecodeScale']) ? $infoarray['TimecodeScale'] : 1000000) / 1000000000);
break;
}
}
}
// extract tags
if (isset($info['matroska']['tags']) && is_array($info['matroska']['tags'])) {
foreach ($info['matroska']['tags'] as $key => $infoarray) {
$this->ExtractCommentsSimpleTag($infoarray);
}
}
// process tracks
if (isset($info['matroska']['tracks']['tracks']) && is_array($info['matroska']['tracks']['tracks'])) {
foreach ($info['matroska']['tracks']['tracks'] as $key => $trackarray) {
$track_info = array();
$track_info['dataformat'] = self::CodecIDtoCommonName($trackarray['CodecID']);
$track_info['default'] = isset($trackarray['FlagDefault']) ? $trackarray['FlagDefault'] : true;
if (isset($trackarray['Name'])) {
$track_info['name'] = $trackarray['Name'];
}
switch ($trackarray['TrackType']) {
case 1:
// Video
$track_info['resolution_x'] = $trackarray['PixelWidth'];
$track_info['resolution_y'] = $trackarray['PixelHeight'];
$track_info['display_unit'] = self::displayUnit(isset($trackarray['DisplayUnit']) ? $trackarray['DisplayUnit'] : 0);
$track_info['display_x'] = isset($trackarray['DisplayWidth']) ? $trackarray['DisplayWidth'] : $trackarray['PixelWidth'];
$track_info['display_y'] = isset($trackarray['DisplayHeight']) ? $trackarray['DisplayHeight'] : $trackarray['PixelHeight'];
if (isset($trackarray['PixelCropBottom'])) {
$track_info['crop_bottom'] = $trackarray['PixelCropBottom'];
}
if (isset($trackarray['PixelCropTop'])) {
$track_info['crop_top'] = $trackarray['PixelCropTop'];
}
if (isset($trackarray['PixelCropLeft'])) {
$track_info['crop_left'] = $trackarray['PixelCropLeft'];
}
if (isset($trackarray['PixelCropRight'])) {
$track_info['crop_right'] = $trackarray['PixelCropRight'];
}
if (isset($trackarray['DefaultDuration'])) {
$track_info['frame_rate'] = round(1000000000 / $trackarray['DefaultDuration'], 3);
}
if (isset($trackarray['CodecName'])) {
$track_info['codec'] = $trackarray['CodecName'];
}
switch ($trackarray['CodecID']) {
case 'V_MS/VFW/FOURCC':
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'module.audio-video.riff.php', __FILE__, true);
$parsed = getid3_riff::ParseBITMAPINFOHEADER($trackarray['CodecPrivate']);
$track_info['codec'] = getid3_riff::fourccLookup($parsed['fourcc']);
$info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $parsed;
break;
/*case 'V_MPEG4/ISO/AVC':
$h264['profile'] = getid3_lib::BigEndian2Int(substr($trackarray['CodecPrivate'], 1, 1));
$h264['level'] = getid3_lib::BigEndian2Int(substr($trackarray['CodecPrivate'], 3, 1));
$rn = getid3_lib::BigEndian2Int(substr($trackarray['CodecPrivate'], 4, 1));
$h264['NALUlength'] = ($rn & 3) + 1;
$rn = getid3_lib::BigEndian2Int(substr($trackarray['CodecPrivate'], 5, 1));
$nsps = ($rn & 31);
$offset = 6;
for ($i = 0; $i < $nsps; $i ++) {
$length = getid3_lib::BigEndian2Int(substr($trackarray['CodecPrivate'], $offset, 2));
$h264['SPS'][] = substr($trackarray['CodecPrivate'], $offset + 2, $length);
$offset += 2 + $length;
}
$npps = getid3_lib::BigEndian2Int(substr($trackarray['CodecPrivate'], $offset, 1));
$offset += 1;
for ($i = 0; $i < $npps; $i ++) {
$length = getid3_lib::BigEndian2Int(substr($trackarray['CodecPrivate'], $offset, 2));
$h264['PPS'][] = substr($trackarray['CodecPrivate'], $offset + 2, $length);
$offset += 2 + $length;
}
$info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $h264;
break;*/
}
$info['video']['streams'][] = $track_info;
break;
case 2:
// Audio
$track_info['sample_rate'] = isset($trackarray['SamplingFrequency']) ? $trackarray['SamplingFrequency'] : 8000.0;
$track_info['channels'] = isset($trackarray['Channels']) ? $trackarray['Channels'] : 1;
$track_info['language'] = isset($trackarray['Language']) ? $trackarray['Language'] : 'eng';
if (isset($trackarray['BitDepth'])) {
$track_info['bits_per_sample'] = $trackarray['BitDepth'];
}
//.........这里部分代码省略.........
示例4: Analyze
//.........这里部分代码省略.........
$sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
$sub_subelement_end = $offset + $sub_subelement_length;
switch ($sub_subelement_id) {
case EBML_ID_PIXELWIDTH:
case EBML_ID_PIXELHEIGHT:
case EBML_ID_STEREOMODE:
case EBML_ID_PIXELCROPBOTTOM:
case EBML_ID_PIXELCROPTOP:
case EBML_ID_PIXELCROPLEFT:
case EBML_ID_PIXELCROPRIGHT:
case EBML_ID_DISPLAYWIDTH:
case EBML_ID_DISPLAYHEIGHT:
case EBML_ID_DISPLAYUNIT:
case EBML_ID_ASPECTRATIOTYPE:
$track_entry[$sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
break;
case EBML_ID_FLAGINTERLACED:
$track_entry[$sub_subelement_idname] = (bool) getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
break;
case EBML_ID_GAMMAVALUE:
$track_entry[$sub_subelement_idname] = getid3_lib::BigEndian2Float(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
break;
case EBML_ID_COLOURSPACE:
$track_entry[$sub_subelement_idname] = trim(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length), "");
break;
default:
$this->warnings[] = 'Unhandled track.video element [' . basename(__FILE__) . ':' . __LINE__ . '] (' . $sub_subelement_id . '::' . $sub_subelement_idname . ') at ' . $sub_subelement_offset;
break;
}
$offset = $sub_subelement_end;
}
if (isset($track_entry[$this->EBMLidName(EBML_ID_CODECID)]) && $track_entry[$this->EBMLidName(EBML_ID_CODECID)] == 'V_MS/VFW/FOURCC' && isset($track_entry[$this->EBMLidName(EBML_ID_CODECPRIVATE)])) {
if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'module.audio-video.riff.php', __FILE__, false)) {
$track_entry['codec_private_parsed'] = getid3_riff::ParseBITMAPINFOHEADER($track_entry[$this->EBMLidName(EBML_ID_CODECPRIVATE)]);
} else {
$this->warnings[] = 'Unable to parse codec private data [' . basename(__FILE__) . ':' . __LINE__ . '] because cannot include "module.audio-video.riff.php"';
}
}
break;
case EBML_ID_AUDIO:
while ($offset < $subelement_end) {
$this->EnsureBufferHasEnoughData($EBMLdata, $offset, $EBMLdata_offset);
$sub_subelement_offset = $offset;
$sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
$sub_subelement_idname = $this->EBMLidName($sub_subelement_id);
$sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
$sub_subelement_end = $offset + $sub_subelement_length;
switch ($sub_subelement_id) {
case EBML_ID_CHANNELS:
case EBML_ID_BITDEPTH:
$track_entry[$sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
break;
case EBML_ID_SAMPLINGFREQUENCY:
case EBML_ID_OUTPUTSAMPLINGFREQUENCY:
$track_entry[$sub_subelement_idname] = getid3_lib::BigEndian2Float(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
break;
case EBML_ID_CHANNELPOSITIONS:
$track_entry[$sub_subelement_idname] = trim(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length), "");
break;
default:
$this->warnings[] = 'Unhandled track.audio element [' . basename(__FILE__) . ':' . __LINE__ . '] (' . $sub_subelement_id . '::' . $sub_subelement_idname . ') at ' . $sub_subelement_offset;
break;
}
$offset = $sub_subelement_end;
}
break;
示例5: ParseOptimFROGheader45
//.........这里部分代码省略.........
}
}
}
$ThisFileInfo['audio']['channels'] = $thisfile_ofr_thisblock['channels'];
$ThisFileInfo['audio']['sample_rate'] = $thisfile_ofr_thisblock['sample_rate'];
$ThisFileInfo['audio']['bits_per_sample'] = $this->OptimFROGbitsPerSampleTypeLookup($thisfile_ofr_thisblock['raw']['sample_type']);
break;
case 'COMP':
// unlike other block types, there CAN be multiple COMP blocks
$COMPdata['offset'] = $BlockOffset;
$COMPdata['size'] = $BlockSize;
if ($ThisFileInfo['avdataoffset'] == 0) {
$ThisFileInfo['avdataoffset'] = $BlockOffset;
}
// Only interested in first 14 bytes (only first 12 needed for v4.50 alpha), not actual audio data
$BlockData .= fread($fd, 14);
fseek($fd, $BlockSize - 14, SEEK_CUR);
$COMPdata['crc_32'] = getid3_lib::LittleEndian2Int(substr($BlockData, $offset, 4));
$offset += 4;
$COMPdata['sample_count'] = getid3_lib::LittleEndian2Int(substr($BlockData, $offset, 4));
$offset += 4;
$COMPdata['raw']['sample_type'] = getid3_lib::LittleEndian2Int(substr($BlockData, $offset, 1));
$COMPdata['sample_type'] = $this->OptimFROGsampleTypeLookup($COMPdata['raw']['sample_type']);
$offset += 1;
$COMPdata['raw']['channel_configuration'] = getid3_lib::LittleEndian2Int(substr($BlockData, $offset, 1));
$COMPdata['channel_configuration'] = $this->OptimFROGchannelConfigurationLookup($COMPdata['raw']['channel_configuration']);
$offset += 1;
$COMPdata['raw']['algorithm_id'] = getid3_lib::LittleEndian2Int(substr($BlockData, $offset, 2));
//$COMPdata['algorithm'] = OptimFROGalgorithmNameLookup($COMPdata['raw']['algorithm_id']);
$offset += 2;
if ($ThisFileInfo['ofr']['OFR ']['size'] > 12) {
// OFR 4.504b or higher
$COMPdata['raw']['encoder_id'] = getid3_lib::LittleEndian2Int(substr($BlockData, $offset, 2));
$COMPdata['encoder'] = $this->OptimFROGencoderNameLookup($COMPdata['raw']['encoder_id']);
$offset += 2;
}
if ($COMPdata['crc_32'] == 0x454e4f4e) {
// ASCII value of 'NONE' - placeholder value in v4.50a
$COMPdata['crc_32'] = false;
}
$thisfile_ofr_thisblock[] = $COMPdata;
break;
case 'HEAD':
$thisfile_ofr_thisblock['offset'] = $BlockOffset;
$thisfile_ofr_thisblock['size'] = $BlockSize;
$RIFFdata .= fread($fd, $BlockSize);
break;
case 'TAIL':
$thisfile_ofr_thisblock['offset'] = $BlockOffset;
$thisfile_ofr_thisblock['size'] = $BlockSize;
if ($BlockSize > 0) {
$RIFFdata .= fread($fd, $BlockSize);
}
break;
case 'RECV':
// block contains no useful meta data - simply note and skip
$thisfile_ofr_thisblock['offset'] = $BlockOffset;
$thisfile_ofr_thisblock['size'] = $BlockSize;
fseek($fd, $BlockSize, SEEK_CUR);
break;
case 'APET':
// APEtag v2
$thisfile_ofr_thisblock['offset'] = $BlockOffset;
$thisfile_ofr_thisblock['size'] = $BlockSize;
$ThisFileInfo['warning'][] = 'APEtag processing inside OptimFROG not supported in this version (' . GETID3_VERSION . ') of getID3()';
fseek($fd, $BlockSize, SEEK_CUR);
break;
case 'MD5 ':
// APEtag v2
$thisfile_ofr_thisblock['offset'] = $BlockOffset;
$thisfile_ofr_thisblock['size'] = $BlockSize;
if ($BlockSize == 16) {
$thisfile_ofr_thisblock['md5_binary'] = fread($fd, $BlockSize);
$thisfile_ofr_thisblock['md5_string'] = getid3_lib::PrintHexBytes($thisfile_ofr_thisblock['md5_binary'], true, false, false);
$ThisFileInfo['md5_data_source'] = $thisfile_ofr_thisblock['md5_string'];
} else {
$ThisFileInfo['warning'][] = 'Expecting block size of 16 in "MD5 " chunk, found ' . $BlockSize . ' instead';
fseek($fd, $BlockSize, SEEK_CUR);
}
break;
default:
$thisfile_ofr_thisblock['offset'] = $BlockOffset;
$thisfile_ofr_thisblock['size'] = $BlockSize;
$ThisFileInfo['warning'][] = 'Unhandled OptimFROG block type "' . $BlockName . '" at offset ' . $thisfile_ofr_thisblock['offset'];
fseek($fd, $BlockSize, SEEK_CUR);
break;
}
}
if (isset($ThisFileInfo['ofr']['TAIL']['offset'])) {
$ThisFileInfo['avdataend'] = $ThisFileInfo['ofr']['TAIL']['offset'];
}
$ThisFileInfo['playtime_seconds'] = (double) $ThisFileInfo['ofr']['OFR ']['total_samples'] / ($ThisFileInfo['audio']['channels'] * $ThisFileInfo['audio']['sample_rate']);
$ThisFileInfo['audio']['bitrate'] = ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8 / $ThisFileInfo['playtime_seconds'];
// move the data chunk after all other chunks (if any)
// so that the RIFF parser doesn't see EOF when trying
// to skip over the data chunk
$RIFFdata = substr($RIFFdata, 0, 36) . substr($RIFFdata, 44) . substr($RIFFdata, 36, 8);
getid3_riff::ParseRIFFdata($RIFFdata, $ThisFileInfo);
return true;
}
示例6: parseEBML
//.........这里部分代码省略.........
$track_entry[$subelement['id_name']] = (bool) getid3_lib::BigEndian2Int($subelement['data']);
break;
case EBML_ID_VIDEO:
while ($this->getEBMLelement($sub_subelement, $subelement['end'], true)) {
switch ($sub_subelement['id']) {
case EBML_ID_PIXELWIDTH:
case EBML_ID_PIXELHEIGHT:
case EBML_ID_STEREOMODE:
case EBML_ID_PIXELCROPBOTTOM:
case EBML_ID_PIXELCROPTOP:
case EBML_ID_PIXELCROPLEFT:
case EBML_ID_PIXELCROPRIGHT:
case EBML_ID_DISPLAYWIDTH:
case EBML_ID_DISPLAYHEIGHT:
case EBML_ID_DISPLAYUNIT:
case EBML_ID_ASPECTRATIOTYPE:
$track_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']);
break;
case EBML_ID_FLAGINTERLACED:
$track_entry[$sub_subelement['id_name']] = (bool) getid3_lib::BigEndian2Int($sub_subelement['data']);
break;
case EBML_ID_GAMMAVALUE:
$track_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Float($sub_subelement['data']);
break;
case EBML_ID_COLOURSPACE:
$track_entry[$sub_subelement['id_name']] = getid3_lib::trimNullByte($sub_subelement['data']);
break;
default:
$this->unhandledElement('track.video', __LINE__, $sub_subelement);
}
}
if (isset($track_entry[$this->EBMLidName(EBML_ID_CODECID)]) && $track_entry[$this->EBMLidName(EBML_ID_CODECID)] == 'V_MS/VFW/FOURCC' && isset($track_entry[$this->EBMLidName(EBML_ID_CODECPRIVATE)])) {
if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'module.audio-video.riff.php', __FILE__, false)) {
$track_entry['codec_private_parsed'] = getid3_riff::ParseBITMAPINFOHEADER($track_entry[$this->EBMLidName(EBML_ID_CODECPRIVATE)]);
} else {
$this->getid3->warning('Unable to parse codec private data [' . basename(__FILE__) . ':' . __LINE__ . '] because cannot include "module.audio-video.riff.php"');
}
}
break;
case EBML_ID_AUDIO:
while ($this->getEBMLelement($sub_subelement, $subelement['end'], true)) {
switch ($sub_subelement['id']) {
case EBML_ID_CHANNELS:
case EBML_ID_BITDEPTH:
$track_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']);
break;
case EBML_ID_SAMPLINGFREQUENCY:
case EBML_ID_OUTPUTSAMPLINGFREQUENCY:
$track_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Float($sub_subelement['data']);
break;
case EBML_ID_CHANNELPOSITIONS:
$track_entry[$sub_subelement['id_name']] = getid3_lib::trimNullByte($sub_subelement['data']);
break;
default:
$this->unhandledElement('track.audio', __LINE__, $sub_subelement);
}
}
break;
case EBML_ID_CONTENTENCODINGS:
while ($this->getEBMLelement($sub_subelement, $subelement['end'])) {
switch ($sub_subelement['id']) {
case EBML_ID_CONTENTENCODING:
while ($this->getEBMLelement($sub_sub_subelement, $sub_subelement['end'], array(EBML_ID_CONTENTCOMPRESSION, EBML_ID_CONTENTENCRYPTION))) {
switch ($sub_sub_subelement['id']) {
case EBML_ID_CONTENTENCODINGORDER:
case EBML_ID_CONTENTENCODINGSCOPE:
示例7: RIFFparseWAVEFORMATex
function RIFFparseWAVEFORMATex($WaveFormatExData)
{
// shortcut
$WaveFormatEx['raw'] = array();
$WaveFormatEx_raw =& $WaveFormatEx['raw'];
$WaveFormatEx_raw['wFormatTag'] = getid3_lib::LittleEndian2Int(substr($WaveFormatExData, 0, 2));
$WaveFormatEx_raw['nChannels'] = getid3_lib::LittleEndian2Int(substr($WaveFormatExData, 2, 2));
$WaveFormatEx_raw['nSamplesPerSec'] = getid3_lib::LittleEndian2Int(substr($WaveFormatExData, 4, 4));
$WaveFormatEx_raw['nAvgBytesPerSec'] = getid3_lib::LittleEndian2Int(substr($WaveFormatExData, 8, 4));
$WaveFormatEx_raw['nBlockAlign'] = getid3_lib::LittleEndian2Int(substr($WaveFormatExData, 12, 2));
$WaveFormatEx_raw['wBitsPerSample'] = getid3_lib::LittleEndian2Int(substr($WaveFormatExData, 14, 2));
if (strlen($WaveFormatExData) > 16) {
$WaveFormatEx_raw['cbSize'] = getid3_lib::LittleEndian2Int(substr($WaveFormatExData, 16, 2));
}
$WaveFormatEx['codec'] = getid3_riff::RIFFwFormatTagLookup($WaveFormatEx_raw['wFormatTag']);
$WaveFormatEx['channels'] = $WaveFormatEx_raw['nChannels'];
$WaveFormatEx['sample_rate'] = $WaveFormatEx_raw['nSamplesPerSec'];
$WaveFormatEx['bitrate'] = $WaveFormatEx_raw['nAvgBytesPerSec'] * 8;
$WaveFormatEx['bits_per_sample'] = $WaveFormatEx_raw['wBitsPerSample'];
return $WaveFormatEx;
}
示例8: Analyze
//.........这里部分代码省略.........
// ID_SHAPING_WEIGHTS
// ID_SHAPING_WEIGHTS
case 0x8:
// ID_FLOAT_INFO
// ID_FLOAT_INFO
case 0x9:
// ID_INT32_INFO
// ID_INT32_INFO
case 0xa:
// ID_WV_BITSTREAM
// ID_WV_BITSTREAM
case 0xb:
// ID_WVC_BITSTREAM
// ID_WVC_BITSTREAM
case 0xc:
// ID_WVX_BITSTREAM
// ID_WVX_BITSTREAM
case 0xd:
// ID_CHANNEL_INFO
fseek($this->getid3->fp, $metablock['offset'] + ($metablock['large_block'] ? 4 : 2) + $metablock['size'], SEEK_SET);
break;
default:
$info['warning'][] = 'Unexpected metablock type "0x' . str_pad(dechex($metablock['function_id']), 2, '0', STR_PAD_LEFT) . '" at offset ' . $metablock['offset'];
fseek($this->getid3->fp, $metablock['offset'] + ($metablock['large_block'] ? 4 : 2) + $metablock['size'], SEEK_SET);
break;
}
switch ($metablock['function_id']) {
case 0x21:
// ID_RIFF_HEADER
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'module.audio-video.riff.php', __FILE__, true);
$original_wav_filesize = getid3_lib::LittleEndian2Int(substr($metablock['data'], 4, 4));
$getid3_temp = new getID3();
$getid3_temp->openfile($this->getid3->filename);
$getid3_riff = new getid3_riff($getid3_temp);
$getid3_riff->ParseRIFFdata($metablock['data']);
$metablock['riff'] = $getid3_temp->info['riff'];
$info['audio']['sample_rate'] = $getid3_temp->info['riff']['raw']['fmt ']['nSamplesPerSec'];
unset($getid3_riff, $getid3_temp);
$metablock['riff']['original_filesize'] = $original_wav_filesize;
$info['wavpack']['riff_trailer_size'] = $original_wav_filesize - $metablock['riff']['WAVE']['data'][0]['size'] - $metablock['riff']['header_size'];
$info['playtime_seconds'] = $info['wavpack']['blockheader']['total_samples'] / $info['audio']['sample_rate'];
// Safe RIFF header in case there's a RIFF footer later
$metablockRIFFheader = $metablock['data'];
break;
case 0x22:
// ID_RIFF_TRAILER
$metablockRIFFfooter = $metablockRIFFheader . $metablock['data'];
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'module.audio-video.riff.php', __FILE__, true);
$startoffset = $metablock['offset'] + ($metablock['large_block'] ? 4 : 2);
$getid3_temp = new getID3();
$getid3_temp->openfile($this->getid3->filename);
$getid3_temp->info['avdataend'] = $info['avdataend'];
$getid3_temp->info['fileformat'] = 'riff';
$getid3_riff = new getid3_riff($getid3_temp);
$metablock['riff'] = $getid3_riff->ParseRIFF($startoffset, $startoffset + $metablock['size']);
if (!empty($metablock['riff']['INFO'])) {
$getid3_riff->RIFFcommentsParse($metablock['riff']['INFO'], $metablock['comments']);
$info['tags']['riff'] = $metablock['comments'];
}
unset($getid3_temp, $getid3_riff);
break;
case 0x23:
// ID_REPLAY_GAIN
$info['warning'][] = 'WavPack "Replay Gain" contents not yet handled by getID3() in metablock at offset ' . $metablock['offset'];
break;
case 0x24:
示例9: Analyze
public function Analyze()
{
$info =& $this->getid3->info;
// parse container
try {
$this->parseEBML($info);
} catch (Exception $e) {
$info['error'][] = 'EBML parser: ' . $e->getMessage();
}
// calculate playtime
if (isset($info['matroska']['info']) && is_array($info['matroska']['info'])) {
foreach ($info['matroska']['info'] as $key => $infoarray) {
if (isset($infoarray['Duration'])) {
// TimecodeScale is how many nanoseconds each Duration unit is
$info['playtime_seconds'] = $infoarray['Duration'] * ((isset($infoarray['TimecodeScale']) ? $infoarray['TimecodeScale'] : 1000000) / 1000000000);
break;
}
}
}
// extract tags
if (isset($info['matroska']['tags']) && is_array($info['matroska']['tags'])) {
foreach ($info['matroska']['tags'] as $key => $infoarray) {
$this->ExtractCommentsSimpleTag($infoarray);
}
}
// process tracks
if (isset($info['matroska']['tracks']['tracks']) && is_array($info['matroska']['tracks']['tracks'])) {
foreach ($info['matroska']['tracks']['tracks'] as $key => $trackarray) {
$track_info = array();
$track_info['dataformat'] = self::MatroskaCodecIDtoCommonName($trackarray['CodecID']);
$track_info['default'] = isset($trackarray['FlagDefault']) ? $trackarray['FlagDefault'] : true;
if (isset($trackarray['Name'])) {
$track_info['name'] = $trackarray['Name'];
}
switch ($trackarray['TrackType']) {
case 1:
// Video
$track_info['resolution_x'] = $trackarray['PixelWidth'];
$track_info['resolution_y'] = $trackarray['PixelHeight'];
if (isset($trackarray['DisplayWidth'])) {
$track_info['display_x'] = $trackarray['DisplayWidth'];
}
if (isset($trackarray['DisplayHeight'])) {
$track_info['display_y'] = $trackarray['DisplayHeight'];
}
if (isset($trackarray['DefaultDuration'])) {
$track_info['frame_rate'] = round(1000000000 / $trackarray['DefaultDuration'], 3);
}
//if (isset($trackarray['CodecName'])) { $track_info['codec'] = $trackarray['CodecName']; }
switch ($trackarray['CodecID']) {
case 'V_MS/VFW/FOURCC':
if (!getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'module.audio-video.riff.php', __FILE__, false)) {
$this->getid3->warning('Unable to parse codec private data [' . basename(__FILE__) . ':' . __LINE__ . '] because cannot include "module.audio-video.riff.php"');
break;
}
$parsed = getid3_riff::ParseBITMAPINFOHEADER($trackarray['CodecPrivate']);
$track_info['codec'] = getid3_riff::RIFFfourccLookup($parsed['fourcc']);
$info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $parsed;
break;
}
$info['video']['streams'][] = $track_info;
break;
case 2:
// Audio
$track_info['sample_rate'] = isset($trackarray['SamplingFrequency']) ? $trackarray['SamplingFrequency'] : 8000.0;
$track_info['channels'] = isset($trackarray['Channels']) ? $trackarray['Channels'] : 1;
$track_info['language'] = isset($trackarray['Language']) ? $trackarray['Language'] : 'eng';
if (isset($trackarray['BitDepth'])) {
$track_info['bits_per_sample'] = $trackarray['BitDepth'];
}
//if (isset($trackarray['CodecName'])) { $track_info['codec'] = $trackarray['CodecName']; }
switch ($trackarray['CodecID']) {
case 'A_PCM/INT/LIT':
case 'A_PCM/INT/BIG':
$track_info['bitrate'] = $trackarray['SamplingFrequency'] * $trackarray['Channels'] * $trackarray['BitDepth'];
break;
case 'A_AC3':
case 'A_DTS':
case 'A_MPEG/L3':
//case 'A_FLAC':
if (!getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'module.audio.' . $track_info['dataformat'] . '.php', __FILE__, false)) {
$this->getid3->warning('Unable to parse audio data [' . basename(__FILE__) . ':' . __LINE__ . '] because cannot include "module.audio.' . $track_info['dataformat'] . '.php"');
break;
}
if (!isset($info['matroska']['track_data_offsets'][$trackarray['TrackNumber']])) {
$this->getid3->warning('Unable to parse audio data [' . basename(__FILE__) . ':' . __LINE__ . '] because $info[matroska][track_data_offsets][' . $trackarray['TrackNumber'] . '] not set');
break;
}
// create temp instance
$getid3_temp = new getID3();
$getid3_temp->openfile($this->getid3->filename);
$getid3_temp->info['avdataoffset'] = $info['matroska']['track_data_offsets'][$trackarray['TrackNumber']]['offset'];
if ($track_info['dataformat'] == 'mp3' || $track_info['dataformat'] == 'flac') {
$getid3_temp->info['avdataend'] = $info['matroska']['track_data_offsets'][$trackarray['TrackNumber']]['offset'] + $info['matroska']['track_data_offsets'][$trackarray['TrackNumber']]['length'];
}
// analyze
$class = 'getid3_' . $track_info['dataformat'];
$header_data_key = $track_info['dataformat'] == 'mp3' ? 'mpeg' : $track_info['dataformat'];
$getid3_audio = new $class($getid3_temp);
if ($track_info['dataformat'] == 'mp3') {
//.........这里部分代码省略.........
示例10: getid3_real
//.........这里部分代码省略.........
$thisfile_real_chunks_currentchunk['mime_type_size'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 1));
$offset += 1;
$thisfile_real_chunks_currentchunk['mime_type'] = substr($ChunkData, $offset, $thisfile_real_chunks_currentchunk['mime_type_size']);
$offset += $thisfile_real_chunks_currentchunk['mime_type_size'];
$thisfile_real_chunks_currentchunk['type_specific_len'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 4));
$offset += 4;
$thisfile_real_chunks_currentchunk['type_specific_data'] = substr($ChunkData, $offset, $thisfile_real_chunks_currentchunk['type_specific_len']);
$offset += $thisfile_real_chunks_currentchunk['type_specific_len'];
// shortcut
$thisfile_real_chunks_currentchunk_typespecificdata =& $thisfile_real_chunks_currentchunk['type_specific_data'];
switch ($thisfile_real_chunks_currentchunk['mime_type']) {
case 'video/x-pn-realvideo':
case 'video/x-pn-multirate-realvideo':
// http://www.freelists.org/archives/matroska-devel/07-2003/msg00010.html
// shortcut
$thisfile_real_chunks_currentchunk['video_info'] = array();
$thisfile_real_chunks_currentchunk_videoinfo =& $thisfile_real_chunks_currentchunk['video_info'];
$thisfile_real_chunks_currentchunk_videoinfo['dwSize'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 0, 4));
$thisfile_real_chunks_currentchunk_videoinfo['fourcc1'] = substr($thisfile_real_chunks_currentchunk_typespecificdata, 4, 4);
$thisfile_real_chunks_currentchunk_videoinfo['fourcc2'] = substr($thisfile_real_chunks_currentchunk_typespecificdata, 8, 4);
$thisfile_real_chunks_currentchunk_videoinfo['width'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 12, 2));
$thisfile_real_chunks_currentchunk_videoinfo['height'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 14, 2));
$thisfile_real_chunks_currentchunk_videoinfo['bits_per_sample'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 16, 2));
$thisfile_real_chunks_currentchunk_videoinfo['unknown1'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 18, 2));
$thisfile_real_chunks_currentchunk_videoinfo['unknown2'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 20, 2));
$thisfile_real_chunks_currentchunk_videoinfo['frames_per_second'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 22, 2));
$thisfile_real_chunks_currentchunk_videoinfo['unknown3'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 24, 2));
$thisfile_real_chunks_currentchunk_videoinfo['unknown4'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 26, 2));
$thisfile_real_chunks_currentchunk_videoinfo['unknown5'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 28, 2));
$thisfile_real_chunks_currentchunk_videoinfo['unknown6'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 30, 2));
$thisfile_real_chunks_currentchunk_videoinfo['unknown7'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 32, 2));
$thisfile_real_chunks_currentchunk_videoinfo['unknown8'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 34, 2));
$thisfile_real_chunks_currentchunk_videoinfo['unknown9'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 36, 2));
$thisfile_real_chunks_currentchunk_videoinfo['codec'] = getid3_riff::RIFFfourccLookup($thisfile_real_chunks_currentchunk_videoinfo['fourcc2']);
$ThisFileInfo['video']['resolution_x'] = $thisfile_real_chunks_currentchunk_videoinfo['width'];
$ThisFileInfo['video']['resolution_y'] = $thisfile_real_chunks_currentchunk_videoinfo['height'];
$ThisFileInfo['video']['frame_rate'] = (double) $thisfile_real_chunks_currentchunk_videoinfo['frames_per_second'];
$ThisFileInfo['video']['codec'] = $thisfile_real_chunks_currentchunk_videoinfo['codec'];
$ThisFileInfo['video']['bits_per_sample'] = $thisfile_real_chunks_currentchunk_videoinfo['bits_per_sample'];
break;
case 'audio/x-pn-realaudio':
case 'audio/x-pn-multirate-realaudio':
$this->ParseOldRAheader($thisfile_real_chunks_currentchunk_typespecificdata, $thisfile_real_chunks_currentchunk['parsed_audio_data']);
$ThisFileInfo['audio']['sample_rate'] = $thisfile_real_chunks_currentchunk['parsed_audio_data']['sample_rate'];
$ThisFileInfo['audio']['bits_per_sample'] = $thisfile_real_chunks_currentchunk['parsed_audio_data']['bits_per_sample'];
$ThisFileInfo['audio']['channels'] = $thisfile_real_chunks_currentchunk['parsed_audio_data']['channels'];
if (!empty($ThisFileInfo['audio']['dataformat'])) {
foreach ($ThisFileInfo['audio'] as $key => $value) {
if ($key != 'streams') {
$ThisFileInfo['audio']['streams'][$thisfile_real_chunks_currentchunk['stream_number']][$key] = $value;
}
}
}
break;
case 'logical-fileinfo':
// shortcut
$thisfile_real_chunks_currentchunk['logical_fileinfo'] = array();
$thisfile_real_chunks_currentchunk_logicalfileinfo =& $thisfile_real_chunks_currentchunk['logical_fileinfo'];
$thisfile_real_chunks_currentchunk_logicalfileinfo['logical_fileinfo_length'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 0, 4));
$thisfile_real_chunks_currentchunk_logicalfileinfo['a'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 4, 4));
$thisfile_real_chunks_currentchunk_logicalfileinfo['b'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 8, 4));
$thisfile_real_chunks_currentchunk_logicalfileinfo['c'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 12, 4));
break;
}
if (empty($ThisFileInfo['playtime_seconds'])) {
$ThisFileInfo['playtime_seconds'] = max($ThisFileInfo['playtime_seconds'], ($thisfile_real_chunks_currentchunk['duration'] + $thisfile_real_chunks_currentchunk['start_time']) / 1000);
示例11: array_merge_noclobber
public static function array_merge_noclobber($array1, $array2)
{
if (!is_array($array1) || !is_array($array2)) {
return false;
}
$new_array = $array1;
foreach ($array2 as $key => $val) {
if (is_array($val) && isset($new_array[$key]) && is_array($new_array[$key])) {
$new_array[$key] = getid3_riff::array_merge_noclobber($new_array[$key], $val);
} elseif (!isset($new_array[$key])) {
$new_array[$key] = $val;
}
}
return $new_array;
}
示例12: Analyze
//.........这里部分代码省略.........
$offset += 1;
$info['la']['flags']['seekable'] = (bool) ($info['la']['raw']['flags'] & 0x1);
if ($info['la']['version'] >= 0.4) {
$info['la']['flags']['high_compression'] = (bool) ($info['la']['raw']['flags'] & 0x2);
}
$info['la']['original_crc'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));
$offset += 4;
// mikeØbevin*de
// Basically, the blocksize/seekevery are 61440/19 in La0.4 and 73728/16
// in earlier versions. A seekpoint is added every blocksize * seekevery
// samples, so 4 * int(totalSamples / (blockSize * seekEvery)) should
// give the number of bytes used for the seekpoints. Of course, if seeking
// is disabled, there are no seekpoints stored.
if ($info['la']['version'] >= 0.4) {
$info['la']['blocksize'] = 61440;
$info['la']['seekevery'] = 19;
} else {
$info['la']['blocksize'] = 73728;
$info['la']['seekevery'] = 16;
}
$info['la']['seekpoint_count'] = 0;
if ($info['la']['flags']['seekable']) {
$info['la']['seekpoint_count'] = floor($info['la']['samples'] / ($info['la']['blocksize'] * $info['la']['seekevery']));
for ($i = 0; $i < $info['la']['seekpoint_count']; $i++) {
$info['la']['seekpoints'][] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));
$offset += 4;
}
}
if ($info['la']['version'] >= 0.3) {
// Following the main header information, the program outputs all of the
// seekpoints. Following these is what I called the 'footer start',
// i.e. the position immediately after the La audio data is finished.
$info['la']['footerstart'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));
$offset += 4;
if ($info['la']['footerstart'] > $info['filesize']) {
$info['warning'][] = 'FooterStart value points to offset ' . $info['la']['footerstart'] . ' which is beyond end-of-file (' . $info['filesize'] . ')';
$info['la']['footerstart'] = $info['filesize'];
}
} else {
// La v0.2 didn't have FooterStart value
$info['la']['footerstart'] = $info['avdataend'];
}
if ($info['la']['footerstart'] < $info['avdataend']) {
if ($RIFFtempfilename = tempnam(GETID3_TEMP_DIR, 'id3')) {
if ($RIFF_fp = fopen($RIFFtempfilename, 'w+b')) {
$RIFFdata = 'WAVE';
if ($info['la']['version'] == 0.2) {
$RIFFdata .= substr($rawdata, 12, 24);
} else {
$RIFFdata .= substr($rawdata, 16, 24);
}
if ($info['la']['footerstart'] < $info['avdataend']) {
fseek($this->getid3->fp, $info['la']['footerstart'], SEEK_SET);
$RIFFdata .= fread($this->getid3->fp, $info['avdataend'] - $info['la']['footerstart']);
}
$RIFFdata = 'RIFF' . getid3_lib::LittleEndian2String(strlen($RIFFdata), 4, false) . $RIFFdata;
fwrite($RIFF_fp, $RIFFdata, strlen($RIFFdata));
fclose($RIFF_fp);
$getid3_temp = new getID3();
$getid3_temp->openfile($RIFFtempfilename);
$getid3_riff = new getid3_riff($getid3_temp);
$getid3_riff->Analyze();
if (empty($getid3_temp->info['error'])) {
$info['riff'] = $getid3_temp->info['riff'];
} else {
$info['warning'][] = 'Error parsing RIFF portion of La file: ' . implode($getid3_temp->info['error']);
}
unset($getid3_temp, $getid3_riff);
}
unlink($RIFFtempfilename);
}
}
// $info['avdataoffset'] should be zero to begin with, but just in case it's not, include the addition anyway
$info['avdataend'] = $info['avdataoffset'] + $info['la']['footerstart'];
$info['avdataoffset'] = $info['avdataoffset'] + $offset;
//$info['la']['codec'] = RIFFwFormatTagLookup($info['la']['raw']['format']);
$info['la']['compression_ratio'] = (double) (($info['avdataend'] - $info['avdataoffset']) / $info['la']['uncompressed_size']);
$info['playtime_seconds'] = (double) ($info['la']['samples'] / $info['la']['sample_rate']) / $info['la']['channels'];
if ($info['playtime_seconds'] == 0) {
$info['error'][] = 'Corrupt LA file: playtime_seconds == zero';
return false;
}
$info['audio']['bitrate'] = ($info['avdataend'] - $info['avdataoffset']) * 8 / $info['playtime_seconds'];
//$info['audio']['codec'] = $info['la']['codec'];
$info['audio']['bits_per_sample'] = $info['la']['bits_per_sample'];
break;
default:
if (substr($rawdata, $offset, 2) == 'LA') {
$info['error'][] = 'This version of getID3() [' . $this->getid3->version() . '] does not support LA version ' . substr($rawdata, $offset + 2, 1) . '.' . substr($rawdata, $offset + 3, 1) . ' which this appears to be - check http://getid3.sourceforge.net for updates.';
} else {
$info['error'][] = 'Not a LA (Lossless-Audio) file';
}
return false;
break;
}
$info['audio']['channels'] = $info['la']['channels'];
$info['audio']['sample_rate'] = (int) $info['la']['sample_rate'];
$info['audio']['encoder'] = 'LA v' . $info['la']['version'];
return true;
}
示例13: getid3_matroska
//.........这里部分代码省略.........
$sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
$sub_subelement_end = $offset + $sub_subelement_length;
switch ($sub_subelement_id) {
case EBML_ID_PIXELWIDTH:
case EBML_ID_PIXELHEIGHT:
case EBML_ID_STEREOMODE:
case EBML_ID_PIXELCROPBOTTOM:
case EBML_ID_PIXELCROPTOP:
case EBML_ID_PIXELCROPLEFT:
case EBML_ID_PIXELCROPRIGHT:
case EBML_ID_DISPLAYWIDTH:
case EBML_ID_DISPLAYHEIGHT:
case EBML_ID_DISPLAYUNIT:
case EBML_ID_ASPECTRATIOTYPE:
$track_entry[$sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
break;
case EBML_ID_FLAGINTERLACED:
$track_entry[$sub_subelement_idname] = (bool) getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
break;
case EBML_ID_GAMMAVALUE:
$track_entry[$sub_subelement_idname] = getid3_lib::BigEndian2Float(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
break;
case EBML_ID_COLOURSPACE:
$track_entry[$sub_subelement_idname] = trim(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length), "");
break;
default:
$this->warnings[] = 'Unhandled track.video element[' . __LINE__ . '] (' . $sub_subelement_id . '::' . $sub_subelement_idname . ') at ' . $sub_subelement_offset;
break;
}
$offset = $sub_subelement_end;
}
if (@$track_entry[$this->EBMLidName(EBML_ID_CODECID)] == 'V_MS/VFW/FOURCC' && isset($track_entry[$this->EBMLidName(EBML_ID_CODECPRIVATE)])) {
if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'module.audio-video.riff.php', __FILE__, false)) {
$track_entry['codec_private_parsed'] = getid3_riff::ParseBITMAPINFOHEADER($track_entry[$this->EBMLidName(EBML_ID_CODECPRIVATE)]);
} else {
$this->warnings[] = 'Unable to parse codec private data[' . __LINE__ . '] because cannot include "module.audio-video.riff.php"';
}
}
break;
case EBML_ID_AUDIO:
while ($offset < $subelement_end) {
$this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
$sub_subelement_offset = $offset;
$sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
$sub_subelement_idname = $this->EBMLidName($sub_subelement_id);
$sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
$sub_subelement_end = $offset + $sub_subelement_length;
switch ($sub_subelement_id) {
case EBML_ID_CHANNELS:
case EBML_ID_BITDEPTH:
$track_entry[$sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
break;
case EBML_ID_SAMPLINGFREQUENCY:
case EBML_ID_OUTPUTSAMPLINGFREQUENCY:
$track_entry[$sub_subelement_idname] = getid3_lib::BigEndian2Float(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
break;
case EBML_ID_CHANNELPOSITIONS:
$track_entry[$sub_subelement_idname] = trim(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length), "");
break;
default:
$this->warnings[] = 'Unhandled track.video element[' . __LINE__ . '] (' . $sub_subelement_id . '::' . $sub_subelement_idname . ') at ' . $sub_subelement_offset;
break;
}
$offset = $sub_subelement_end;
}
break;
示例14: getid3_matroska
//.........这里部分代码省略.........
$sub_subelement_end = $offset + $sub_subelement_length;
switch ($sub_subelement_id) {
case EBML_ID_PIXELWIDTH:
case EBML_ID_PIXELHEIGHT:
case EBML_ID_STEREOMODE:
case EBML_ID_PIXELCROPBOTTOM:
case EBML_ID_PIXELCROPTOP:
case EBML_ID_PIXELCROPLEFT:
case EBML_ID_PIXELCROPRIGHT:
case EBML_ID_DISPLAYWIDTH:
case EBML_ID_DISPLAYHEIGHT:
case EBML_ID_DISPLAYUNIT:
case EBML_ID_ASPECTRATIOTYPE:
$track_entry[$sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
break;
case EBML_ID_FLAGINTERLACED:
$track_entry[$sub_subelement_idname] = (bool) getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
break;
case EBML_ID_GAMMAVALUE:
$track_entry[$sub_subelement_idname] = getid3_lib::BigEndian2Float(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
break;
case EBML_ID_COLOURSPACE:
$track_entry[$sub_subelement_idname] = trim(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length), "\x00");
break;
default:
$this->warnings[] = 'Unhandled track.video element ['.basename(__FILE__).':'.__LINE__.'] ('.$sub_subelement_id.'::'.$sub_subelement_idname.') at '.$sub_subelement_offset;
break;
}
$offset = $sub_subelement_end;
}
if (isset($track_entry[$this->EBMLidName(EBML_ID_CODECID)]) && ($track_entry[$this->EBMLidName(EBML_ID_CODECID)] == 'V_MS/VFW/FOURCC') && isset($track_entry[$this->EBMLidName(EBML_ID_CODECPRIVATE)])) {
if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, false)) {
$track_entry['codec_private_parsed'] = getid3_riff::ParseBITMAPINFOHEADER($track_entry[$this->EBMLidName(EBML_ID_CODECPRIVATE)]);
} else {
$this->warnings[] = 'Unable to parse codec private data ['.basename(__FILE__).':'.__LINE__.'] because cannot include "module.audio-video.riff.php"';
}
}
break;
case EBML_ID_AUDIO:
while ($offset < $subelement_end) {
$this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
$sub_subelement_offset = $offset;
$sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
$sub_subelement_idname = $this->EBMLidName($sub_subelement_id);
$sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
$sub_subelement_end = $offset + $sub_subelement_length;
switch ($sub_subelement_id) {
case EBML_ID_CHANNELS:
case EBML_ID_BITDEPTH:
$track_entry[$sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
break;
case EBML_ID_SAMPLINGFREQUENCY:
case EBML_ID_OUTPUTSAMPLINGFREQUENCY:
$track_entry[$sub_subelement_idname] = getid3_lib::BigEndian2Float(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
break;
case EBML_ID_CHANNELPOSITIONS:
$track_entry[$sub_subelement_idname] = trim(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length), "\x00");
break;
default:
$this->warnings[] = 'Unhandled track.video element ['.basename(__FILE__).':'.__LINE__.'] ('.$sub_subelement_id.'::'.$sub_subelement_idname.') at '.$sub_subelement_offset;
break;
}
$offset = $sub_subelement_end;
}
示例15: Analyze
//.........这里部分代码省略.........
$getid3->info['playtime_seconds'] = $info_real_chunks_current_chunk['duration'] / 1000;
if ($info_real_chunks_current_chunk['duration'] > 0) {
$getid3->info['bitrate'] += $info_real_chunks_current_chunk['avg_bit_rate'];
}
$info_real_chunks_current_chunk['flags']['save_enabled'] = (bool) ($info_real_chunks_current_chunk['flags_raw'] & 0x1);
$info_real_chunks_current_chunk['flags']['perfect_play'] = (bool) ($info_real_chunks_current_chunk['flags_raw'] & 0x2);
$info_real_chunks_current_chunk['flags']['live_broadcast'] = (bool) ($info_real_chunks_current_chunk['flags_raw'] & 0x4);
}
break;
case 'MDPR':
// Media Properties Header
$info_real_chunks_current_chunk['object_version'] = getid3_lib::BigEndian2Int(substr($chunk_data, $offset, 2));
$offset += 2;
if ($info_real_chunks_current_chunk['object_version'] == 0) {
getid3_lib::ReadSequence('BigEndian2Int', $info_real_chunks_current_chunk, $chunk_data, $offset, array('stream_number' => 2, 'max_bit_rate' => 4, 'avg_bit_rate' => 4, 'max_packet_size' => 4, 'avg_packet_size' => 4, 'start_time' => 4, 'preroll' => 4, 'duration' => 4, 'stream_name_size' => 1));
$offset += 31;
$info_real_chunks_current_chunk['stream_name'] = substr($chunk_data, $offset, $info_real_chunks_current_chunk['stream_name_size']);
$offset += $info_real_chunks_current_chunk['stream_name_size'];
$info_real_chunks_current_chunk['mime_type_size'] = getid3_lib::BigEndian2Int($chunk_data[$offset++]);
$info_real_chunks_current_chunk['mime_type'] = substr($chunk_data, $offset, $info_real_chunks_current_chunk['mime_type_size']);
$offset += $info_real_chunks_current_chunk['mime_type_size'];
$info_real_chunks_current_chunk['type_specific_len'] = getid3_lib::BigEndian2Int(substr($chunk_data, $offset, 4));
$offset += 4;
$info_real_chunks_current_chunk['type_specific_data'] = substr($chunk_data, $offset, $info_real_chunks_current_chunk['type_specific_len']);
$offset += $info_real_chunks_current_chunk['type_specific_len'];
$info_real_chunks_current_chunk_typespecificdata =& $info_real_chunks_current_chunk['type_specific_data'];
switch ($info_real_chunks_current_chunk['mime_type']) {
case 'video/x-pn-realvideo':
case 'video/x-pn-multirate-realvideo':
// http://www.freelists.org/archives/matroska-devel/07-2003/msg00010.html
$info_real_chunks_current_chunk['video_info'] = array();
$info_real_chunks_current_chunk_video_info =& $info_real_chunks_current_chunk['video_info'];
getid3_lib::ReadSequence('BigEndian2Int', $info_real_chunks_current_chunk_video_info, $info_real_chunks_current_chunk_typespecificdata, 0, array('dwSize' => 4, 'fourcc1' => -4, 'fourcc2' => -4, 'width' => 2, 'height' => 2, 'bits_per_sample' => 2, 'IGNORE-unknown1' => 2, 'IGNORE-unknown2' => 2, 'frames_per_second' => 2, 'IGNORE-unknown3' => 2, 'IGNORE-unknown4' => 2, 'IGNORE-unknown5' => 2, 'IGNORE-unknown6' => 2, 'IGNORE-unknown7' => 2, 'IGNORE-unknown8' => 2, 'IGNORE-unknown9' => 2));
$info_real_chunks_current_chunk_video_info['codec'] = getid3_riff::RIFFfourccLookup($info_real_chunks_current_chunk_video_info['fourcc2']);
$getid3->info['video']['resolution_x'] = $info_real_chunks_current_chunk_video_info['width'];
$getid3->info['video']['resolution_y'] = $info_real_chunks_current_chunk_video_info['height'];
$getid3->info['video']['frame_rate'] = (double) $info_real_chunks_current_chunk_video_info['frames_per_second'];
$getid3->info['video']['codec'] = $info_real_chunks_current_chunk_video_info['codec'];
$getid3->info['video']['bits_per_sample'] = $info_real_chunks_current_chunk_video_info['bits_per_sample'];
break;
case 'audio/x-pn-realaudio':
case 'audio/x-pn-multirate-realaudio':
$this->ParseOldRAheader($info_real_chunks_current_chunk_typespecificdata, $info_real_chunks_current_chunk['parsed_audio_data']);
$getid3->info['audio']['sample_rate'] = $info_real_chunks_current_chunk['parsed_audio_data']['sample_rate'];
$getid3->info['audio']['bits_per_sample'] = $info_real_chunks_current_chunk['parsed_audio_data']['bits_per_sample'];
$getid3->info['audio']['channels'] = $info_real_chunks_current_chunk['parsed_audio_data']['channels'];
if (!empty($getid3->info['audio']['dataformat'])) {
foreach ($getid3->info['audio'] as $key => $value) {
if ($key != 'streams') {
$getid3->info['audio']['streams'][$info_real_chunks_current_chunk['stream_number']][$key] = $value;
}
}
}
break;
case 'logical-fileinfo':
$info_real_chunks_current_chunk['logical_fileinfo']['logical_fileinfo_length'] = getid3_lib::BigEndian2Int(substr($info_real_chunks_current_chunk_typespecificdata, 0, 4));
// $info_real_chunks_current_chunk['logical_fileinfo']['IGNORE-unknown1'] = getid3_lib::BigEndian2Int(substr($info_real_chunks_current_chunk_typespecificdata, 4, 4));
$info_real_chunks_current_chunk['logical_fileinfo']['num_tags'] = getid3_lib::BigEndian2Int(substr($info_real_chunks_current_chunk_typespecificdata, 8, 4));
// $info_real_chunks_current_chunk['logical_fileinfo']['IGNORE-unknown2'] = getid3_lib::BigEndian2Int(substr($info_real_chunks_current_chunk_typespecificdata, 12, 4));
break;
}
if (empty($getid3->info['playtime_seconds'])) {
$getid3->info['playtime_seconds'] = max($getid3->info['playtime_seconds'], ($info_real_chunks_current_chunk['duration'] + $info_real_chunks_current_chunk['start_time']) / 1000);
}
if ($info_real_chunks_current_chunk['duration'] > 0) {
switch ($info_real_chunks_current_chunk['mime_type']) {