当前位置: 首页>>代码示例>>PHP>>正文


PHP getid3_riff::RIFFparseWAVEFORMATex方法代码示例

本文整理汇总了PHP中getid3_riff::RIFFparseWAVEFORMATex方法的典型用法代码示例。如果您正苦于以下问题:PHP getid3_riff::RIFFparseWAVEFORMATex方法的具体用法?PHP getid3_riff::RIFFparseWAVEFORMATex怎么用?PHP getid3_riff::RIFFparseWAVEFORMATex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在getid3_riff的用法示例。


在下文中一共展示了getid3_riff::RIFFparseWAVEFORMATex方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
 }
开发者ID:pheski,项目名称:Scribite,代码行数:46,代码来源:module.audio.shorten.php

示例2: Analyze


//.........这里部分代码省略.........
                 // 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
                 $stream_properties_object_data['objectid_guid'] = $next_object_guidtext;
                 $stream_properties_object_data['objectsize'] = $next_object_size;
                 getid3_lib::ReadSequence('LittleEndian2Int', $stream_properties_object_data, $asf_header_data, $offset, array('stream_type' => -16, 'error_correct_type' => -16, 'time_offset' => 8, 'type_data_length' => 4, 'error_data_length' => 4, 'flags_raw' => 2));
                 $stream_properties_stream_number = $stream_properties_object_data['flags_raw'] & 0x7f;
                 $stream_properties_object_data['flags']['encrypted'] = (bool) ($stream_properties_object_data['flags_raw'] & 0x8000);
                 $stream_properties_object_data['stream_type_guid'] = getid3_asf::BytestringToGUID($stream_properties_object_data['stream_type']);
                 $stream_properties_object_data['error_correct_guid'] = getid3_asf::BytestringToGUID($stream_properties_object_data['error_correct_type']);
                 $offset += 54;
                 // 50 bytes + 4 bytes reserved - DWORD
                 $stream_properties_object_data['type_specific_data'] = substr($asf_header_data, $offset, $stream_properties_object_data['type_data_length']);
                 $offset += $stream_properties_object_data['type_data_length'];
                 $stream_properties_object_data['error_correct_data'] = substr($asf_header_data, $offset, $stream_properties_object_data['error_data_length']);
                 $offset += $stream_properties_object_data['error_data_length'];
                 switch ($stream_properties_object_data['stream_type_guid']) {
                     case getid3_asf::Audio_Media:
                         $info_audio['dataformat'] = @$info_audio['dataformat'] ? $info_audio['dataformat'] : 'asf';
                         $info_audio['bitrate_mode'] = @$info_audio['bitrate_mode'] ? $info_audio['bitrate_mode'] : 'cbr';
                         $audiodata = getid3_riff::RIFFparseWAVEFORMATex(substr($stream_properties_object_data['type_specific_data'], 0, 16));
                         unset($audiodata['raw']);
                         $info_audio = getid3_riff::array_merge_noclobber($audiodata, $info_audio);
                         break;
                     case getid3_asf::Video_Media:
                         $info_video['dataformat'] = @$info_video['dataformat'] ? $info_video['dataformat'] : 'asf';
                         $info_video['bitrate_mode'] = @$info_video['bitrate_mode'] ? $info_video['bitrate_mode'] : 'cbr';
                         break;
                         /* does nothing but eat memory
                            case getid3_asf::Command_Media:
                            default:
                                // do nothing
                                break;
                            */
                 }
                 $info_asf['stream_properties_object'][$stream_properties_stream_number] = $stream_properties_object_data;
                 unset($stream_properties_object_data);
                 // 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
                 $info_asf['header_extension_object'] = array();
                 $info_asf_header_extension_object =& $info_asf['header_extension_object'];
                 $info_asf_header_extension_object['objectid_guid'] = $next_object_guidtext;
                 $info_asf_header_extension_object['objectsize'] = $next_object_size;
                 $info_asf_header_extension_object['reserved_1_guid'] = getid3_asf::BytestringToGUID(substr($asf_header_data, $offset, 16));
开发者ID:JPisaBrony,项目名称:SonicFlow,代码行数:67,代码来源:module.audio-video.asf.php

