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


PHP getID3::openfile方法代码示例

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


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

示例1: open

 /**
  * Open file
  *
  * @param \SplFileInfo $file
  *
  * @return \GravityMedia\Metadata\GetId3\Factory
  */
 public function open(\SplFileInfo $file)
 {
     if (!$this->getId3->openfile($file->getRealPath())) {
         $this->close();
         throw new \RuntimeException(sprintf('Error while opening file "%s": %s.', $this->filename, implode(PHP_EOL, $this->info['error'])));
     }
     return new Factory($this);
 }
开发者ID:gravitymedia,项目名称:metadata,代码行数:15,代码来源:GetId3.php

示例2: GetMIMEtype

function GetMIMEtype($filename)
{
    $filename = realpath($filename);
    if (!file_exists($filename)) {
        echo 'File does not exist: "' . htmlentities($filename) . '"<br>';
        return '';
    } elseif (!is_readable($filename)) {
        echo 'File is not readable: "' . htmlentities($filename) . '"<br>';
        return '';
    }
    // include getID3() library (can be in a different directory if full path is specified)
    require_once '../getid3/getid3.php';
    // Initialize getID3 engine
    $getID3 = new getID3();
    $DeterminedMIMEtype = '';
    if ($fp = fopen($filename, 'rb')) {
        $getID3->openfile($filename);
        if (empty($getID3->info['error'])) {
            // ID3v2 is the only tag format that might be prepended in front of files, and it's non-trivial to skip, easier just to parse it and know where to skip to
            getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'module.tag.id3v2.php', __FILE__, true);
            $getid3_id3v2 = new getid3_id3v2($getID3);
            $getid3_id3v2->Analyze();
            fseek($fp, $getID3->info['avdataoffset'], SEEK_SET);
            $formattest = fread($fp, 16);
            // 16 bytes is sufficient for any format except ISO CD-image
            fclose($fp);
            $DeterminedFormatInfo = $getID3->GetFileFormat($formattest);
            $DeterminedMIMEtype = $DeterminedFormatInfo['mime_type'];
        } else {
            echo 'Failed to getID3->openfile "' . htmlentities($filename) . '"<br>';
        }
    } else {
        echo 'Failed to fopen "' . htmlentities($filename) . '"<br>';
    }
    return $DeterminedMIMEtype;
}
开发者ID:boedy,项目名称:getID3,代码行数:36,代码来源:demo.mimeonly.php

示例3: Analyze


//.........这里部分代码省略.........
                     $info['video']['streams'][] = $track_info;
                     if (isset($track_info['resolution_x']) && empty($info['video']['resolution_x'])) {
                         foreach ($track_info as $key => $value) {
                             $info['video'][$key] = $value;
                         }
                     }
                     break;
                 case 2:
                     // Audio
                     if (!empty($trackarray['CodecID'])) {
                         $track_info['dataformat'] = $this->MatroskaCodecIDtoCommonName($trackarray['CodecID']);
                     }
                     if (!empty($trackarray['SamplingFrequency'])) {
                         $track_info['sample_rate'] = $trackarray['SamplingFrequency'];
                     }
                     if (!empty($trackarray['Channels'])) {
                         $track_info['channels'] = $trackarray['Channels'];
                     }
                     if (!empty($trackarray['BitDepth'])) {
                         $track_info['bits_per_sample'] = $trackarray['BitDepth'];
                     }
                     if (!empty($trackarray['Language'])) {
                         $track_info['language'] = $trackarray['Language'];
                     }
                     switch (isset($trackarray[$this->EBMLidName(EBML_ID_CODECID)]) ? $trackarray[$this->EBMLidName(EBML_ID_CODECID)] : '') {
                         case 'A_PCM/INT/LIT':
                         case 'A_PCM/INT/BIG':
                             $track_info['bitrate'] = $trackarray['SamplingFrequency'] * $trackarray['Channels'] * $trackarray['BitDepth'];
                             break;
                         case 'A_AC3':
                             if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'module.audio.ac3.php', __FILE__, false)) {
                                 if (isset($info['matroska']['track_data_offsets'][$trackarray['TrackNumber']]['offset'])) {
                                     $getid3_temp = new getID3();
                                     $getid3_temp->openfile($this->getid3->filename);
                                     $getid3_temp->info['avdataoffset'] = $info['matroska']['track_data_offsets'][$trackarray['TrackNumber']]['offset'];
                                     $getid3_ac3 = new getid3_ac3($getid3_temp);
                                     $getid3_ac3->Analyze();
                                     unset($getid3_temp->info['ac3']['GETID3_VERSION']);
                                     $info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $getid3_temp->info['ac3'];
                                     if (!empty($getid3_temp->info['error'])) {
                                         foreach ($getid3_temp->info['error'] as $newerror) {
                                             $this->warnings[] = 'getid3_ac3() says: [' . $newerror . ']';
                                         }
                                     }
                                     if (!empty($getid3_temp->info['warning'])) {
                                         foreach ($getid3_temp->info['warning'] as $newerror) {
                                             $this->warnings[] = 'getid3_ac3() says: [' . $newerror . ']';
                                         }
                                     }
                                     if (isset($getid3_temp->info['audio']) && is_array($getid3_temp->info['audio'])) {
                                         foreach ($getid3_temp->info['audio'] as $key => $value) {
                                             $track_info[$key] = $value;
                                         }
                                     }
                                     unset($getid3_temp, $getid3_ac3);
                                 } else {
                                     $this->warnings[] = 'Unable to parse audio data [' . basename(__FILE__) . ':' . __LINE__ . '] because $info[matroska][track_data_offsets][' . $trackarray['TrackNumber'] . '][offset] not set';
                                 }
                             } else {
                                 $this->warnings[] = 'Unable to parse audio data [' . basename(__FILE__) . ':' . __LINE__ . '] because cannot include "module.audio.ac3.php"';
                             }
                             break;
                         case 'A_DTS':
                             $dts_offset = $info['matroska']['track_data_offsets'][$trackarray['TrackNumber']]['offset'];
                             // this is a NASTY hack, but sometimes audio data is off by a byte or two and not sure why, email info@getid3.org if you can explain better
                             fseek($this->getid3->fp, $dts_offset, SEEK_SET);
