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


PHP getid3_riff::ParseRIFF方法代码示例

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


在下文中一共展示了getid3_riff::ParseRIFF方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Analyze


//.........这里部分代码省略.........
                     // 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:
                         // ID_CUESHEET
开发者ID:ricofreak,项目名称:omekaArchiveProject,代码行数:67,代码来源:module.audio.wavpack.php

示例2: ParseRIFF

 function ParseRIFF(&$fd, $startoffset, $maxoffset, &$ThisFileInfo)
 {
     $maxoffset = min($maxoffset, $ThisFileInfo['avdataend']);
     $RIFFchunk = false;
     fseek($fd, $startoffset, SEEK_SET);
     while (ftell($fd) < $maxoffset) {
         $chunkname = fread($fd, 4);
         if (strlen($chunkname) < 4) {
             $ThisFileInfo['error'][] = 'Expecting chunk name at offset ' . (ftell($fd) - 4) . ' but found nothing. Aborting RIFF parsing.';
             break;
         }
         $chunksize = getid3_riff::EitherEndian2Int($ThisFileInfo, fread($fd, 4));
         if ($chunksize == 0) {
             $ThisFileInfo['error'][] = 'Chunk size at offset ' . (ftell($fd) - 4) . ' is zero. Aborting RIFF parsing.';
             break;
         }
         if ($chunksize % 2 != 0) {
             // all structures are packed on word boundaries
             $chunksize++;
         }
         switch ($chunkname) {
             case 'LIST':
                 $listname = fread($fd, 4);
                 switch ($listname) {
                     case 'movi':
                     case 'rec ':
                         $RIFFchunk[$listname]['offset'] = ftell($fd) - 4;
                         $RIFFchunk[$listname]['size'] = $chunksize;
                         static $ParsedAudioStream = false;
                         if ($ParsedAudioStream) {
                             // skip over
                         } else {
                             $WhereWeWere = ftell($fd);
                             $AudioChunkHeader = fread($fd, 12);
                             $AudioChunkStreamNum = substr($AudioChunkHeader, 0, 2);
                             $AudioChunkStreamType = substr($AudioChunkHeader, 2, 2);
                             $AudioChunkSize = getid3_lib::LittleEndian2Int(substr($AudioChunkHeader, 4, 4));
                             if ($AudioChunkStreamType == 'wb') {
                                 $FirstFourBytes = substr($AudioChunkHeader, 8, 4);
                                 if (preg_match('/^\\xFF[\\xE2-\\xE7\\xF2-\\xF7\\xFA-\\xFF][\\x00-\\xEB]/s', $FirstFourBytes)) {
                                     // MP3
                                     if (getid3_mp3::MPEGaudioHeaderBytesValid($FirstFourBytes)) {
                                         $dummy = $ThisFileInfo;
                                         $dummy['avdataoffset'] = ftell($fd) - 4;
                                         $dummy['avdataend'] = ftell($fd) + $AudioChunkSize;
                                         getid3_mp3::getOnlyMPEGaudioInfo($fd, $dummy, $dummy['avdataoffset'], false);
                                         if (isset($dummy['mpeg']['audio'])) {
                                             $ThisFileInfo = $dummy;
                                             $ThisFileInfo['audio']['dataformat'] = 'mp' . $ThisFileInfo['mpeg']['audio']['layer'];
                                             $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['mpeg']['audio']['sample_rate'];
                                             $ThisFileInfo['audio']['channels'] = $ThisFileInfo['mpeg']['audio']['channels'];
                                             $ThisFileInfo['audio']['bitrate'] = $ThisFileInfo['mpeg']['audio']['bitrate'];
                                             $ThisFileInfo['bitrate'] = $ThisFileInfo['audio']['bitrate'];
                                             $ThisFileInfo['audio']['bitrate_mode'] = strtolower($ThisFileInfo['mpeg']['audio']['bitrate_mode']);
                                         }
                                     }
                                 } elseif (preg_match('/^\\x0B\\x77/s', $FirstFourBytes)) {
                                     // AC3
                                     $GETID3_ERRORARRAY =& $ThisFileInfo['warning'];
                                     if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'module.audio.ac3.php', __FILE__, false)) {
                                         $dummy = $ThisFileInfo;
                                         $dummy['avdataoffset'] = ftell($fd) - 4;
                                         $dummy['avdataend'] = ftell($fd) + $AudioChunkSize;
                                         $dummy['error'] = array();
                                         $ac3_tag = new getid3_ac3($fd, $dummy);
                                         if (empty($dummy['error'])) {
                                             $ThisFileInfo['audio'] = $dummy['audio'];
                                             $ThisFileInfo['ac3'] = $dummy['ac3'];
                                             $ThisFileInfo['warning'] = $dummy['warning'];
                                         }
                                     }
                                 }
                             }
                             $ParsedAudioStream = true;
                             fseek($fd, $WhereWeWere, SEEK_SET);
                         }
                         fseek($fd, $chunksize - 4, SEEK_CUR);
                         break;
                     default:
                         if (!isset($RIFFchunk[$listname])) {
                             $RIFFchunk[$listname] = array();
                         }
                         $LISTchunkParent = $listname;
                         $LISTchunkMaxOffset = ftell($fd) - 4 + $chunksize;
                         if ($parsedChunk = getid3_riff::ParseRIFF($fd, ftell($fd), ftell($fd) + $chunksize - 4, $ThisFileInfo)) {
                             $RIFFchunk[$listname] = array_merge_recursive($RIFFchunk[$listname], $parsedChunk);
                         }
                         break;
                 }
                 break;
             default:
                 $thisindex = 0;
                 if (isset($RIFFchunk[$chunkname]) && is_array($RIFFchunk[$chunkname])) {
                     $thisindex = count($RIFFchunk[$chunkname]);
                 }
                 $RIFFchunk[$chunkname][$thisindex]['offset'] = ftell($fd) - 8;
                 $RIFFchunk[$chunkname][$thisindex]['size'] = $chunksize;
                 switch ($chunkname) {
                     case 'data':
                         $ThisFileInfo['avdataoffset'] = ftell($fd);
//.........这里部分代码省略.........
开发者ID:ioanok,项目名称:symfoxid,代码行数:101,代码来源:module.audio-video.riff.php

示例3: ParseRIFF

 static function ParseRIFF(&$fd, $startoffset, $maxoffset, &$ThisFileInfo)
 {
     $maxoffset = min($maxoffset, $ThisFileInfo['avdataend']);
     $RIFFchunk = false;
     $FoundAllChunksWeNeed = false;
     if ($startoffset < 0 || !getid3_lib::intValueSupported($startoffset)) {
         $ThisFileInfo['warning'][] = 'Unable to ParseRIFF() at ' . $startoffset . ' because beyond ' . round(PHP_INT_MAX / 1073741824) . 'GB limit of PHP filesystem functions';
         return false;
     }
     $max_usable_offset = min(PHP_INT_MAX - 1024, $maxoffset);
     if ($maxoffset > $max_usable_offset) {
         $ThisFileInfo['warning'][] = 'ParseRIFF() may return incomplete data for chunk starting at ' . $startoffset . ' because beyond it extends to ' . $maxoffset . ', which is beyond the ' . round(PHP_INT_MAX / 1073741824) . 'GB limit of PHP filesystem functions';
     }
     fseek($fd, $startoffset, SEEK_SET);
     while (ftell($fd) < $max_usable_offset) {
         $chunknamesize = fread($fd, 8);
         $chunkname = substr($chunknamesize, 0, 4);
         $chunksize = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($chunknamesize, 4, 4));
         if (strlen($chunkname) < 4) {
             $ThisFileInfo['error'][] = 'Expecting chunk name at offset ' . (ftell($fd) - 4) . ' but found nothing. Aborting RIFF parsing.';
             break;
         }
         if ($chunksize == 0) {
             if ($chunkname == 'JUNK') {
                 // we'll allow zero-size JUNK frames
             } else {
                 $ThisFileInfo['warning'][] = 'Chunk size at offset ' . (ftell($fd) - 4) . ' is zero. Aborting RIFF parsing.';
                 break;
             }
         }
         if ($chunksize % 2 != 0) {
             // all structures are packed on word boundaries
             $chunksize++;
         }
         switch ($chunkname) {
             case 'LIST':
                 $listname = fread($fd, 4);
                 if (preg_match('#^(movi|rec )$#i', $listname)) {
                     $RIFFchunk[$listname]['offset'] = ftell($fd) - 4;
                     $RIFFchunk[$listname]['size'] = $chunksize;
                     if ($FoundAllChunksWeNeed) {
                         // skip over
                     } else {
                         $WhereWeWere = ftell($fd);
                         $AudioChunkHeader = fread($fd, 12);
                         $AudioChunkStreamNum = substr($AudioChunkHeader, 0, 2);
                         $AudioChunkStreamType = substr($AudioChunkHeader, 2, 2);
                         $AudioChunkSize = getid3_lib::LittleEndian2Int(substr($AudioChunkHeader, 4, 4));
                         if ($AudioChunkStreamType == 'wb') {
                             $FirstFourBytes = substr($AudioChunkHeader, 8, 4);
                             if (preg_match('/^\\xFF[\\xE2-\\xE7\\xF2-\\xF7\\xFA-\\xFF][\\x00-\\xEB]/s', $FirstFourBytes)) {
                                 // MP3
                                 if (getid3_mp3::MPEGaudioHeaderBytesValid($FirstFourBytes)) {
                                     $dummy = $ThisFileInfo;
                                     $dummy['avdataoffset'] = ftell($fd) - 4;
                                     $dummy['avdataend'] = ftell($fd) + $AudioChunkSize;
                                     getid3_mp3::getOnlyMPEGaudioInfo($fd, $dummy, $dummy['avdataoffset'], false);
                                     if (isset($dummy['mpeg']['audio'])) {
                                         $ThisFileInfo = $dummy;
                                         $ThisFileInfo['audio']['dataformat'] = 'mp' . $ThisFileInfo['mpeg']['audio']['layer'];
                                         $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['mpeg']['audio']['sample_rate'];
                                         $ThisFileInfo['audio']['channels'] = $ThisFileInfo['mpeg']['audio']['channels'];
                                         $ThisFileInfo['audio']['bitrate'] = $ThisFileInfo['mpeg']['audio']['bitrate'];
                                         $ThisFileInfo['bitrate'] = $ThisFileInfo['audio']['bitrate'];
                                         $ThisFileInfo['audio']['bitrate_mode'] = strtolower($ThisFileInfo['mpeg']['audio']['bitrate_mode']);
                                     }
                                     unset($dummy);
                                 }
                             } elseif (preg_match('/^\\x0B\\x77/s', $FirstFourBytes)) {
                                 // AC3
                                 $GETID3_ERRORARRAY =& $ThisFileInfo['warning'];
                                 if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'module.audio.ac3.php', __FILE__, false)) {
                                     $dummy = $ThisFileInfo;
                                     $dummy['avdataoffset'] = ftell($fd) - 4;
                                     $dummy['avdataend'] = ftell($fd) + $AudioChunkSize;
                                     $dummy['error'] = array();
                                     $ac3_tag = new getid3_ac3($fd, $dummy);
                                     if (empty($dummy['error'])) {
                                         $ThisFileInfo['audio'] = $dummy['audio'];
                                         $ThisFileInfo['ac3'] = $dummy['ac3'];
                                         $ThisFileInfo['warning'] = $dummy['warning'];
                                     }
                                     unset($ac3_tag);
                                 }
                             }
                         }
                         $FoundAllChunksWeNeed = true;
                         fseek($fd, $WhereWeWere, SEEK_SET);
                     }
                     fseek($fd, $chunksize - 4, SEEK_CUR);
                     //} elseif (preg_match('#^[0-9]{2}(wb|pc|dc|db)$#i', $listname)) {
                     //
                     //	// data chunk, ignore
                     //
                 } else {
                     if (!isset($RIFFchunk[$listname])) {
                         $RIFFchunk[$listname] = array();
                     }
                     $LISTchunkParent = $listname;
                     $LISTchunkMaxOffset = ftell($fd) - 4 + $chunksize;
//.........这里部分代码省略.........
开发者ID:sahartak,项目名称:newsroyal,代码行数:101,代码来源:module.audio-video.riff.php


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