示例3: getid3_riff

 function getid3_riff(&$fd, &$ThisFileInfo)
 {
     // initialize these values to an empty array, otherwise they default to NULL
     // and you can't append array values to a NULL value
     $ThisFileInfo['riff'] = array('raw' => array());
     // Shortcuts
     $thisfile_riff =& $ThisFileInfo['riff'];
     $thisfile_riff_raw =& $thisfile_riff['raw'];
     $thisfile_audio =& $ThisFileInfo['audio'];
     $thisfile_video =& $ThisFileInfo['video'];
     $thisfile_avdataoffset =& $ThisFileInfo['avdataoffset'];
     $thisfile_avdataend =& $ThisFileInfo['avdataend'];
     $thisfile_audio_dataformat =& $thisfile_audio['dataformat'];
     $thisfile_riff_audio =& $thisfile_riff['audio'];
     $thisfile_riff_video =& $thisfile_riff['video'];
     $Original['avdataoffset'] = $thisfile_avdataoffset;
     $Original['avdataend'] = $thisfile_avdataend;
     fseek($fd, $thisfile_avdataoffset, SEEK_SET);
     $RIFFheader = fread($fd, 12);
     $RIFFsubtype = substr($RIFFheader, 8, 4);
     switch (substr($RIFFheader, 0, 4)) {
         case 'FORM':
             $ThisFileInfo['fileformat'] = 'aiff';
             $RIFFheaderSize = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($RIFFheader, 4, 4));
             $thisfile_riff[$RIFFsubtype] = getid3_riff::ParseRIFF($fd, $thisfile_avdataoffset + 12, $thisfile_avdataoffset + $RIFFheaderSize, $ThisFileInfo);
             $thisfile_riff['header_size'] = $RIFFheaderSize;
             break;
         case 'RIFF':
         case 'SDSS':
             // SDSS is identical to RIFF, just renamed. Used by SmartSound QuickTracks (www.smartsound.com)
         // SDSS is identical to RIFF, just renamed. Used by SmartSound QuickTracks (www.smartsound.com)
         case 'RMP3':
             // RMP3 is identical to RIFF, just renamed. Used by [unknown program] when creating RIFF-MP3s
             if ($RIFFsubtype == 'RMP3') {
                 // RMP3 is identical to WAVE, just renamed. Used by [unknown program] when creating RIFF-MP3s
                 $RIFFsubtype = 'WAVE';
             }
             $ThisFileInfo['fileformat'] = 'riff';
             $RIFFheaderSize = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($RIFFheader, 4, 4));
             $thisfile_riff[$RIFFsubtype] = getid3_riff::ParseRIFF($fd, $thisfile_avdataoffset + 12, $thisfile_avdataoffset + $RIFFheaderSize, $ThisFileInfo);
             $thisfile_riff['header_size'] = $RIFFheaderSize;
             if ($RIFFsubtype == 'WAVE') {
                 $thisfile_riff_WAVE =& $thisfile_riff['WAVE'];
             }
             break;
         default:
             $ThisFileInfo['error'][] = 'Cannot parse RIFF (this is maybe not a RIFF / WAV / AVI file?) - expecting "FORM|RIFF|SDSS|RMP3" found "' . $RIFFsubtype . '" instead';
             unset($ThisFileInfo['fileformat']);
             return false;
             break;
     }
     $streamindex = 0;
     switch ($RIFFsubtype) {
         case 'WAVE':
             if (empty($thisfile_audio['bitrate_mode'])) {
                 $thisfile_audio['bitrate_mode'] = 'cbr';
             }
             if (empty($thisfile_audio_dataformat)) {
                 $thisfile_audio_dataformat = 'wav';
             }
             if (isset($thisfile_riff_WAVE['data'][0]['offset'])) {
                 $thisfile_avdataoffset = $thisfile_riff_WAVE['data'][0]['offset'] + 8;
                 $thisfile_avdataend = $thisfile_avdataoffset + $thisfile_riff_WAVE['data'][0]['size'];
             }
             if (isset($thisfile_riff_WAVE['fmt '][0]['data'])) {
                 $thisfile_riff_audio[$streamindex] = getid3_riff::RIFFparseWAVEFORMATex($thisfile_riff_WAVE['fmt '][0]['data']);
                 $thisfile_audio['wformattag'] = $thisfile_riff_audio[$streamindex]['raw']['wFormatTag'];
                 if (@$thisfile_riff_audio[$streamindex]['bitrate'] == 0) {
                     $ThisFileInfo['error'][] = 'Corrupt RIFF file: bitrate_audio == zero';
                     return false;
                 }
                 $thisfile_riff_raw['fmt '] = $thisfile_riff_audio[$streamindex]['raw'];
                 unset($thisfile_riff_audio[$streamindex]['raw']);
                 $thisfile_audio['streams'][$streamindex] = $thisfile_riff_audio[$streamindex];
                 $thisfile_audio = getid3_lib::array_merge_noclobber($thisfile_audio, $thisfile_riff_audio[$streamindex]);
                 if (substr($thisfile_audio['codec'], 0, strlen('unknown: 0x')) == 'unknown: 0x') {
                     $ThisFileInfo['warning'][] = 'Audio codec = ' . $thisfile_audio['codec'];
                 }
                 $thisfile_audio['bitrate'] = $thisfile_riff_audio[$streamindex]['bitrate'];
                 $ThisFileInfo['playtime_seconds'] = (double) (($thisfile_avdataend - $thisfile_avdataoffset) * 8 / $thisfile_audio['bitrate']);
                 $thisfile_audio['lossless'] = false;
                 if (isset($thisfile_riff_WAVE['data'][0]['offset']) && isset($thisfile_riff_raw['fmt ']['wFormatTag'])) {
                     switch ($thisfile_riff_raw['fmt ']['wFormatTag']) {
                         case 0x1:
                             // PCM
                             $thisfile_audio['lossless'] = true;
                             break;
                         case 0x2000:
                             // AC-3
                             $thisfile_audio_dataformat = 'ac3';
                             break;
                         default:
                             // do nothing
                             break;
                     }
                 }
                 $thisfile_audio['streams'][$streamindex]['wformattag'] = $thisfile_audio['wformattag'];
                 $thisfile_audio['streams'][$streamindex]['bitrate_mode'] = $thisfile_audio['bitrate_mode'];
                 $thisfile_audio['streams'][$streamindex]['lossless'] = $thisfile_audio['lossless'];
                 $thisfile_audio['streams'][$streamindex]['dataformat'] = $thisfile_audio_dataformat;
//.........这里部分代码省略.........
开发者ID:ioanok,项目名称:symfoxid,代码行数:101,代码来源:module.audio-video.riff.php

示例4: getid3_shorten


//.........这里部分代码省略.........
             //   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 = fread($fd, $ThisFileInfo['shn']['seektable']['length'] - 16);
             $ThisFileInfo['shn']['seektable']['entry_count'] = floor(strlen($SeekTableData) / 80);
             //$ThisFileInfo['shn']['seektable']['entries'] = array();
             //$SeekTableOffset = 0;
             //for ($i = 0; $i < $ThisFileInfo['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;
             //	}
             //
             //	$ThisFileInfo['shn']['seektable']['entries'][] = $SeekTableEntry;
             //}
         }
     }
     if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
         $ThisFileInfo['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)) {
                 $ThisFileInfo['error'][] = GETID3_HELPERAPPSDIR . $required_file . ' does not exist';
                 return false;
             }
         }
         $commandline = GETID3_HELPERAPPSDIR . 'shorten.exe -x "' . $ThisFileInfo['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) {
             $ThisFileInfo['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($ThisFileInfo['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::RIFFparseWAVEFORMATex(substr($output, 20, $fmt_size));
         $ThisFileInfo['audio']['channels'] = $DecodedWAVFORMATEX['channels'];
         $ThisFileInfo['audio']['bits_per_sample'] = $DecodedWAVFORMATEX['bits_per_sample'];
         $ThisFileInfo['audio']['sample_rate'] = $DecodedWAVFORMATEX['sample_rate'];
         if (substr($output, 20 + $fmt_size, 4) == 'data') {
             $ThisFileInfo['playtime_seconds'] = getid3_lib::LittleEndian2Int(substr($output, 20 + 4 + $fmt_size, 4)) / $DecodedWAVFORMATEX['raw']['nAvgBytesPerSec'];
         } else {
             $ThisFileInfo['error'][] = 'shorten failed to decode DATA chunk to expected location, cannot determine playtime';
             return false;
         }
         $ThisFileInfo['audio']['bitrate'] = ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) / $ThisFileInfo['playtime_seconds'] * 8;
     } else {
         $ThisFileInfo['error'][] = 'shorten failed to decode file to WAV for parsing';
         return false;
     }
     return true;
 }