开发者ID:hackersforcharity,项目名称:rachelpiOS,代码行数:67,代码来源:module.audio-video.matroska.php

示例4: Analyze

 function Analyze()
 {
     $info =& $this->getid3->info;
     fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
     $LPACheader = fread($this->getid3->fp, 14);
     if (substr($LPACheader, 0, 4) != 'LPAC') {
         $info['error'][] = 'Expected "LPAC" at offset ' . $info['avdataoffset'] . ', found "' . $StreamMarker . '"';
         return false;
     }
     $info['avdataoffset'] += 14;
     $info['fileformat'] = 'lpac';
     $info['audio']['dataformat'] = 'lpac';
     $info['audio']['lossless'] = true;
     $info['audio']['bitrate_mode'] = 'vbr';
     $info['lpac']['file_version'] = getid3_lib::BigEndian2Int(substr($LPACheader, 4, 1));
     $flags['audio_type'] = getid3_lib::BigEndian2Int(substr($LPACheader, 5, 1));
     $info['lpac']['total_samples'] = getid3_lib::BigEndian2Int(substr($LPACheader, 6, 4));
     $flags['parameters'] = getid3_lib::BigEndian2Int(substr($LPACheader, 10, 4));
     $info['lpac']['flags']['is_wave'] = (bool) ($flags['audio_type'] & 0x40);
     $info['lpac']['flags']['stereo'] = (bool) ($flags['audio_type'] & 0x4);
     $info['lpac']['flags']['24_bit'] = (bool) ($flags['audio_type'] & 0x2);
     $info['lpac']['flags']['16_bit'] = (bool) ($flags['audio_type'] & 0x1);
     if ($info['lpac']['flags']['24_bit'] && $info['lpac']['flags']['16_bit']) {
         $info['warning'][] = '24-bit and 16-bit flags cannot both be set';
     }
     $info['lpac']['flags']['fast_compress'] = (bool) ($flags['parameters'] & 0x40000000);
     $info['lpac']['flags']['random_access'] = (bool) ($flags['parameters'] & 0x8000000);
     $info['lpac']['block_length'] = pow(2, ($flags['parameters'] & 0x7000000) >> 24) * 256;
     $info['lpac']['flags']['adaptive_prediction_order'] = (bool) ($flags['parameters'] & 0x800000);
     $info['lpac']['flags']['adaptive_quantization'] = (bool) ($flags['parameters'] & 0x400000);
     $info['lpac']['flags']['joint_stereo'] = (bool) ($flags['parameters'] & 0x40000);
     $info['lpac']['quantization'] = ($flags['parameters'] & 0x1f00) >> 8;
     $info['lpac']['max_prediction_order'] = $flags['parameters'] & 0x3f;
     if ($info['lpac']['flags']['fast_compress'] && $info['lpac']['max_prediction_order'] != 3) {
         $info['warning'][] = 'max_prediction_order expected to be "3" if fast_compress is true, actual value is "' . $info['lpac']['max_prediction_order'] . '"';
     }
     switch ($info['lpac']['file_version']) {
         case 6:
             if ($info['lpac']['flags']['adaptive_quantization']) {
                 $info['warning'][] = 'adaptive_quantization expected to be false in LPAC file stucture v6, actually true';
             }
             if ($info['lpac']['quantization'] != 20) {
                 $info['warning'][] = 'Quantization expected to be 20 in LPAC file stucture v6, actually ' . $info['lpac']['flags']['Q'];
             }
             break;
         default:
             //$info['warning'][] = 'This version of getID3() ['.$this->getid3->version().'] only supports LPAC file format version 6, this file is version '.$info['lpac']['file_version'].' - please report to info@getid3.org';
             break;
     }
     $getid3_temp = new getID3();
     $getid3_temp->openfile($this->getid3->filename);
     $getid3_temp->info = $info;
     $getid3_riff = new getid3_riff($getid3_temp);
     $getid3_riff->Analyze();
     $info['avdataoffset'] = $getid3_temp->info['avdataoffset'];
     $info['riff'] = $getid3_temp->info['riff'];
     $info['error'] = $getid3_temp->info['error'];
     $info['warning'] = $getid3_temp->info['warning'];
     $info['lpac']['comments']['comment'] = $getid3_temp->info['comments'];
     $info['audio']['sample_rate'] = $getid3_temp->info['audio']['sample_rate'];
     unset($getid3_temp, $getid3_riff);
     $info['audio']['channels'] = $info['lpac']['flags']['stereo'] ? 2 : 1;
     if ($info['lpac']['flags']['24_bit']) {
         $info['audio']['bits_per_sample'] = $info['riff']['audio'][0]['bits_per_sample'];
     } elseif ($info['lpac']['flags']['16_bit']) {
         $info['audio']['bits_per_sample'] = 16;
     } else {
         $info['audio']['bits_per_sample'] = 8;
     }
     if ($info['lpac']['flags']['fast_compress']) {
         // fast
         $info['audio']['encoder_options'] = '-1';
     } else {
         switch ($info['lpac']['max_prediction_order']) {
             case 20:
                 // simple
                 $info['audio']['encoder_options'] = '-2';
                 break;
             case 30:
                 // medium
                 $info['audio']['encoder_options'] = '-3';
                 break;
             case 40:
                 // high
                 $info['audio']['encoder_options'] = '-4';
                 break;
             case 60:
                 // extrahigh
                 $info['audio']['encoder_options'] = '-5';
                 break;
         }
     }
     $info['playtime_seconds'] = $info['lpac']['total_samples'] / $info['audio']['sample_rate'];
     $info['audio']['bitrate'] = ($info['avdataend'] - $info['avdataoffset']) * 8 / $info['playtime_seconds'];
     return true;
 }
开发者ID:hackersforcharity,项目名称:rachelpiOS,代码行数:96,代码来源:module.audio.lpac.php

示例5: HandleBonkTags

 function HandleBonkTags($BonkTagName)
 {
     $info =& $this->getid3->info;
     switch ($BonkTagName) {
         case 'BONK':
             // shortcut
             $thisfile_bonk_BONK =& $info['bonk']['BONK'];
             $BonkData = "" . 'BONK' . fread($this->getid3->fp, 17);
             $thisfile_bonk_BONK['version'] = getid3_lib::LittleEndian2Int(substr($BonkData, 5, 1));
             $thisfile_bonk_BONK['number_samples'] = getid3_lib::LittleEndian2Int(substr($BonkData, 6, 4));
             $thisfile_bonk_BONK['sample_rate'] = getid3_lib::LittleEndian2Int(substr($BonkData, 10, 4));
             $thisfile_bonk_BONK['channels'] = getid3_lib::LittleEndian2Int(substr($BonkData, 14, 1));
             $thisfile_bonk_BONK['lossless'] = (bool) getid3_lib::LittleEndian2Int(substr($BonkData, 15, 1));
             $thisfile_bonk_BONK['joint_stereo'] = (bool) getid3_lib::LittleEndian2Int(substr($BonkData, 16, 1));
             $thisfile_bonk_BONK['number_taps'] = getid3_lib::LittleEndian2Int(substr($BonkData, 17, 2));
             $thisfile_bonk_BONK['downsampling_ratio'] = getid3_lib::LittleEndian2Int(substr($BonkData, 19, 1));
             $thisfile_bonk_BONK['samples_per_packet'] = getid3_lib::LittleEndian2Int(substr($BonkData, 20, 2));
             $info['avdataoffset'] = $thisfile_bonk_BONK['offset'] + 5 + 17;
             $info['avdataend'] = $thisfile_bonk_BONK['offset'] + $thisfile_bonk_BONK['size'];
             $info['fileformat'] = 'bonk';
             $info['audio']['dataformat'] = 'bonk';
             $info['audio']['bitrate_mode'] = 'vbr';
             // assumed
             $info['audio']['channels'] = $thisfile_bonk_BONK['channels'];
             $info['audio']['sample_rate'] = $thisfile_bonk_BONK['sample_rate'];
             $info['audio']['channelmode'] = $thisfile_bonk_BONK['joint_stereo'] ? 'joint stereo' : 'stereo';
             $info['audio']['lossless'] = $thisfile_bonk_BONK['lossless'];
             $info['audio']['codec'] = 'bonk';
             $info['playtime_seconds'] = $thisfile_bonk_BONK['number_samples'] / ($thisfile_bonk_BONK['sample_rate'] * $thisfile_bonk_BONK['channels']);
             if ($info['playtime_seconds'] > 0) {
                 $info['audio']['bitrate'] = ($info['bonk']['dataend'] - $info['bonk']['dataoffset']) * 8 / $info['playtime_seconds'];
             }
             break;
         case 'INFO':
             // shortcut
             $thisfile_bonk_INFO =& $info['bonk']['INFO'];
             $thisfile_bonk_INFO['version'] = getid3_lib::LittleEndian2Int(fread($this->getid3->fp, 1));
             $thisfile_bonk_INFO['entries_count'] = 0;
             $NextInfoDataPair = fread($this->getid3->fp, 5);
             if (!$this->BonkIsValidTagName(substr($NextInfoDataPair, 1, 4))) {
                 while (!feof($this->getid3->fp)) {
                     //$CurrentSeekInfo['offset']  = getid3_lib::LittleEndian2Int(substr($NextInfoDataPair, 0, 4));
                     //$CurrentSeekInfo['nextbit'] = getid3_lib::LittleEndian2Int(substr($NextInfoDataPair, 4, 1));
                     //$thisfile_bonk_INFO[] = $CurrentSeekInfo;
                     $NextInfoDataPair = fread($this->getid3->fp, 5);
                     if ($this->BonkIsValidTagName(substr($NextInfoDataPair, 1, 4))) {
                         fseek($this->getid3->fp, -5, SEEK_CUR);
                         break;
                     }
                     $thisfile_bonk_INFO['entries_count']++;
                 }
             }
             break;
         case 'META':
             $BonkData = "" . 'META' . fread($this->getid3->fp, $info['bonk']['META']['size'] - 5);
             $info['bonk']['META']['version'] = getid3_lib::LittleEndian2Int(substr($BonkData, 5, 1));
             $MetaTagEntries = floor((strlen($BonkData) - 8 - 6) / 8);
             // BonkData - xxxxmeta - ØMETA
             $offset = 6;
             for ($i = 0; $i < $MetaTagEntries; $i++) {
                 $MetaEntryTagName = substr($BonkData, $offset, 4);
                 $offset += 4;
                 $MetaEntryTagOffset = getid3_lib::LittleEndian2Int(substr($BonkData, $offset, 4));
                 $offset += 4;
                 $info['bonk']['META']['tags'][$MetaEntryTagName] = $MetaEntryTagOffset;
             }
             break;
         case ' ID3':
             $info['audio']['encoder'] = 'Extended BONK v0.9+';
             // ID3v2 checking is optional
             if (class_exists('getid3_id3v2')) {
                 $getid3_temp = new getID3();
                 $getid3_temp->openfile($this->getid3->filename);
                 $getid3_id3v2 = new getid3_id3v2($getid3_temp);
                 $getid3_id3v2->StartingOffset = $info['bonk'][' ID3']['offset'] + 2;
                 $info['bonk'][' ID3']['valid'] = $getid3_id3v2->Analyze();
                 if ($info['bonk'][' ID3']['valid']) {
                     $info['id3v2'] = $getid3_temp->info['id3v2'];
                 }
                 unset($getid3_temp, $getid3_id3v2);
             }
             break;
         default:
             $info['warning'][] = 'Unexpected Bonk tag "' . $BonkTagName . '" at offset ' . $info['bonk'][$BonkTagName]['offset'];
             break;
     }
 }