开发者ID:sjlu,项目名称:fb-music-app,代码行数:101,代码来源:module.audio.shorten.php

示例5: Analyze


//.........这里部分代码省略.........
                             }
                             if (!empty($getid3_temp->info['warning'])) {
                                 foreach ($getid3_temp->info['warning'] as $newerror) {
                                     if ($track_info['dataformat'] == 'mp3' && preg_match('/^Probable truncated file: expecting \\d+ bytes of audio data, only found \\d+ \\(short by \\d+ bytes\\)$/', $newerror)) {
                                         // LAME/Xing header is probably set, but audio data is chunked into Matroska file and near-impossible to verify if audio stream is complete, so ignore useless warning
                                         continue;
                                     }
                                     $this->getid3->warning($class . '() says: [' . $newerror . ']');
                                 }
                             }
                             unset($getid3_temp, $getid3_audio);
                             break;
                         case 'A_AAC':
                         case 'A_AAC/MPEG2/LC':
                         case 'A_AAC/MPEG4/LC':
                         case 'A_AAC/MPEG4/LC/SBR':
                             $this->getid3->warning($trackarray['CodecID'] . ' audio data contains no header, audio/video bitrates can\'t be calculated');
                             break;
                         case 'A_VORBIS':
                             if (!isset($trackarray['CodecPrivate'])) {
                                 $this->getid3->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->getid3->warning('Unable to parse audio data [' . basename(__FILE__) . ':' . __LINE__ . '] because CodecPrivate data does not contain "vorbis" keyword');
                                 break;
                             }
                             $vorbis_offset -= 1;
                             if (!getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'module.audio.ogg.php', __FILE__, false)) {
                                 $this->getid3->warning('Unable to parse audio data [' . basename(__FILE__) . ':' . __LINE__ . '] because cannot include "module.audio.ogg.php"');
                             }
                             // create temp instance
                             $getid3_temp = new getID3();
                             $getid3_temp->openfile($this->getid3->filename);
                             // 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->getid3->warning('getid3_ogg() says: [' . $newerror . ']');
                                 }
                             }
                             if (!empty($getid3_temp->info['warning'])) {
                                 foreach ($getid3_temp->info['warning'] as $newerror) {
                                     $this->getid3->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':
                             if (!getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'module.audio-video.riff.php', __FILE__, false)) {
                                 $this->getid3->warning('Unable to parse audio data [' . basename(__FILE__) . ':' . __LINE__ . '] because cannot include "module.audio-video.riff.php"');
                                 break;
                             }
                             $parsed = getid3_riff::RIFFparseWAVEFORMATex($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->getid3->warning('Unhandled audio type "' . (isset($trackarray['CodecID']) ? $trackarray['CodecID'] : '') . '"');
                     }
                     $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']);
         }
     }
     // 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;
 }