开发者ID:thelectronicnub,项目名称:shimmie2,代码行数:87,代码来源:module.audio.bonk.php

示例6: QuicktimeParseAtom


//.........这里部分代码省略.........
         case 'ftyp':
             // FileTYPe (?) atom (for MP4 it seems)
             $atom_structure['signature'] = substr($atom_data, 0, 4);
             $atom_structure['unknown_1'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
             $atom_structure['fourcc'] = substr($atom_data, 8, 4);
             break;
         case 'mdat':
             // Media DATa atom
             // 'mdat' contains the actual data for the audio/video, possibly also subtitles
             /* due to lack of known documentation, this is a kludge implementation. If you know of documentation on how mdat is properly structed, please send it to info@getid3.org */
             // first, skip any 'wide' padding, and second 'mdat' header (with specified size of zero?)
             $mdat_offset = 0;
             while (true) {
                 if (substr($atom_data, $mdat_offset, 8) == "" . 'wide') {
                     $mdat_offset += 8;
                 } elseif (substr($atom_data, $mdat_offset, 8) == "" . 'mdat') {
                     $mdat_offset += 8;
                 } else {
                     break;
                 }
             }
             // check to see if it looks like chapter titles, in the form of unterminated strings with a leading 16-bit size field
             while (($chapter_string_length = getid3_lib::BigEndian2Int(substr($atom_data, $mdat_offset, 2))) && $chapter_string_length < 1000 && $chapter_string_length <= strlen($atom_data) - $mdat_offset - 2 && preg_match('#^[\\x20-\\xFF]+$#', substr($atom_data, $mdat_offset + 2, $chapter_string_length), $chapter_matches)) {
                 $mdat_offset += 2 + $chapter_string_length;
                 @($info['quicktime']['comments']['chapters'][] = $chapter_matches[0]);
             }
             if ($atomsize > 8 && (!isset($info['avdataend_tmp']) || $info['quicktime'][$atomname]['size'] > $info['avdataend_tmp'] - $info['avdataoffset'])) {
                 $info['avdataoffset'] = $atom_structure['offset'] + 8;
                 // $info['quicktime'][$atomname]['offset'] + 8;
                 $OldAVDataEnd = $info['avdataend'];
                 $info['avdataend'] = $atom_structure['offset'] + $atom_structure['size'];
                 // $info['quicktime'][$atomname]['offset'] + $info['quicktime'][$atomname]['size'];
                 $getid3_temp = new getID3();
                 $getid3_temp->openfile($this->getid3->filename);
                 $getid3_temp->info['avdataoffset'] = $info['avdataoffset'];
                 $getid3_temp->info['avdataend'] = $info['avdataend'];
                 $getid3_mp3 = new getid3_mp3($getid3_temp);
                 if ($getid3_mp3->MPEGaudioHeaderValid($getid3_mp3->MPEGaudioHeaderDecode($this->fread(4)))) {
                     $getid3_mp3->getOnlyMPEGaudioInfo($getid3_temp->info['avdataoffset'], false);
                     if (!empty($getid3_temp->info['warning'])) {
                         foreach ($getid3_temp->info['warning'] as $value) {
                             $info['warning'][] = $value;
                         }
                     }
                     if (!empty($getid3_temp->info['mpeg'])) {
                         $info['mpeg'] = $getid3_temp->info['mpeg'];
                         if (isset($info['mpeg']['audio'])) {
                             $info['audio']['dataformat'] = 'mp3';
                             $info['audio']['codec'] = !empty($info['mpeg']['audio']['encoder']) ? $info['mpeg']['audio']['encoder'] : (!empty($info['mpeg']['audio']['codec']) ? $info['mpeg']['audio']['codec'] : (!empty($info['mpeg']['audio']['LAME']) ? 'LAME' : 'mp3'));
                             $info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate'];
                             $info['audio']['channels'] = $info['mpeg']['audio']['channels'];
                             $info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate'];
                             $info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']);
                             $info['bitrate'] = $info['audio']['bitrate'];
                         }
                     }
                 }
                 unset($getid3_mp3, $getid3_temp);
                 $info['avdataend'] = $OldAVDataEnd;
                 unset($OldAVDataEnd);
             }
             unset($mdat_offset, $chapter_string_length, $chapter_matches);
             break;
         case 'free':
             // FREE space atom
         // FREE space atom
开发者ID:rauldobrota,项目名称:zenphoto,代码行数:67,代码来源:module.audio-video.quicktime.php

示例7: 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') {
//.........这里部分代码省略.........
开发者ID:thelectronicnub,项目名称:shimmie2,代码行数:101,代码来源:module.audio-video.matroska.php

示例8: getinfo

 public function getinfo($filename)
 {
     $realfile = litepublisher::$paths->files . str_replace('/', DIRECTORY_SEPARATOR, $filename);
     $result = $this->getdefaultvalues($filename);
     if (preg_match("/\\.({$this->videoext})\$/", $filename, $m)) {
         $ext = $m[1];
         $mime = array('mp4' => 'video/mp4', 'mpe' => 'video/mpeg', 'mpeg' => 'video/mpeg', 'mpg' => 'video/mpeg', 'avi' => 'video/x-msvideo', 'mov' => 'video/quicktime', 'ogv' => 'video/ogg', 'webm' => 'video/webm', 'flv' => 'video/x-flv', 'f4v' => 'video/mp4', 'f4p' => 'video/mp4');
         if (isset($mime[$ext])) {
             $result['mime'] = $mime[$ext];
         }
         $result['media'] = 'video';
         return $result;
     }
     if ($info = @getimagesize($realfile)) {
         $result['mime'] = $info['mime'];
         $result['media'] = 'application/x-shockwave-flash' == $info['mime'] ? 'flash' : 'image';
         $result['width'] = $info[0];
         $result['height'] = $info[1];
         return $result;
     }
     if (preg_match("/\\.({$this->audioext})\$/", $filename)) {
         $mime = array('mp3' => 'audio/mpeg', 'wav' => 'audio/x-wav', 'flac' => 'audio/ogg', 'f4a' => 'audio/mp4', 'f4b' => 'audio/mp4');
         $result['mime'] = $mime[strtolower(substr($filename, -3))];
         $result['media'] = 'audio';
         return $result;
     }
     if (strend($filename, '.txt')) {
         $result['mime'] = 'text/plain';
         $result['media'] = 'text';
         return $result;
     }
     if (strend($filename, '.swf')) {
         $result['media'] = 'flash';
         $result['mime'] = 'application/x-shockwave-flash';
         require_once litepublisher::$paths->libinclude . 'getid3.php';
         require_once litepublisher::$paths->libinclude . 'getid3.lib.php';
         require_once litepublisher::$paths->libinclude . 'module.audio-video.swf.php';
         $getID3 = new getID3();
         $getID3->option_md5_data = true;
         $getID3->option_md5_data_source = true;
         $getID3->encoding = 'UTF-8';
         //$info = $getID3->analyze($realfile);
         $getID3->openfile($realfile);
         $swf = new getid3_swf($getID3);
         $swf->analyze();
         fclose($getID3->fp);
         $info = $getID3->info;
         if (!isset($info['error'])) {
             $result['width'] = (int) round($info['swf']['header']['frame_width'] / 20);
             $result['height'] = (int) round($info['swf']['header']['frame_height'] / 20);
             return $result;
         }
     }
     return $result;
 }
开发者ID:laiello,项目名称:litepublisher,代码行数:55,代码来源:mediaparser.class.php

示例9: Analyze


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

示例10: 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;
 }