开发者ID:thelectronicnub,项目名称:shimmie2,代码行数:101,代码来源:module.audio-video.matroska.php

示例6: Analyze

 public function Analyze()
 {
     $getid3 = $this->getid3;
     $getid3->info['riff']['raw'] = array();
     $info_riff =& $getid3->info['riff'];
     $info_riff_raw =& $info_riff['raw'];
     $info_audio =& $getid3->info['audio'];
     $info_video =& $getid3->info['video'];
     $info_avdataoffset =& $getid3->info['avdataoffset'];
     $info_avdataend =& $getid3->info['avdataend'];
     $info_audio_dataformat =& $info_audio['dataformat'];
     $info_riff_audio =& $info_riff['audio'];
     $info_riff_video =& $info_riff['video'];
     $original['avdataend'] = $info_avdataend;
     $this->fseek($info_avdataoffset, SEEK_SET);
     $riff_header = $this->fread(12);
     $riff_sub_type = substr($riff_header, 8, 4);
     switch (substr($riff_header, 0, 4)) {
         case 'FORM':
             $getid3->info['fileformat'] = 'aiff';
             $this->endian_function = 'BigEndian2Int';
             $riff_header_size = getid3_lib::BigEndian2Int(substr($riff_header, 4, 4));
             $info_riff[$riff_sub_type] = $this->ParseRIFF($info_avdataoffset + 12, $info_avdataoffset + $riff_header_size);
             $info_riff['header_size'] = $riff_header_size;
             break;
         case 'RIFF':
         case 'SDSS':
             // SDSS is identical to RIFF, just renamed. Used by SmartSound QuickTracks (www.smartsound.com)
         // SDSS is identical to RIFF, just renamed. Used by SmartSound QuickTracks (www.smartsound.com)
         case 'RMP3':
             // RMP3 is identical to RIFF, just renamed. Used by [unknown program] when creating RIFF-MP3s
             if ($riff_sub_type == 'RMP3') {
                 $riff_sub_type = 'WAVE';
             }
             $getid3->info['fileformat'] = 'riff';
             $this->endian_function = 'LittleEndian2Int';
             $riff_header_size = getid3_lib::LittleEndian2Int(substr($riff_header, 4, 4));
             $info_riff[$riff_sub_type] = $this->ParseRIFF($info_avdataoffset + 12, $info_avdataoffset + $riff_header_size);
             $info_riff['header_size'] = $riff_header_size;
             if ($riff_sub_type == 'WAVE') {
                 $info_riff_wave =& $info_riff['WAVE'];
             }
             break;
         default:
             throw new getid3_exception('Cannot parse RIFF (this is maybe not a RIFF / WAV / AVI file?) - expecting "FORM|RIFF|SDSS|RMP3" found "' . $riff_sub_type . '" instead');
     }
     $endian_function = $this->endian_function;
     $stream_index = 0;
     switch ($riff_sub_type) {
         case 'WAVE':
             if (empty($info_audio['bitrate_mode'])) {
                 $info_audio['bitrate_mode'] = 'cbr';
             }
             if (empty($info_audio_dataformat)) {
                 $info_audio_dataformat = 'wav';
             }
             if (isset($info_riff_wave['data'][0]['offset'])) {
                 $info_avdataoffset = $info_riff_wave['data'][0]['offset'] + 8;
                 $info_avdataend = $info_avdataoffset + $info_riff_wave['data'][0]['size'];
             }
             if (isset($info_riff_wave['fmt '][0]['data'])) {
                 $info_riff_audio[$stream_index] = getid3_riff::RIFFparseWAVEFORMATex($info_riff_wave['fmt '][0]['data']);
                 $info_audio['wformattag'] = $info_riff_audio[$stream_index]['raw']['wFormatTag'];
                 $info_riff_raw['fmt '] = $info_riff_audio[$stream_index]['raw'];
                 unset($info_riff_audio[$stream_index]['raw']);
                 $info_audio['streams'][$stream_index] = $info_riff_audio[$stream_index];
                 $info_audio = getid3_riff::array_merge_noclobber($info_audio, $info_riff_audio[$stream_index]);
                 if (substr($info_audio['codec'], 0, strlen('unknown: 0x')) == 'unknown: 0x') {
                     $getid3->warning('Audio codec = ' . $info_audio['codec']);
                 }
                 $info_audio['bitrate'] = $info_riff_audio[$stream_index]['bitrate'];
                 $getid3->info['playtime_seconds'] = (double) (($info_avdataend - $info_avdataoffset) * 8 / $info_audio['bitrate']);
                 $info_audio['lossless'] = false;
                 if (isset($info_riff_wave['data'][0]['offset']) && isset($info_riff_raw['fmt ']['wFormatTag'])) {
                     switch ($info_riff_raw['fmt ']['wFormatTag']) {
                         case 0x1:
                             // PCM
                             $info_audio['lossless'] = true;
                             break;
                         case 0x2000:
                             // AC-3
                             $info_audio_dataformat = 'ac3';
                             break;
                         default:
                             // do nothing
                             break;
                     }
                 }
                 $info_audio['streams'][$stream_index]['wformattag'] = $info_audio['wformattag'];
                 $info_audio['streams'][$stream_index]['bitrate_mode'] = $info_audio['bitrate_mode'];
                 $info_audio['streams'][$stream_index]['lossless'] = $info_audio['lossless'];
                 $info_audio['streams'][$stream_index]['dataformat'] = $info_audio_dataformat;
             }
             if (isset($info_riff_wave['rgad'][0]['data'])) {
                 // shortcuts
                 $rgadData =& $info_riff_wave['rgad'][0]['data'];
                 $info_riff_raw['rgad'] = array('track' => array(), 'album' => array());
                 $info_riff_raw_rgad =& $info_riff_raw['rgad'];
                 $info_riff_raw_rgad_track =& $info_riff_raw_rgad['track'];
                 $info_riff_raw_rgad_album =& $info_riff_raw_rgad['album'];
//.........这里部分代码省略.........
开发者ID:jwlynch,项目名称:openacs.core,代码行数:101,代码来源:module.audio-video.riff.php

示例7: Analyze


//.........这里部分代码省略.........
                                     }
                                     break 2;
                                 }
                             }
                             $info['warning'][] = 'expecting "RIFF" or "JUNK" at ' . $nextRIFFoffset . ', found ' . getid3_lib::PrintHexBytes(substr($nextRIFFheader, 0, 4)) . ' - skipping rest of file';
                             break 2;
                     }
                 }
             }
             if ($RIFFsubtype == 'WAVE') {
                 $thisfile_riff_WAVE =& $thisfile_riff['WAVE'];
             }
             break;
         default:
             $info['error'][] = 'Cannot parse RIFF (this is maybe not a RIFF / WAV / AVI file?) - expecting "FORM|RIFF|SDSS|RMP3" found "' . $RIFFsubtype . '" instead';
             unset($info['fileformat']);
             return false;
             break;
     }
     $streamindex = 0;
     switch ($RIFFsubtype) {
         case 'WAVE':
             if (empty($thisfile_audio['bitrate_mode'])) {
                 $thisfile_audio['bitrate_mode'] = 'cbr';
             }
             if (empty($thisfile_audio_dataformat)) {
                 $thisfile_audio_dataformat = 'wav';
             }
             if (isset($thisfile_riff_WAVE['data'][0]['offset'])) {
                 $info['avdataoffset'] = $thisfile_riff_WAVE['data'][0]['offset'] + 8;
                 $info['avdataend'] = $info['avdataoffset'] + $thisfile_riff_WAVE['data'][0]['size'];
             }
             if (isset($thisfile_riff_WAVE['fmt '][0]['data'])) {
                 $thisfile_riff_audio[$streamindex] = getid3_riff::RIFFparseWAVEFORMATex($thisfile_riff_WAVE['fmt '][0]['data']);
                 $thisfile_audio['wformattag'] = $thisfile_riff_audio[$streamindex]['raw']['wFormatTag'];
                 if (!isset($thisfile_riff_audio[$streamindex]['bitrate']) || $thisfile_riff_audio[$streamindex]['bitrate'] == 0) {
                     $info['error'][] = 'Corrupt RIFF file: bitrate_audio == zero';
                     return false;
                 }
                 $thisfile_riff_raw['fmt '] = $thisfile_riff_audio[$streamindex]['raw'];
                 unset($thisfile_riff_audio[$streamindex]['raw']);
                 $thisfile_audio['streams'][$streamindex] = $thisfile_riff_audio[$streamindex];
                 $thisfile_audio = getid3_lib::array_merge_noclobber($thisfile_audio, $thisfile_riff_audio[$streamindex]);
                 if (substr($thisfile_audio['codec'], 0, strlen('unknown: 0x')) == 'unknown: 0x') {
                     $info['warning'][] = 'Audio codec = ' . $thisfile_audio['codec'];
                 }
                 $thisfile_audio['bitrate'] = $thisfile_riff_audio[$streamindex]['bitrate'];
                 $info['playtime_seconds'] = (double) (($info['avdataend'] - $info['avdataoffset']) * 8 / $thisfile_audio['bitrate']);
                 $thisfile_audio['lossless'] = false;
                 if (isset($thisfile_riff_WAVE['data'][0]['offset']) && isset($thisfile_riff_raw['fmt ']['wFormatTag'])) {
                     switch ($thisfile_riff_raw['fmt ']['wFormatTag']) {
                         case 0x1:
                             // PCM
                             $thisfile_audio['lossless'] = true;
                             break;
                         case 0x2000:
                             // AC-3
                             $thisfile_audio_dataformat = 'ac3';
                             break;
                         default:
                             // do nothing
                             break;
                     }
                 }
                 $thisfile_audio['streams'][$streamindex]['wformattag'] = $thisfile_audio['wformattag'];
                 $thisfile_audio['streams'][$streamindex]['bitrate_mode'] = $thisfile_audio['bitrate_mode'];
开发者ID:thelectronicnub,项目名称:shimmie2,代码行数:67,代码来源:module.audio-video.riff.php

示例8: getid3_asf


//.........这里部分代码省略.........
                 // 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'] & 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::RIFFparseWAVEFORMATex(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['objectid'] = $NextObjectGUID;
                 $thisfile_asf_headerextensionobject['objectid_guid'] = $NextObjectGUIDtext;
                 $thisfile_asf_headerextensionobject['objectsize'] = $NextObjectSize;
                 $thisfile_asf_headerextensionobject['reserved_1'] = substr($ASFHeaderData, $offset, 16);
开发者ID:artistafrustrado,项目名称:debaser-diaadiaeducacao,代码行数:67,代码来源:module.audio-video.asf.php


注:本文中的getid3_riff::RIFFparseWAVEFORMATex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。