开发者ID:ricofreak,项目名称:omekaArchiveProject,代码行数:101,代码来源:module.audio.la.php

示例11: ParseOptimFROGheader45


//.........这里部分代码省略.........
             case 'COMP':
                 // unlike other block types, there CAN be multiple COMP blocks
                 $COMPdata['offset'] = $BlockOffset;
                 $COMPdata['size'] = $BlockSize;
                 if ($info['avdataoffset'] == 0) {
                     $info['avdataoffset'] = $BlockOffset;
                 }
                 // Only interested in first 14 bytes (only first 12 needed for v4.50 alpha), not actual audio data
                 $BlockData .= $this->fread(14);
                 $this->fseek($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 ($info['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 .= $this->fread($BlockSize);
                 break;
             case 'TAIL':
                 $thisfile_ofr_thisblock['offset'] = $BlockOffset;
                 $thisfile_ofr_thisblock['size'] = $BlockSize;
                 if ($BlockSize > 0) {
                     $RIFFdata .= $this->fread($BlockSize);
                 }
                 break;
             case 'RECV':
                 // block contains no useful meta data - simply note and skip
                 $thisfile_ofr_thisblock['offset'] = $BlockOffset;
                 $thisfile_ofr_thisblock['size'] = $BlockSize;
                 $this->fseek($BlockSize, SEEK_CUR);
                 break;
             case 'APET':
                 // APEtag v2
                 $thisfile_ofr_thisblock['offset'] = $BlockOffset;
                 $thisfile_ofr_thisblock['size'] = $BlockSize;
                 $info['warning'][] = 'APEtag processing inside OptimFROG not supported in this version (' . $this->getid3->version() . ') of getID3()';
                 $this->fseek($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'] = $this->fread($BlockSize);
                     $thisfile_ofr_thisblock['md5_string'] = getid3_lib::PrintHexBytes($thisfile_ofr_thisblock['md5_binary'], true, false, false);
                     $info['md5_data_source'] = $thisfile_ofr_thisblock['md5_string'];
                 } else {
                     $info['warning'][] = 'Expecting block size of 16 in "MD5 " chunk, found ' . $BlockSize . ' instead';
                     $this->fseek($BlockSize, SEEK_CUR);
                 }
                 break;
             default:
                 $thisfile_ofr_thisblock['offset'] = $BlockOffset;
                 $thisfile_ofr_thisblock['size'] = $BlockSize;
                 $info['warning'][] = 'Unhandled OptimFROG block type "' . $BlockName . '" at offset ' . $thisfile_ofr_thisblock['offset'];
                 $this->fseek($BlockSize, SEEK_CUR);
                 break;
         }
     }
     if (isset($info['ofr']['TAIL']['offset'])) {
         $info['avdataend'] = $info['ofr']['TAIL']['offset'];
     }
     $info['playtime_seconds'] = (double) $info['ofr']['OFR ']['total_samples'] / ($info['audio']['channels'] * $info['audio']['sample_rate']);
     $info['audio']['bitrate'] = ($info['avdataend'] - $info['avdataoffset']) * 8 / $info['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_temp = new getID3();
     $getid3_temp->openfile($this->getid3->filename);
     $getid3_temp->info['avdataoffset'] = $info['avdataoffset'];
     $getid3_temp->info['avdataend'] = $info['avdataend'];
     $getid3_riff = new getid3_riff($getid3_temp);
     $getid3_riff->ParseRIFFdata($RIFFdata);
     $info['riff'] = $getid3_temp->info['riff'];
     unset($getid3_riff, $getid3_temp, $RIFFdata);
     return true;
 }
开发者ID:ndurchx,项目名称:music,代码行数:101,代码来源:module.audio.optimfrog.php

示例12: Analyze


//.........这里部分代码省略.........
                 					$bitstreamoffset = 0;
                 
                 					$PackedElementaryStream['marker_bits']               = self::readBitsFromStream($bitstream, $bitstreamoffset,  2); //  2 bits for marker_bits -- should be "10" = 2
                 echo 'marker_bits = '.$PackedElementaryStream['marker_bits'].'<br>';
                 					$PackedElementaryStream['scrambling_control']        = self::readBitsFromStream($bitstream, $bitstreamoffset,  2); //  2 bits for scrambling_control -- 00 implies not scrambled
                 					$PackedElementaryStream['priority']                  = self::readBitsFromStream($bitstream, $bitstreamoffset,  1); //  1 bit flag: priority
                 					$PackedElementaryStream['data_alignment_indicator']  = self::readBitsFromStream($bitstream, $bitstreamoffset,  1); //  1 bit flag: data_alignment_indicator -- 1 indicates that the PES packet header is immediately followed by the video start code or audio syncword
                 					$PackedElementaryStream['copyright']                 = self::readBitsFromStream($bitstream, $bitstreamoffset,  1); //  1 bit flag: copyright -- 1 implies copyrighted
                 					$PackedElementaryStream['original_or_copy']          = self::readBitsFromStream($bitstream, $bitstreamoffset,  1); //  1 bit flag: original_or_copy -- 1 implies original
                 					$PackedElementaryStream['pts_flag']                  = self::readBitsFromStream($bitstream, $bitstreamoffset,  1); //  1 bit flag: pts_flag -- Presentation Time Stamp
                 					$PackedElementaryStream['dts_flag']                  = self::readBitsFromStream($bitstream, $bitstreamoffset,  1); //  1 bit flag: dts_flag -- Decode Time Stamp
                 					$PackedElementaryStream['escr_flag']                 = self::readBitsFromStream($bitstream, $bitstreamoffset,  1); //  1 bit flag: escr_flag -- Elementary Stream Clock Reference
                 					$PackedElementaryStream['es_rate_flag']              = self::readBitsFromStream($bitstream, $bitstreamoffset,  1); //  1 bit flag: es_rate_flag -- Elementary Stream [data] Rate
                 					$PackedElementaryStream['dsm_trick_mode_flag']       = self::readBitsFromStream($bitstream, $bitstreamoffset,  1); //  1 bit flag: dsm_trick_mode_flag -- DSM trick mode - not used by DVD
                 					$PackedElementaryStream['additional_copy_info_flag'] = self::readBitsFromStream($bitstream, $bitstreamoffset,  1); //  1 bit flag: additional_copy_info_flag
                 					$PackedElementaryStream['crc_flag']                  = self::readBitsFromStream($bitstream, $bitstreamoffset,  1); //  1 bit flag: crc_flag
                 					$PackedElementaryStream['extension_flag']            = self::readBitsFromStream($bitstream, $bitstreamoffset,  1); //  1 bit flag: extension_flag
                 					$PackedElementaryStream['pes_remain_header_length']  = self::readBitsFromStream($bitstream, $bitstreamoffset,  8); //  1 bit flag: priority
                 
                 					$additional_header_bytes = 0;
                 					$additional_header_bytes += ($PackedElementaryStream['pts_flag']                  ? 5 : 0);
                 					$additional_header_bytes += ($PackedElementaryStream['dts_flag']                  ? 5 : 0);
                 					$additional_header_bytes += ($PackedElementaryStream['escr_flag']                 ? 6 : 0);
                 					$additional_header_bytes += ($PackedElementaryStream['es_rate_flag']              ? 3 : 0);
                 					$additional_header_bytes += ($PackedElementaryStream['additional_copy_info_flag'] ? 1 : 0);
                 					$additional_header_bytes += ($PackedElementaryStream['crc_flag']                  ? 2 : 0);
                 					$additional_header_bytes += ($PackedElementaryStream['extension_flag']            ? 1 : 0);
                 $PackedElementaryStream['additional_header_bytes'] = $additional_header_bytes;
                 					$bitstream .= getid3_lib::BigEndian2Bin(substr($MPEGstreamData, $StartCodeOffset + 9, $additional_header_bytes));
                 
                 					$info['mpeg']['packed_elementary_streams'][$PackedElementaryStream['stream_type']][$PackedElementaryStream['stream_id']][] = $PackedElementaryStream;
                 */
                 $getid3_temp = new getID3();
                 $getid3_temp->openfile($this->getid3->filename);
                 $getid3_temp->info = $info;
                 $getid3_mp3 = new getid3_mp3($getid3_temp);
                 for ($i = 0; $i <= 7; $i++) {
                     // some files have the MPEG-audio header 8 bytes after the end of the $00 $00 $01 $C0 signature, some have it up to 13 bytes (or more?) after
                     // I have no idea why or what the difference is, so this is a stupid hack.
                     // If anybody has any better idea of what's going on, please let me know - info@getid3.org
                     $getid3_temp->info = $info;
                     // only overwrite real data if valid header found
                     //echo 'audio at? '.($MPEGstreamBaseOffset + $StartCodeOffset + 4 + 8 + $i).'<br>';
                     if ($getid3_mp3->decodeMPEGaudioHeader($MPEGstreamBaseOffset + $StartCodeOffset + 4 + 8 + $i, $getid3_temp->info, false)) {
                         //echo 'yes!<br>';
                         $info = $getid3_temp->info;
                         $info['audio']['bitrate_mode'] = 'cbr';
                         $info['audio']['lossless'] = false;
                         break;
                     }
                 }
                 unset($getid3_temp, $getid3_mp3);
                 break;
             case 0xbc:
                 // Program Stream Map
             // Program Stream Map
             case 0xbd:
                 // Private stream 1 (non MPEG audio, subpictures)
             // Private stream 1 (non MPEG audio, subpictures)
             case 0xbe:
                 // Padding stream
             // Padding stream
             case 0xbf:
                 // Private stream 2 (navigation data)
             // Private stream 2 (navigation data)
             case 0xf0:
开发者ID:rauldobrota,项目名称:zenphoto,代码行数:67,代码来源:module.audio-video.mpeg.php

示例13: Analyze

 function Analyze()
 {
     $info =& $this->getid3->info;
     $info['fileformat'] = 'quicktime';
     $info['quicktime']['hinting'] = false;
     $info['quicktime']['controller'] = 'standard';
     // may be overridden if 'ctyp' atom is present
     fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
     $offset = 0;
     $atomcounter = 0;
     while ($offset < $info['avdataend']) {
         if (!getid3_lib::intValueSupported($offset)) {
             $info['error'][] = 'Unable to parse atom at offset ' . $offset . ' because beyond ' . round(PHP_INT_MAX / 1073741824) . 'GB limit of PHP filesystem functions';
             break;
         }
         fseek($this->getid3->fp, $offset, SEEK_SET);
         $AtomHeader = fread($this->getid3->fp, 8);
         $atomsize = getid3_lib::BigEndian2Int(substr($AtomHeader, 0, 4));
         $atomname = substr($AtomHeader, 4, 4);
         // 64-bit MOV patch by jlegateØktnc*com
         if ($atomsize == 1) {
             $atomsize = getid3_lib::BigEndian2Int(fread($this->getid3->fp, 8));
         }
         $info['quicktime'][$atomname]['name'] = $atomname;
         $info['quicktime'][$atomname]['size'] = $atomsize;
         $info['quicktime'][$atomname]['offset'] = $offset;
         if ($offset + $atomsize > $info['avdataend']) {
             $info['error'][] = 'Atom at offset ' . $offset . ' claims to go beyond end-of-file (length: ' . $atomsize . ' bytes)';
             return false;
         }
         if ($atomsize == 0) {
             // Furthermore, for historical reasons the list of atoms is optionally
             // terminated by a 32-bit integer set to 0. If you are writing a program
             // to read user data atoms, you should allow for the terminating 0.
             break;
         }
         switch ($atomname) {
             case 'mdat':
                 // Media DATa atom
                 // 'mdat' contains the actual data for the audio/video
                 if ($atomsize > 8 && (!isset($info['avdataend_tmp']) || $info['quicktime'][$atomname]['size'] > $info['avdataend_tmp'] - $info['avdataoffset'])) {
                     $info['avdataoffset'] = $info['quicktime'][$atomname]['offset'] + 8;
                     $OldAVDataEnd = $info['avdataend'];
                     $info['avdataend'] = $info['quicktime'][$atomname]['offset'] + $info['quicktime'][$atomname]['size'];
                     $getid3_temp = new getID3();
                     $getid3_temp->openfile($this->getid3->filename);
                     $getid3_temp->info['avdataoffset'] = $info['avdataoffset'];
                     $getid3_temp->info['avdataend'] = $info['avdataend'];
                     $getid3_mp3 = new getid3_mp3($getid3_temp);
                     if ($getid3_mp3->MPEGaudioHeaderValid($getid3_mp3->MPEGaudioHeaderDecode(fread($this->getid3->fp, 4)))) {
                         $getid3_mp3->getOnlyMPEGaudioInfo($getid3_temp->info['avdataoffset'], false);
                         if (!empty($getid3_temp->info['warning'])) {
                             foreach ($getid3_temp->info['warning'] as $value) {
                                 $info['warning'][] = $value;
                             }
                         }
                         if (!empty($getid3_temp->info['mpeg'])) {
                             $info['mpeg'] = $getid3_temp->info['mpeg'];
                             if (isset($info['mpeg']['audio'])) {
                                 $info['audio']['dataformat'] = 'mp3';
                                 $info['audio']['codec'] = !empty($info['mpeg']['audio']['encoder']) ? $info['mpeg']['audio']['encoder'] : (!empty($info['mpeg']['audio']['codec']) ? $info['mpeg']['audio']['codec'] : (!empty($info['mpeg']['audio']['LAME']) ? 'LAME' : 'mp3'));
                                 $info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate'];
                                 $info['audio']['channels'] = $info['mpeg']['audio']['channels'];
                                 $info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate'];
                                 $info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']);
                                 $info['bitrate'] = $info['audio']['bitrate'];
                             }
                         }
                     }
                     unset($getid3_mp3, $getid3_temp);
                     $info['avdataend'] = $OldAVDataEnd;
                     unset($OldAVDataEnd);
                 }
                 break;
             case 'free':
                 // FREE space atom
             // FREE space atom
             case 'skip':
                 // SKIP atom
             // SKIP atom
             case 'wide':
                 // 64-bit expansion placeholder atom
                 // 'free', 'skip' and 'wide' are just padding, contains no useful data at all
                 break;
             default:
                 $atomHierarchy = array();
                 $info['quicktime'][$atomname] = $this->QuicktimeParseAtom($atomname, $atomsize, fread($this->getid3->fp, $atomsize), $offset, $atomHierarchy, $this->ParseAllPossibleAtoms);
                 break;
         }
         $offset += $atomsize;
         $atomcounter++;
     }
     if (!empty($info['avdataend_tmp'])) {
         // this value is assigned to a temp value and then erased because
         // otherwise any atoms beyond the 'mdat' atom would not get parsed
         $info['avdataend'] = $info['avdataend_tmp'];
         unset($info['avdataend_tmp']);
     }
     if (!isset($info['bitrate']) && isset($info['playtime_seconds'])) {
         $info['bitrate'] = ($info['avdataend'] - $info['avdataoffset']) * 8 / $info['playtime_seconds'];
//.........这里部分代码省略.........
开发者ID:hackersforcharity,项目名称:rachelpiOS,代码行数:101,代码来源:module.audio-video.quicktime.php

示例14: Analyze


//.........这里部分代码省略.........
         //+=========================================+
         //|...original file name, zero-terminated...|
         //+=========================================+
         // GZIP files may have only one file, with no filename, so assume original filename is current filename without .gz
         $thisInfo['filename'] = preg_replace('#\\.gz$#i', '', $info['filename']);
         if ($thisInfo['flags']['filename']) {
             while (true) {
                 if (ord($buff[$fpointer]) == 0) {
                     $fpointer++;
                     break;
                 }
                 $thisInfo['filename'] .= $buff[$fpointer];
                 $fpointer++;
             }
         }
         // bit 4 - FLG.FCOMMENT
         //+===================================+
         //|...file comment, zero-terminated...|
         //+===================================+
         if ($thisInfo['flags']['comment']) {
             while (true) {
                 if (ord($buff[$fpointer]) == 0) {
                     $fpointer++;
                     break;
                 }
                 $thisInfo['comment'] .= $buff[$fpointer];
                 $fpointer++;
             }
         }
         // bit 1 - FLG.FHCRC
         //+---+---+
         //| CRC16 |
         //+---+---+
         if ($thisInfo['flags']['crc16']) {
             $w_crc = substr($buff, $fpointer, 2);
             $thisInfo['crc16'] = getid3_lib::LittleEndian2Int($w_crc);
             $fpointer += 2;
         }
         // bit 0 - FLG.FTEXT
         //if ($thisInfo['raw']['flags'] & 0x01) {
         //	Ignored...
         //}
         // bits 5, 6, 7 - reserved
         $thisInfo['crc32'] = getid3_lib::LittleEndian2Int(substr($buff, strlen($buff) - 8, 4));
         $thisInfo['filesize'] = getid3_lib::LittleEndian2Int(substr($buff, strlen($buff) - 4));
         $info['gzip']['files'] = getid3_lib::array_merge_clobber($info['gzip']['files'], getid3_lib::CreateDeepArray($thisInfo['filename'], '/', $thisInfo['filesize']));
         if ($this->option_gzip_parse_contents) {
             // Try to inflate GZip
             $csize = 0;
             $inflated = '';
             $chkcrc32 = '';
             if (function_exists('gzinflate')) {
                 $cdata = substr($buff, $fpointer);
                 $cdata = substr($cdata, 0, strlen($cdata) - 8);
                 $csize = strlen($cdata);
                 $inflated = gzinflate($cdata);
                 // Calculate CRC32 for inflated content
                 $thisInfo['crc32_valid'] = (bool) (sprintf('%u', crc32($inflated)) == $thisInfo['crc32']);
                 // determine format
                 $formattest = substr($inflated, 0, 32774);
                 $getid3_temp = new getID3();
                 $determined_format = $getid3_temp->GetFileFormat($formattest);
                 unset($getid3_temp);
                 // file format is determined
                 $determined_format['module'] = isset($determined_format['module']) ? $determined_format['module'] : '';
                 switch ($determined_format['module']) {
                     case 'tar':
                         // view TAR-file info
                         if (file_exists(GETID3_INCLUDEPATH . $determined_format['include']) && (include_once GETID3_INCLUDEPATH . $determined_format['include'])) {
                             if (($temp_tar_filename = tempnam(GETID3_TEMP_DIR, 'getID3')) === false) {
                                 // can't find anywhere to create a temp file, abort
                                 $info['error'][] = 'Unable to create temp file to parse TAR inside GZIP file';
                                 break;
                             }
                             if ($fp_temp_tar = fopen($temp_tar_filename, 'w+b')) {
                                 fwrite($fp_temp_tar, $inflated);
                                 fclose($fp_temp_tar);
                                 $getid3_temp = new getID3();
                                 $getid3_temp->openfile($temp_tar_filename);
                                 $getid3_tar = new getid3_tar($getid3_temp);
                                 $getid3_tar->Analyze();
                                 $info['gzip']['member_header'][$idx]['tar'] = $getid3_temp->info['tar'];
                                 unset($getid3_temp, $getid3_tar);
                                 unlink($temp_tar_filename);
                             } else {
                                 $info['error'][] = 'Unable to fopen() temp file to parse TAR inside GZIP file';
                                 break;
                             }
                         }
                         break;
                     case '':
                     default:
                         // unknown or unhandled format
                         break;
                 }
             }
         }
     }
     return true;
 }
开发者ID:hackersforcharity,项目名称:rachelpiOS,代码行数:101,代码来源:module.archive.gzip.php

示例15: getID3Mime

 /**
  *
  * @access public
  * @return
  **/
 public function getID3Mime()
 {
     $mime = NULL;
     $filename = realpath($this->file_src_pathname);
     if (!file_exists($filename)) {
         $this->error = 'File does not exist: "' . htmlentities($filename);
         return false;
     } elseif (!is_readable($filename)) {
         $this->error = 'File is not readable: "' . htmlentities($filename);
         return false;
     }
     require_once CAT_PATH . '/modules/lib_getid3/getid3/getid3.php';
     $getID3 = new getID3();
     if ($fp = fopen($filename, 'rb')) {
         $getID3->openfile($filename);
         if (empty($getID3->info['error'])) {
             // ID3v2 is the only tag format that might be prepended in front of files, and it's non-trivial to skip, easier just to parse it and know where to skip to
             getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'module.tag.id3v2.php', __FILE__, true);
             $getid3_id3v2 = new getid3_id3v2($getID3);
             $getid3_id3v2->Analyze();
             fseek($fp, $getID3->info['avdataoffset'], SEEK_SET);
             $formattest = fread($fp, 16);
             // 16 bytes is sufficient for any format except ISO CD-image
             fclose($fp);
             $DeterminedFormatInfo = $getID3->GetFileFormat($formattest);
             $mime = $DeterminedFormatInfo['mime_type'];
         } else {
             $this->error = 'Failed to getID3->openfile "' . htmlentities($filename);
         }
     } else {
         $this->error = 'Failed to fopen "' . htmlentities($filename);
     }
     $this->log()->logDebug('MIME type detected as [' . $mime . '] by getID3 library');
     return $mime;
 }
开发者ID:ircoco,项目名称:BlackCatCMS,代码行数:40,代码来源:Upload.php


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