當前位置: 首頁>>代碼示例>>PHP>>正文


PHP getid3_lib::intValueSupported方法代碼示例

本文整理匯總了PHP中getid3_lib::intValueSupported方法的典型用法代碼示例。如果您正苦於以下問題:PHP getid3_lib::intValueSupported方法的具體用法?PHP getid3_lib::intValueSupported怎麽用?PHP getid3_lib::intValueSupported使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在getid3_lib的用法示例。


在下文中一共展示了getid3_lib::intValueSupported方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: saveAttachment

 public function saveAttachment(&$ThisFileInfoIndex, $filename, $offset, $length)
 {
     try {
         if (!getid3_lib::intValueSupported($offset + $length)) {
             throw new Exception('cannot extract attachment, it extends beyond the ' . round(PHP_INT_MAX / 1073741824) . 'GB limit');
         }
         // do not extract at all
         if ($this->option_save_attachments === getID3::ATTACHMENTS_NONE) {
             unset($ThisFileInfoIndex);
             // do not set any
             // extract to return array
         } elseif ($this->option_save_attachments === getID3::ATTACHMENTS_INLINE) {
             // get whole data in one pass, till it is anyway stored in memory
             $ThisFileInfoIndex = file_get_contents($this->info['filenamepath'], false, null, $offset, $length);
             if ($ThisFileInfoIndex === false || strlen($ThisFileInfoIndex) != $length) {
                 // verify
                 throw new Exception('failed to read attachment data');
             }
             // assume directory path is given
         } else {
             $dir = rtrim(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $this->option_save_attachments), DIRECTORY_SEPARATOR);
             // check supplied directory
             if (!is_dir($dir) || !is_writable($dir)) {
                 throw new Exception('getID3::saveAttachment() -- supplied path (' . $dir . ') does not exist, or is not writable');
             }
             // set up destination path
             $dest = $dir . DIRECTORY_SEPARATOR . $filename;
             // optimize speed if read buffer size is configured to be large enough
             // here stream_copy_to_stream() may also be used. need to do speed-compare tests
             if ($length <= $this->fread_buffer_size()) {
                 $data = file_get_contents($this->info['filenamepath'], false, null, $offset, $length);
                 if ($data === false || strlen($data) != $length) {
                     // verify
                     throw new Exception('failed to read attachment data');
                 }
                 if (!file_put_contents($dest, $data)) {
                     throw new Exception('failed to create file ' . $dest);
                 }
             } else {
                 // optimization not available - copy data in loop
                 // here stream_copy_to_stream() shouldn't be used because it's internal read buffer may be larger than ours!
                 getid3_lib::CopyFileParts($this->info['filenamepath'], $dest, $offset, $length);
             }
             $ThisFileInfoIndex = $dest;
         }
     } catch (Exception $e) {
         unset($ThisFileInfoIndex);
         // do not set any is case of error
         $this->warning('Failed to extract attachment ' . $filename . ': ' . $e->getMessage());
         return false;
     }
     return true;
 }
開發者ID:jesusmarket,項目名稱:jesusmarket,代碼行數:53,代碼來源:getid3.php

示例2: CopyFileParts

 static function CopyFileParts($filename_source, $filename_dest, $offset, $length)
 {
     if (!getid3_lib::intValueSupported($offset + $length)) {
         throw new Exception('cannot copy file portion, it extends beyond the ' . round(PHP_INT_MAX / 1073741824) . 'GB limit');
     }
     if (is_readable($filename_source) && is_file($filename_source) && ($fp_src = fopen($filename_source, 'rb'))) {
         if (is_writable($filename_dest) && is_file($filename_dest) && ($fp_dest = fopen($filename_dest, 'wb'))) {
             if (fseek($fp_src, $offset, SEEK_SET) == 0) {
                 $byteslefttowrite = $length;
                 while ($byteslefttowrite > 0 && ($buffer = fread($fp_src, min($byteslefttowrite, $this->getid3->fread_buffer_size())))) {
                     $byteswritten = fwrite($fp_dest, $buffer, $byteslefttowrite);
                     $byteslefttowrite -= $byteswritten;
                 }
                 return true;
             } else {
                 throw new Exception('failed to seek to offset ' . $offset . ' in ' . $this->info['filenamepath']);
             }
             fclose($fp_dest);
         } else {
             throw new Exception('failed to open file for reading ' . $this->info['filenamepath']);
         }
         fclose($fp_src);
     } else {
         throw new Exception('failed to create file for writing ' . $dest);
     }
     return false;
 }
開發者ID:GavinHellyer,項目名稱:Annexe-Media,代碼行數:27,代碼來源:getid3.lib.php

示例3: Analyze

 public 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
     $this->fseek($info['avdataoffset']);
     $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;
         }
         $this->fseek($offset);
         $AtomHeader = $this->fread(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($this->fread(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;
         }
         $atomHierarchy = array();
         $info['quicktime'][$atomname] = $this->QuicktimeParseAtom($atomname, $atomsize, $this->fread($atomsize), $offset, $atomHierarchy, $this->ParseAllPossibleAtoms);
         $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'];
     }
     if (isset($info['bitrate']) && !isset($info['audio']['bitrate']) && !isset($info['quicktime']['video'])) {
         $info['audio']['bitrate'] = $info['bitrate'];
     }
     if (!empty($info['playtime_seconds']) && !isset($info['video']['frame_rate']) && !empty($info['quicktime']['stts_framecount'])) {
         foreach ($info['quicktime']['stts_framecount'] as $key => $samples_count) {
             $samples_per_second = $samples_count / $info['playtime_seconds'];
             if ($samples_per_second > 240) {
                 // has to be audio samples
             } else {
                 $info['video']['frame_rate'] = $samples_per_second;
                 break;
             }
         }
     }
     if ($info['audio']['dataformat'] == 'mp4' && empty($info['video']['resolution_x'])) {
         $info['fileformat'] = 'mp4';
         $info['mime_type'] = 'audio/mp4';
         unset($info['video']['dataformat']);
     }
     if (!$this->ReturnAtomData) {
         unset($info['quicktime']['moov']);
     }
     if (empty($info['audio']['dataformat']) && !empty($info['quicktime']['audio'])) {
         $info['audio']['dataformat'] = 'quicktime';
     }
     if (empty($info['video']['dataformat']) && !empty($info['quicktime']['video'])) {
         $info['video']['dataformat'] = 'quicktime';
     }
     return true;
 }
開發者ID:rauldobrota,項目名稱:zenphoto,代碼行數:80,代碼來源:module.audio-video.quicktime.php

示例4: RemoveID3v1

 function RemoveID3v1()
 {
     // File MUST be writeable - CHMOD(646) at least
     if (!empty($this->filename) && is_readable($this->filename) && is_writable($this->filename) && is_file($this->filename)) {
         $this->setRealFileSize();
         if ($this->filesize <= 0 || !getid3_lib::intValueSupported($this->filesize)) {
             $this->errors[] = 'Unable to RemoveID3v1(' . $this->filename . ') because filesize (' . $this->filesize . ') is larger than ' . round(PHP_INT_MAX / 1073741824) . 'GB';
             return false;
         }
         if ($fp_source = fopen($this->filename, 'r+b')) {
             fseek($fp_source, -128, SEEK_END);
             if (fread($fp_source, 3) == 'TAG') {
                 ftruncate($fp_source, $this->filesize - 128);
             } else {
                 // no ID3v1 tag to begin with - do nothing
             }
             fclose($fp_source);
             return true;
         } else {
             $this->errors[] = 'Could not fopen(' . $this->filename . ', "r+b")';
         }
     } else {
         $this->errors[] = $this->filename . ' is not writeable';
     }
     return false;
 }
開發者ID:ricofreak,項目名稱:omekaArchiveProject,代碼行數:26,代碼來源:write.id3v1.php

示例5: Analyze

 public function Analyze()
 {
     $info =& $this->getid3->info;
     if (!getid3_lib::intValueSupported($info['filesize'])) {
         $info['warning'][] = 'Unable to check for ID3v1 because file is larger than ' . round(PHP_INT_MAX / 1073741824) . 'GB';
         return false;
     }
     $this->fseek(-256, SEEK_END);
     $preid3v1 = $this->fread(128);
     $id3v1tag = $this->fread(128);
     if (substr($id3v1tag, 0, 3) == 'TAG') {
         $info['avdataend'] = $info['filesize'] - 128;
         $ParsedID3v1['title'] = $this->cutfield(substr($id3v1tag, 3, 30));
         $ParsedID3v1['artist'] = $this->cutfield(substr($id3v1tag, 33, 30));
         $ParsedID3v1['album'] = $this->cutfield(substr($id3v1tag, 63, 30));
         $ParsedID3v1['year'] = $this->cutfield(substr($id3v1tag, 93, 4));
         $ParsedID3v1['comment'] = substr($id3v1tag, 97, 30);
         // can't remove nulls yet, track detection depends on them
         $ParsedID3v1['genreid'] = ord(substr($id3v1tag, 127, 1));
         // If second-last byte of comment field is null and last byte of comment field is non-null
         // then this is ID3v1.1 and the comment field is 28 bytes long and the 30th byte is the track number
         if ($id3v1tag[125] === "" && $id3v1tag[126] !== "") {
             $ParsedID3v1['track'] = ord(substr($ParsedID3v1['comment'], 29, 1));
             $ParsedID3v1['comment'] = substr($ParsedID3v1['comment'], 0, 28);
         }
         $ParsedID3v1['comment'] = $this->cutfield($ParsedID3v1['comment']);
         $ParsedID3v1['genre'] = $this->LookupGenreName($ParsedID3v1['genreid']);
         if (!empty($ParsedID3v1['genre'])) {
             unset($ParsedID3v1['genreid']);
         }
         if (isset($ParsedID3v1['genre']) && (empty($ParsedID3v1['genre']) || $ParsedID3v1['genre'] == 'Unknown')) {
             unset($ParsedID3v1['genre']);
         }
         foreach ($ParsedID3v1 as $key => $value) {
             $ParsedID3v1['comments'][$key][0] = $value;
         }
         // ID3v1 data is supposed to be padded with NULL characters, but some taggers pad with spaces
         $GoodFormatID3v1tag = $this->GenerateID3v1Tag($ParsedID3v1['title'], $ParsedID3v1['artist'], $ParsedID3v1['album'], $ParsedID3v1['year'], isset($ParsedID3v1['genre']) ? $this->LookupGenreID($ParsedID3v1['genre']) : false, $ParsedID3v1['comment'], !empty($ParsedID3v1['track']) ? $ParsedID3v1['track'] : '');
         $ParsedID3v1['padding_valid'] = true;
         if ($id3v1tag !== $GoodFormatID3v1tag) {
             $ParsedID3v1['padding_valid'] = false;
             $info['warning'][] = 'Some ID3v1 fields do not use NULL characters for padding';
         }
         $ParsedID3v1['tag_offset_end'] = $info['filesize'];
         $ParsedID3v1['tag_offset_start'] = $ParsedID3v1['tag_offset_end'] - 128;
         $info['id3v1'] = $ParsedID3v1;
     }
     if (substr($preid3v1, 0, 3) == 'TAG') {
         // The way iTunes handles tags is, well, brain-damaged.
         // It completely ignores v1 if ID3v2 is present.
         // This goes as far as adding a new v1 tag *even if there already is one*
         // A suspected double-ID3v1 tag has been detected, but it could be that
         // the "TAG" identifier is a legitimate part of an APE or Lyrics3 tag
         if (substr($preid3v1, 96, 8) == 'APETAGEX') {
             // an APE tag footer was found before the last ID3v1, assume false "TAG" synch
         } elseif (substr($preid3v1, 119, 6) == 'LYRICS') {
             // a Lyrics3 tag footer was found before the last ID3v1, assume false "TAG" synch
         } else {
             // APE and Lyrics3 footers not found - assume double ID3v1
             $info['warning'][] = 'Duplicate ID3v1 tag detected - this has been known to happen with iTunes';
             $info['avdataend'] -= 128;
         }
     }
     return true;
 }
開發者ID:ajspencer,項目名稱:NCSSM-SG-WordPress,代碼行數:65,代碼來源:module.tag.id3v1.php

示例6: Analyze

 function Analyze()
 {
     $info =& $this->getid3->info;
     // shortcut
     $info['bonk'] = array();
     $thisfile_bonk =& $info['bonk'];
     $thisfile_bonk['dataoffset'] = $info['avdataoffset'];
     $thisfile_bonk['dataend'] = $info['avdataend'];
     if (!getid3_lib::intValueSupported($thisfile_bonk['dataend'])) {
         $info['warning'][] = 'Unable to parse BONK file from end (v0.6+ preferred method) because PHP filesystem functions only support up to ' . round(PHP_INT_MAX / 1073741824) . 'GB';
     } else {
         // scan-from-end method, for v0.6 and higher
         fseek($this->getid3->fp, $thisfile_bonk['dataend'] - 8, SEEK_SET);
         $PossibleBonkTag = fread($this->getid3->fp, 8);
         while ($this->BonkIsValidTagName(substr($PossibleBonkTag, 4, 4), true)) {
             $BonkTagSize = getid3_lib::LittleEndian2Int(substr($PossibleBonkTag, 0, 4));
             fseek($this->getid3->fp, 0 - $BonkTagSize, SEEK_CUR);
             $BonkTagOffset = ftell($this->getid3->fp);
             $TagHeaderTest = fread($this->getid3->fp, 5);
             if ($TagHeaderTest[0] != "" || substr($PossibleBonkTag, 4, 4) != strtolower(substr($PossibleBonkTag, 4, 4))) {
                 $info['error'][] = 'Expecting "' . getid3_lib::PrintHexBytes("" . strtoupper(substr($PossibleBonkTag, 4, 4))) . '" at offset ' . $BonkTagOffset . ', found "' . getid3_lib::PrintHexBytes($TagHeaderTest) . '"';
                 return false;
             }
             $BonkTagName = substr($TagHeaderTest, 1, 4);
             $thisfile_bonk[$BonkTagName]['size'] = $BonkTagSize;
             $thisfile_bonk[$BonkTagName]['offset'] = $BonkTagOffset;
             $this->HandleBonkTags($BonkTagName);
             $NextTagEndOffset = $BonkTagOffset - 8;
             if ($NextTagEndOffset < $thisfile_bonk['dataoffset']) {
                 if (empty($info['audio']['encoder'])) {
                     $info['audio']['encoder'] = 'Extended BONK v0.9+';
                 }
                 return true;
             }
             fseek($this->getid3->fp, $NextTagEndOffset, SEEK_SET);
             $PossibleBonkTag = fread($this->getid3->fp, 8);
         }
     }
     // seek-from-beginning method for v0.4 and v0.5
     if (empty($thisfile_bonk['BONK'])) {
         fseek($this->getid3->fp, $thisfile_bonk['dataoffset'], SEEK_SET);
         do {
             $TagHeaderTest = fread($this->getid3->fp, 5);
             switch ($TagHeaderTest) {
                 case "" . 'BONK':
                     if (empty($info['audio']['encoder'])) {
                         $info['audio']['encoder'] = 'BONK v0.4';
                     }
                     break;
                 case "" . 'INFO':
                     $info['audio']['encoder'] = 'Extended BONK v0.5';
                     break;
                 default:
                     break 2;
             }
             $BonkTagName = substr($TagHeaderTest, 1, 4);
             $thisfile_bonk[$BonkTagName]['size'] = $thisfile_bonk['dataend'] - $thisfile_bonk['dataoffset'];
             $thisfile_bonk[$BonkTagName]['offset'] = $thisfile_bonk['dataoffset'];
             $this->HandleBonkTags($BonkTagName);
         } while (true);
     }
     // parse META block for v0.6 - v0.8
     if (empty($thisfile_bonk['INFO']) && isset($thisfile_bonk['META']['tags']['info'])) {
         fseek($this->getid3->fp, $thisfile_bonk['META']['tags']['info'], SEEK_SET);
         $TagHeaderTest = fread($this->getid3->fp, 5);
         if ($TagHeaderTest == "" . 'INFO') {
             $info['audio']['encoder'] = 'Extended BONK v0.6 - v0.8';
             $BonkTagName = substr($TagHeaderTest, 1, 4);
             $thisfile_bonk[$BonkTagName]['size'] = $thisfile_bonk['dataend'] - $thisfile_bonk['dataoffset'];
             $thisfile_bonk[$BonkTagName]['offset'] = $thisfile_bonk['dataoffset'];
             $this->HandleBonkTags($BonkTagName);
         }
     }
     if (empty($info['audio']['encoder'])) {
         $info['audio']['encoder'] = 'Extended BONK v0.9+';
     }
     if (empty($thisfile_bonk['BONK'])) {
         unset($info['bonk']);
     }
     return true;
 }
開發者ID:thelectronicnub,項目名稱:shimmie2,代碼行數:81,代碼來源:module.audio.bonk.php

示例7: getAACADTSheaderFilepointer

 function getAACADTSheaderFilepointer($MaxFramesToScan = 1000000, $ReturnExtendedInfo = false)
 {
     $info =& $this->getid3->info;
     // based loosely on code from AACfile by Jurgen Faul  <jfaulØgmx.de>
     // http://jfaul.de/atl  or  http://j-faul.virtualave.net/atl/atl.html
     // http://faac.sourceforge.net/wiki/index.php?page=ADTS // dead link
     // http://wiki.multimedia.cx/index.php?title=ADTS
     // * ADTS Fixed Header: these don't change from frame to frame
     // syncword                                       12    always: '111111111111'
     // ID                                              1    0: MPEG-4, 1: MPEG-2
     // MPEG layer                                      2    If you send AAC in MPEG-TS, set to 0
     // protection_absent                               1    0: CRC present; 1: no CRC
     // profile                                         2    0: AAC Main; 1: AAC LC (Low Complexity); 2: AAC SSR (Scalable Sample Rate); 3: AAC LTP (Long Term Prediction)
     // sampling_frequency_index                        4    15 not allowed
     // private_bit                                     1    usually 0
     // channel_configuration                           3
     // original/copy                                   1    0: original; 1: copy
     // home                                            1    usually 0
     // emphasis                                        2    only if ID == 0 (ie MPEG-4)  // not present in some documentation?
     // * ADTS Variable Header: these can change from frame to frame
     // copyright_identification_bit                    1
     // copyright_identification_start                  1
     // aac_frame_length                               13    length of the frame including header (in bytes)
     // adts_buffer_fullness                           11    0x7FF indicates VBR
     // no_raw_data_blocks_in_frame                     2
     // * ADTS Error check
     // crc_check                                      16    only if protection_absent == 0
     $byteoffset = $info['avdataoffset'];
     $framenumber = 0;
     // Init bit pattern array
     static $decbin = array();
     // Populate $bindec
     for ($i = 0; $i < 256; $i++) {
         $decbin[chr($i)] = str_pad(decbin($i), 8, '0', STR_PAD_LEFT);
     }
     // used to calculate bitrate below
     $BitrateCache = array();
     while (true) {
         // breaks out when end-of-file encountered, or invalid data found,
         // or MaxFramesToScan frames have been scanned
         if (!getid3_lib::intValueSupported($byteoffset)) {
             $info['warning'][] = 'Unable to parse AAC file beyond ' . ftell($this->getid3->fp) . ' (PHP does not support file operations beyond ' . round(PHP_INT_MAX / 1073741824) . 'GB)';
             return false;
         }
         fseek($this->getid3->fp, $byteoffset, SEEK_SET);
         // First get substring
         $substring = fread($this->getid3->fp, 9);
         // header is 7 bytes (or 9 if CRC is present)
         $substringlength = strlen($substring);
         if ($substringlength != 9) {
             $info['error'][] = 'Failed to read 7 bytes at offset ' . (ftell($this->getid3->fp) - $substringlength) . ' (only read ' . $substringlength . ' bytes)';
             return false;
         }
         // this would be easier with 64-bit math, but split it up to allow for 32-bit:
         $header1 = getid3_lib::BigEndian2Int(substr($substring, 0, 2));
         $header2 = getid3_lib::BigEndian2Int(substr($substring, 2, 4));
         $header3 = getid3_lib::BigEndian2Int(substr($substring, 6, 1));
         $info['aac']['header']['raw']['syncword'] = ($header1 & 0xfff0) >> 4;
         if ($info['aac']['header']['raw']['syncword'] != 0xfff) {
             $info['error'][] = 'Synch pattern (0x0FFF) not found at offset ' . (ftell($this->getid3->fp) - $substringlength) . ' (found 0x0' . strtoupper(dechex($info['aac']['header']['raw']['syncword'])) . ' instead)';
             //if ($info['fileformat'] == 'aac') {
             //	return true;
             //}
             unset($info['aac']);
             return false;
         }
         // Gather info for first frame only - this takes time to do 1000 times!
         if ($framenumber == 0) {
             $info['aac']['header_type'] = 'ADTS';
             $info['fileformat'] = 'aac';
             $info['audio']['dataformat'] = 'aac';
             $info['aac']['header']['raw']['mpeg_version'] = ($header1 & 0x8) >> 3;
             $info['aac']['header']['raw']['mpeg_layer'] = ($header1 & 0x6) >> 1;
             $info['aac']['header']['raw']['protection_absent'] = ($header1 & 0x1) >> 0;
             $info['aac']['header']['raw']['profile_code'] = ($header2 & 0xc0000000) >> 30;
             $info['aac']['header']['raw']['sample_rate_code'] = ($header2 & 0x3c000000) >> 26;
             $info['aac']['header']['raw']['private_stream'] = ($header2 & 0x2000000) >> 25;
             $info['aac']['header']['raw']['channels_code'] = ($header2 & 0x1c00000) >> 22;
             $info['aac']['header']['raw']['original'] = ($header2 & 0x200000) >> 21;
             $info['aac']['header']['raw']['home'] = ($header2 & 0x100000) >> 20;
             $info['aac']['header']['raw']['copyright_stream'] = ($header2 & 0x80000) >> 19;
             $info['aac']['header']['raw']['copyright_start'] = ($header2 & 0x40000) >> 18;
             $info['aac']['header']['raw']['frame_length'] = ($header2 & 0x3ffe0) >> 5;
             $info['aac']['header']['mpeg_version'] = $info['aac']['header']['raw']['mpeg_version'] ? 2 : 4;
             $info['aac']['header']['crc_present'] = $info['aac']['header']['raw']['protection_absent'] ? false : true;
             $info['aac']['header']['profile'] = self::AACprofileLookup($info['aac']['header']['raw']['profile_code'], $info['aac']['header']['mpeg_version']);
             $info['aac']['header']['sample_frequency'] = self::AACsampleRateLookup($info['aac']['header']['raw']['sample_rate_code']);
             $info['aac']['header']['private'] = (bool) $info['aac']['header']['raw']['private_stream'];
             $info['aac']['header']['original'] = (bool) $info['aac']['header']['raw']['original'];
             $info['aac']['header']['home'] = (bool) $info['aac']['header']['raw']['home'];
             $info['aac']['header']['channels'] = $info['aac']['header']['raw']['channels_code'] == 7 ? 8 : $info['aac']['header']['raw']['channels_code'];
             if ($ReturnExtendedInfo) {
                 $info['aac'][$framenumber]['copyright_id_bit'] = (bool) $info['aac']['header']['raw']['copyright_stream'];
                 $info['aac'][$framenumber]['copyright_id_start'] = (bool) $info['aac']['header']['raw']['copyright_start'];
             }
             if ($info['aac']['header']['raw']['mpeg_layer'] != 0) {
                 $info['warning'][] = 'Layer error - expected "0", found "' . $info['aac']['header']['raw']['mpeg_layer'] . '" instead';
             }
             if ($info['aac']['header']['sample_frequency'] == 0) {
                 $info['error'][] = 'Corrupt AAC file: sample_frequency == zero';
//.........這裏部分代碼省略.........
開發者ID:ricofreak,項目名稱:omekaArchiveProject,代碼行數:101,代碼來源:module.audio.aac.php

示例8: analyze

 function analyze($filename)
 {
     try {
         if (!empty($this->startup_error)) {
             return $this->error($this->startup_error);
         }
         if (!empty($this->startup_warning)) {
             $this->warning($this->startup_warning);
         }
         // init result array and set parameters
         $this->info = array();
         $this->info['GETID3_VERSION'] = GETID3_VERSION;
         // Check encoding/iconv support
         if (!function_exists('iconv') && !in_array($this->encoding, array('ISO-8859-1', 'UTF-8', 'UTF-16LE', 'UTF-16BE', 'UTF-16'))) {
             $errormessage = 'iconv() support is needed for encodings other than ISO-8859-1, UTF-8, UTF-16LE, UTF16-BE, UTF-16. ';
             if (GETID3_OS_ISWINDOWS) {
                 $errormessage .= 'PHP does not have iconv() support. Please enable php_iconv.dll in php.ini, and copy iconv.dll from c:/php/dlls to c:/windows/system32';
             } else {
                 $errormessage .= 'PHP is not compiled with iconv() support. Please recompile with the --with-iconv switch';
             }
             return $this->error($errormessage);
         }
         // remote files not supported
         if (preg_match('/^(ht|f)tp:\\/\\//', $filename)) {
             return $this->error('Remote files are not supported in this version of getID3() - please copy the file locally first');
         }
         $filename = str_replace('/', DIRECTORY_SEPARATOR, $filename);
         $filename = preg_replace('#(.+)' . preg_quote(DIRECTORY_SEPARATOR) . '{2,}#U', '\\1' . DIRECTORY_SEPARATOR, $filename);
         // open local file
         if (file_exists($filename) && is_file($filename)) {
             ob_start();
             if ($fp = fopen($filename, 'rb')) {
                 // great
                 ob_end_clean();
             } else {
                 $fopen_error = ob_get_contents();
                 ob_end_clean();
                 return $this->error('Could not open file "' . $filename . '" (fopen says: ' . $fopen_error . ')');
             }
         } else {
             return $this->error('Could not open "' . $filename . '" (does not exist, or is not a file)');
         }
         // set parameters
         // $this->info['filesize'] = filesize($filename);
         $this->info['filesize'] = sprintf("%u", filesize($filename));
         // option_max_2gb_check
         if ($this->option_max_2gb_check) {
             // PHP (32-bit all, and 64-bit Windows) doesn't support integers larger than 2^31 (~2GB)
             // filesize() simply returns (filesize % (pow(2, 32)), no matter the actual filesize
             // ftell() returns 0 if seeking to the end is beyond the range of unsigned integer
             $fseek = fseek($fp, 0, SEEK_END);
             if ($fseek < 0 || $this->info['filesize'] != 0 && ftell($fp) == 0 || $this->info['filesize'] < 0 || ftell($fp) < 0) {
                 $real_filesize = false;
                 if (GETID3_OS_ISWINDOWS) {
                     $commandline = 'dir /-C "' . str_replace('/', DIRECTORY_SEPARATOR, $filename) . '"';
                     $dir_output = `{$commandline}`;
                     if (preg_match('#1 File\\(s\\)[ ]+([0-9]+) bytes#i', $dir_output, $matches)) {
                         $real_filesize = (double) $matches[1];
                     }
                 } else {
                     $commandline = 'ls -o -g -G --time-style=long-iso ' . escapeshellarg($filename);
                     $dir_output = `{$commandline}`;
                     if (preg_match('#([0-9]+) ([0-9]{4}-[0-9]{2}\\-[0-9]{2} [0-9]{2}:[0-9]{2}) ' . str_replace('#', '\\#', preg_quote($filename)) . '$#', $dir_output, $matches)) {
                         $real_filesize = (double) $matches[1];
                     }
                 }
                 if ($real_filesize === false) {
                     unset($this->info['filesize']);
                     fclose($fp);
                     return $this->error('Unable to determine actual filesize. File is most likely larger than ' . round(PHP_INT_MAX / 1073741824) . 'GB and is not supported by PHP.');
                 } elseif (getid3_lib::intValueSupported($real_filesize)) {
                     unset($this->info['filesize']);
                     fclose($fp);
                     return $this->error('PHP seems to think the file is larger than ' . round(PHP_INT_MAX / 1073741824) . 'GB, but filesystem reports it as ' . number_format($real_filesize, 3) . 'GB, please report to info@getid3.org');
                 }
                 $this->info['filesize'] = $real_filesize;
                 $this->error('File is larger than ' . round(PHP_INT_MAX / 1073741824) . 'GB (filesystem reports it as ' . number_format($real_filesize, 3) . 'GB) and is not properly supported by PHP.');
             }
         }
         // set more parameters
         $this->info['avdataoffset'] = 0;
         $this->info['avdataend'] = $this->info['filesize'];
         $this->info['fileformat'] = '';
         // filled in later
         $this->info['audio']['dataformat'] = '';
         // filled in later, unset if not used
         $this->info['video']['dataformat'] = '';
         // filled in later, unset if not used
         $this->info['tags'] = array();
         // filled in later, unset if not used
         $this->info['error'] = array();
         // filled in later, unset if not used
         $this->info['warning'] = array();
         // filled in later, unset if not used
         $this->info['comments'] = array();
         // filled in later, unset if not used
         $this->info['encoding'] = $this->encoding;
         // required by id3v2 and iso modules - can be unset at the end if desired
         // set redundant parameters - might be needed in some include file
         $this->info['filename'] = basename($filename);
//.........這裏部分代碼省略.........
開發者ID:nass600,項目名稱:homeCENTER,代碼行數:101,代碼來源:getid3.php

示例9: Analyze

 public function Analyze()
 {
     $info =& $this->getid3->info;
     if (!getid3_lib::intValueSupported($info['filesize'])) {
         $info['warning'][] = 'Unable to check for ID3v1 because file is larger than ' . round(PHP_INT_MAX / 1073741824) . 'GB';
         return false;
     }
     $this->fseek(-256, SEEK_END);
     $preid3v1 = $this->fread(128);
     $id3v1tag = $this->fread(128);
     if (substr($id3v1tag, 0, 3) == 'TAG') {
         $info['avdataend'] = $info['filesize'] - 128;
         $ParsedID3v1['title'] = $this->cutfield(substr($id3v1tag, 3, 30));
         $ParsedID3v1['artist'] = $this->cutfield(substr($id3v1tag, 33, 30));
         $ParsedID3v1['album'] = $this->cutfield(substr($id3v1tag, 63, 30));
         $ParsedID3v1['year'] = $this->cutfield(substr($id3v1tag, 93, 4));
         $ParsedID3v1['comment'] = substr($id3v1tag, 97, 30);
         // can't remove nulls yet, track detection depends on them
         $ParsedID3v1['genreid'] = ord(substr($id3v1tag, 127, 1));
         // If second-last byte of comment field is null and last byte of comment field is non-null
         // then this is ID3v1.1 and the comment field is 28 bytes long and the 30th byte is the track number
         if ($id3v1tag[125] === "" && $id3v1tag[126] !== "") {
             $ParsedID3v1['track'] = ord(substr($ParsedID3v1['comment'], 29, 1));
             $ParsedID3v1['comment'] = substr($ParsedID3v1['comment'], 0, 28);
         }
         $ParsedID3v1['comment'] = $this->cutfield($ParsedID3v1['comment']);
         $ParsedID3v1['genre'] = $this->LookupGenreName($ParsedID3v1['genreid']);
         if (!empty($ParsedID3v1['genre'])) {
             unset($ParsedID3v1['genreid']);
         }
         if (isset($ParsedID3v1['genre']) && (empty($ParsedID3v1['genre']) || $ParsedID3v1['genre'] == 'Unknown')) {
             unset($ParsedID3v1['genre']);
         }
         foreach ($ParsedID3v1 as $key => $value) {
             $ParsedID3v1['comments'][$key][0] = $value;
         }
         // ID3v1 encoding detection hack START
         // ID3v1 is defined as always using ISO-8859-1 encoding, but it is not uncommon to find files tagged with ID3v1 using Windows-1251 or other character sets
         // Since ID3v1 has no concept of character sets there is no certain way to know we have the correct non-ISO-8859-1 character set, but we can guess
         $ID3v1encoding = 'ISO-8859-1';
         foreach ($ParsedID3v1['comments'] as $tag_key => $valuearray) {
             foreach ($valuearray as $key => $value) {
                 if (preg_match('#^[\\x00-\\x40\\xA8\\B8\\x80-\\xFF]+$#', $value)) {
                     foreach (array('Windows-1251', 'KOI8-R') as $id3v1_bad_encoding) {
                         if (function_exists('mb_convert_encoding') && @mb_convert_encoding($value, $id3v1_bad_encoding, $id3v1_bad_encoding) === $value) {
                             $ID3v1encoding = $id3v1_bad_encoding;
                             break 3;
                         } elseif (function_exists('iconv') && @iconv($id3v1_bad_encoding, $id3v1_bad_encoding, $value) === $value) {
                             $ID3v1encoding = $id3v1_bad_encoding;
                             break 3;
                         }
                     }
                 }
             }
         }
         // ID3v1 encoding detection hack END
         // ID3v1 data is supposed to be padded with NULL characters, but some taggers pad with spaces
         $GoodFormatID3v1tag = $this->GenerateID3v1Tag($ParsedID3v1['title'], $ParsedID3v1['artist'], $ParsedID3v1['album'], $ParsedID3v1['year'], isset($ParsedID3v1['genre']) ? $this->LookupGenreID($ParsedID3v1['genre']) : false, $ParsedID3v1['comment'], !empty($ParsedID3v1['track']) ? $ParsedID3v1['track'] : '');
         $ParsedID3v1['padding_valid'] = true;
         if ($id3v1tag !== $GoodFormatID3v1tag) {
             $ParsedID3v1['padding_valid'] = false;
             $info['warning'][] = 'Some ID3v1 fields do not use NULL characters for padding';
         }
         $ParsedID3v1['tag_offset_end'] = $info['filesize'];
         $ParsedID3v1['tag_offset_start'] = $ParsedID3v1['tag_offset_end'] - 128;
         $info['id3v1'] = $ParsedID3v1;
         $info['id3v1']['encoding'] = $ID3v1encoding;
     }
     if (substr($preid3v1, 0, 3) == 'TAG') {
         // The way iTunes handles tags is, well, brain-damaged.
         // It completely ignores v1 if ID3v2 is present.
         // This goes as far as adding a new v1 tag *even if there already is one*
         // A suspected double-ID3v1 tag has been detected, but it could be that
         // the "TAG" identifier is a legitimate part of an APE or Lyrics3 tag
         if (substr($preid3v1, 96, 8) == 'APETAGEX') {
             // an APE tag footer was found before the last ID3v1, assume false "TAG" synch
         } elseif (substr($preid3v1, 119, 6) == 'LYRICS') {
             // a Lyrics3 tag footer was found before the last ID3v1, assume false "TAG" synch
         } else {
             // APE and Lyrics3 footers not found - assume double ID3v1
             $info['warning'][] = 'Duplicate ID3v1 tag detected - this has been known to happen with iTunes';
             $info['avdataend'] -= 128;
         }
     }
     return true;
 }
開發者ID:AndreyTepaykin,項目名稱:Platform,代碼行數:86,代碼來源:module.tag.id3v1.php

示例10: ParseRIFF

 function ParseRIFF($startoffset, $maxoffset)
 {
     $info =& $this->getid3->info;
     $maxoffset = min($maxoffset, $info['avdataend']);
     $RIFFchunk = false;
     $FoundAllChunksWeNeed = false;
     if ($startoffset < 0 || !getid3_lib::intValueSupported($startoffset)) {
         $info['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) {
         $info['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($this->getid3->fp, $startoffset, SEEK_SET);
     while (ftell($this->getid3->fp) < $max_usable_offset) {
         $chunknamesize = fread($this->getid3->fp, 8);
         $chunkname = substr($chunknamesize, 0, 4);
         $chunksize = $this->EitherEndian2Int(substr($chunknamesize, 4, 4));
         if (strlen($chunkname) < 4) {
             $info['error'][] = 'Expecting chunk name at offset ' . (ftell($this->getid3->fp) - 4) . ' but found nothing. Aborting RIFF parsing.';
             break;
         }
         if ($chunksize == 0) {
             if ($chunkname == 'JUNK') {
                 // we'll allow zero-size JUNK frames
             } else {
                 $info['warning'][] = 'Chunk size at offset ' . (ftell($this->getid3->fp) - 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($this->getid3->fp, 4);
                 if (preg_match('#^(movi|rec )$#i', $listname)) {
                     $RIFFchunk[$listname]['offset'] = ftell($this->getid3->fp) - 4;
                     $RIFFchunk[$listname]['size'] = $chunksize;
                     if ($FoundAllChunksWeNeed) {
                         // skip over
                     } else {
                         $WhereWeWere = ftell($this->getid3->fp);
                         $AudioChunkHeader = fread($this->getid3->fp, 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)) {
                                     $getid3_temp = new getID3();
                                     $getid3_temp->openfile($this->getid3->filename);
                                     $getid3_temp->info['avdataoffset'] = ftell($this->getid3->fp) - 4;
                                     $getid3_temp->info['avdataend'] = ftell($this->getid3->fp) + $AudioChunkSize;
                                     $getid3_mp3 = new getid3_mp3($getid3_temp);
                                     $getid3_mp3->getOnlyMPEGaudioInfo($getid3_temp->info['avdataoffset'], false);
                                     if (isset($getid3_temp->info['mpeg']['audio'])) {
                                         $info['mpeg']['audio'] = $getid3_temp->info['mpeg']['audio'];
                                         $info['audio'] = $getid3_temp->info['audio'];
                                         $info['audio']['dataformat'] = 'mp' . $info['mpeg']['audio']['layer'];
                                         $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_temp, $getid3_mp3);
                                 }
                             } elseif (preg_match('/^\\x0B\\x77/s', $FirstFourBytes)) {
                                 // AC3
                                 if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'module.audio.ac3.php', __FILE__, false)) {
                                     $getid3_temp = new getID3();
                                     $getid3_temp->openfile($this->getid3->filename);
                                     $getid3_temp->info['avdataoffset'] = ftell($this->getid3->fp) - 4;
                                     $getid3_temp->info['avdataend'] = ftell($this->getid3->fp) + $AudioChunkSize;
                                     $getid3_ac3 = new getid3_ac3($getid3_temp);
                                     $getid3_ac3->Analyze();
                                     if (empty($getid3_temp->info['error'])) {
                                         $info['audio'] = $getid3_temp->info['audio'];
                                         $info['ac3'] = $getid3_temp->info['ac3'];
                                         if (!empty($getid3_temp->info['warning'])) {
                                             foreach ($getid3_temp->info['warning'] as $key => $value) {
                                                 $info['warning'][] = $value;
                                             }
                                         }
                                     }
                                     unset($getid3_temp, $getid3_ac3);
                                 }
                             }
                         }
                         $FoundAllChunksWeNeed = true;
                         fseek($this->getid3->fp, $WhereWeWere, SEEK_SET);
                     }
                     fseek($this->getid3->fp, $chunksize - 4, SEEK_CUR);
                     //} elseif (preg_match('#^[0-9]{2}(wb|pc|dc|db)$#i', $listname)) {
                     //
//.........這裏部分代碼省略.........
開發者ID:thelectronicnub,項目名稱:shimmie2,代碼行數:101,代碼來源:module.audio-video.riff.php

示例11: RemoveID3v2

 public function RemoveID3v2()
 {
     // File MUST be writeable - CHMOD(646) at least. It's best if the
     // directory is also writeable, because that method is both faster and less susceptible to errors.
     if (is_writeable(dirname($this->filename))) {
         // preferred method - only one copying operation, minimal chance of corrupting
         // original file if script is interrupted, but required directory to be writeable
         if (is_readable($this->filename) && is_file($this->filename) && ($fp_source = fopen($this->filename, 'rb'))) {
             // Initialize getID3 engine
             $getID3 = new getID3();
             $OldThisFileInfo = $getID3->analyze($this->filename);
             if (!getid3_lib::intValueSupported($OldThisFileInfo['filesize'])) {
                 $this->errors[] = 'Unable to remove ID3v2 because file is larger than ' . round(PHP_INT_MAX / 1073741824) . 'GB';
                 fclose($fp_source);
                 return false;
             }
             rewind($fp_source);
             if ($OldThisFileInfo['avdataoffset'] !== false) {
                 fseek($fp_source, $OldThisFileInfo['avdataoffset']);
             }
             if (is_writable($this->filename) && is_file($this->filename) && ($fp_temp = fopen($this->filename . 'getid3tmp', 'w+b'))) {
                 while ($buffer = fread($fp_source, $this->fread_buffer_size)) {
                     fwrite($fp_temp, $buffer, strlen($buffer));
                 }
                 fclose($fp_temp);
             } else {
                 $this->errors[] = 'Could not fopen("' . $this->filename . 'getid3tmp", "w+b")';
             }
             fclose($fp_source);
         } else {
             $this->errors[] = 'Could not fopen("' . $this->filename . '", "rb")';
         }
         if (file_exists($this->filename)) {
             unlink($this->filename);
         }
         rename($this->filename . 'getid3tmp', $this->filename);
     } elseif (is_writable($this->filename)) {
         // less desirable alternate method - double-copies the file, overwrites original file
         // and could corrupt source file if the script is interrupted or an error occurs.
         if (is_readable($this->filename) && is_file($this->filename) && ($fp_source = fopen($this->filename, 'rb'))) {
             // Initialize getID3 engine
             $getID3 = new getID3();
             $OldThisFileInfo = $getID3->analyze($this->filename);
             if (!getid3_lib::intValueSupported($OldThisFileInfo['filesize'])) {
                 $this->errors[] = 'Unable to remove ID3v2 because file is larger than ' . round(PHP_INT_MAX / 1073741824) . 'GB';
                 fclose($fp_source);
                 return false;
             }
             rewind($fp_source);
             if ($OldThisFileInfo['avdataoffset'] !== false) {
                 fseek($fp_source, $OldThisFileInfo['avdataoffset']);
             }
             if ($fp_temp = tmpfile()) {
                 while ($buffer = fread($fp_source, $this->fread_buffer_size)) {
                     fwrite($fp_temp, $buffer, strlen($buffer));
                 }
                 fclose($fp_source);
                 if (is_writable($this->filename) && is_file($this->filename) && ($fp_source = fopen($this->filename, 'wb'))) {
                     rewind($fp_temp);
                     while ($buffer = fread($fp_temp, $this->fread_buffer_size)) {
                         fwrite($fp_source, $buffer, strlen($buffer));
                     }
                     fseek($fp_temp, -128, SEEK_END);
                     fclose($fp_source);
                 } else {
                     $this->errors[] = 'Could not fopen("' . $this->filename . '", "wb")';
                 }
                 fclose($fp_temp);
             } else {
                 $this->errors[] = 'Could not create tmpfile()';
             }
         } else {
             $this->errors[] = 'Could not fopen("' . $this->filename . '", "rb")';
         }
     } else {
         $this->errors[] = 'Directory and file both not writeable';
     }
     if (!empty($this->errors)) {
         return false;
     }
     return true;
 }
開發者ID:httpool,項目名稱:getID3,代碼行數:82,代碼來源:write.id3v2.php

示例12: getid3_quicktime

 function getid3_quicktime(&$fd, &$ThisFileInfo, $ReturnAtomData = true, $ParseAllPossibleAtoms = false)
 {
     $ThisFileInfo['fileformat'] = 'quicktime';
     $ThisFileInfo['quicktime']['hinting'] = false;
     $ThisFileInfo['quicktime']['controller'] = 'standard';
     // may be overridden if 'ctyp' atom is present
     fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
     $offset = 0;
     $atomcounter = 0;
     while ($offset < $ThisFileInfo['avdataend']) {
         if (!getid3_lib::intValueSupported($offset)) {
             $ThisFileInfo['error'][] = 'Unable to parse atom at offset ' . $offset . ' because beyond ' . round(PHP_INT_MAX / 1073741824) . 'GB limit of PHP filesystem functions';
             break;
         }
         fseek($fd, $offset, SEEK_SET);
         $AtomHeader = fread($fd, 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($fd, 8));
         }
         $ThisFileInfo['quicktime'][$atomname]['name'] = $atomname;
         $ThisFileInfo['quicktime'][$atomname]['size'] = $atomsize;
         $ThisFileInfo['quicktime'][$atomname]['offset'] = $offset;
         if ($offset + $atomsize > $ThisFileInfo['avdataend']) {
             $ThisFileInfo['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($ThisFileInfo['avdataend_tmp']) || $ThisFileInfo['quicktime'][$atomname]['size'] > $ThisFileInfo['avdataend_tmp'] - $ThisFileInfo['avdataoffset'])) {
                     $ThisFileInfo['avdataoffset'] = $ThisFileInfo['quicktime'][$atomname]['offset'] + 8;
                     $OldAVDataEnd = $ThisFileInfo['avdataend'];
                     $ThisFileInfo['avdataend'] = $ThisFileInfo['quicktime'][$atomname]['offset'] + $ThisFileInfo['quicktime'][$atomname]['size'];
                     if (getid3_mp3::MPEGaudioHeaderValid(getid3_mp3::MPEGaudioHeaderDecode(fread($fd, 4)))) {
                         getid3_mp3::getOnlyMPEGaudioInfo($fd, $ThisFileInfo, $ThisFileInfo['avdataoffset'], false);
                         if (isset($ThisFileInfo['mpeg']['audio'])) {
                             $ThisFileInfo['audio']['dataformat'] = 'mp3';
                             $ThisFileInfo['audio']['codec'] = !empty($ThisFileInfo['mpeg']['audio']['encoder']) ? $ThisFileInfo['mpeg']['audio']['encoder'] : (!empty($ThisFileInfo['mpeg']['audio']['codec']) ? $ThisFileInfo['mpeg']['audio']['codec'] : (!empty($ThisFileInfo['mpeg']['audio']['LAME']) ? 'LAME' : 'mp3'));
                             $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['mpeg']['audio']['sample_rate'];
                             $ThisFileInfo['audio']['channels'] = $ThisFileInfo['mpeg']['audio']['channels'];
                             $ThisFileInfo['audio']['bitrate'] = $ThisFileInfo['mpeg']['audio']['bitrate'];
                             $ThisFileInfo['audio']['bitrate_mode'] = strtolower($ThisFileInfo['mpeg']['audio']['bitrate_mode']);
                             $ThisFileInfo['bitrate'] = $ThisFileInfo['audio']['bitrate'];
                         }
                     }
                     $ThisFileInfo['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();
                 $ThisFileInfo['quicktime'][$atomname] = $this->QuicktimeParseAtom($atomname, $atomsize, fread($fd, $atomsize), $ThisFileInfo, $offset, $atomHierarchy, $ParseAllPossibleAtoms);
                 break;
         }
         $offset += $atomsize;
         $atomcounter++;
     }
     if (!empty($ThisFileInfo['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
         $ThisFileInfo['avdataend'] = $ThisFileInfo['avdataend_tmp'];
         unset($ThisFileInfo['avdataend_tmp']);
     }
     if (!isset($ThisFileInfo['bitrate']) && isset($ThisFileInfo['playtime_seconds'])) {
         $ThisFileInfo['bitrate'] = ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8 / $ThisFileInfo['playtime_seconds'];
     }
     if (isset($ThisFileInfo['bitrate']) && !isset($ThisFileInfo['audio']['bitrate']) && !isset($ThisFileInfo['quicktime']['video'])) {
         $ThisFileInfo['audio']['bitrate'] = $ThisFileInfo['bitrate'];
     }
     if (!empty($ThisFileInfo['playtime_seconds']) && !isset($ThisFileInfo['video']['frame_rate']) && !empty($ThisFileInfo['quicktime']['stts_framecount'])) {
         foreach ($ThisFileInfo['quicktime']['stts_framecount'] as $key => $samples_count) {
             $samples_per_second = $samples_count / $ThisFileInfo['playtime_seconds'];
             if ($samples_per_second > 240) {
                 // has to be audio samples
             } else {
                 $ThisFileInfo['video']['frame_rate'] = $samples_per_second;
                 break;
             }
         }
     }
//.........這裏部分代碼省略.........
開發者ID:sahartak,項目名稱:newsroyal,代碼行數:101,代碼來源:module.audio-video.quicktime.php

示例13: 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

示例14: Analyze

 public function Analyze()
 {
     $info =& $this->getid3->info;
     // initialize these values to an empty array, otherwise they default to NULL
     // and you can't append array values to a NULL value
     $info['riff'] = array('raw' => array());
     // Shortcuts
     $thisfile_riff =& $info['riff'];
     $thisfile_riff_raw =& $thisfile_riff['raw'];
     $thisfile_audio =& $info['audio'];
     $thisfile_video =& $info['video'];
     $thisfile_audio_dataformat =& $thisfile_audio['dataformat'];
     $thisfile_riff_audio =& $thisfile_riff['audio'];
     $thisfile_riff_video =& $thisfile_riff['video'];
     $Original['avdataoffset'] = $info['avdataoffset'];
     $Original['avdataend'] = $info['avdataend'];
     $this->fseek($info['avdataoffset']);
     $RIFFheader = $this->fread(12);
     $offset = $this->ftell();
     $RIFFtype = substr($RIFFheader, 0, 4);
     $RIFFsize = substr($RIFFheader, 4, 4);
     $RIFFsubtype = substr($RIFFheader, 8, 4);
     switch ($RIFFtype) {
         case 'FORM':
             // AIFF, AIFC
             $info['fileformat'] = 'aiff';
             $thisfile_riff['header_size'] = $this->EitherEndian2Int($RIFFsize);
             $thisfile_riff[$RIFFsubtype] = $this->ParseRIFF($offset, $offset + $thisfile_riff['header_size'] - 4);
             break;
         case 'RIFF':
             // AVI, WAV, etc
         // AVI, WAV, etc
         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
             $info['fileformat'] = 'riff';
             $thisfile_riff['header_size'] = $this->EitherEndian2Int($RIFFsize);
             if ($RIFFsubtype == 'RMP3') {
                 // RMP3 is identical to WAVE, just renamed. Used by [unknown program] when creating RIFF-MP3s
                 $RIFFsubtype = 'WAVE';
             }
             $thisfile_riff[$RIFFsubtype] = $this->ParseRIFF($offset, $offset + $thisfile_riff['header_size'] - 4);
             if ($info['avdataend'] - $info['filesize'] == 1) {
                 // LiteWave appears to incorrectly *not* pad actual output file
                 // to nearest WORD boundary so may appear to be short by one
                 // byte, in which case - skip warning
                 $info['avdataend'] = $info['filesize'];
             }
             $nextRIFFoffset = $Original['avdataoffset'] + 8 + $thisfile_riff['header_size'];
             // 8 = "RIFF" + 32-bit offset
             while ($nextRIFFoffset < min($info['filesize'], $info['avdataend'])) {
                 if (!getid3_lib::intValueSupported($nextRIFFoffset + 1024)) {
                     $info['error'][] = 'AVI extends beyond ' . round(PHP_INT_MAX / 1073741824) . 'GB and PHP filesystem functions cannot read that far, playtime is probably wrong';
                     $info['warning'][] = '[avdataend] value may be incorrect, multiple AVIX chunks may be present';
                     break;
                 } else {
                     $this->fseek($nextRIFFoffset);
                     $nextRIFFheader = $this->fread(12);
                     if ($nextRIFFoffset == $info['avdataend'] - 1) {
                         if (substr($nextRIFFheader, 0, 1) == "") {
                             // RIFF padded to WORD boundary, we're actually already at the end
                             break;
                         }
                     }
                     $nextRIFFheaderID = substr($nextRIFFheader, 0, 4);
                     $nextRIFFsize = $this->EitherEndian2Int(substr($nextRIFFheader, 4, 4));
                     $nextRIFFtype = substr($nextRIFFheader, 8, 4);
                     $chunkdata = array();
                     $chunkdata['offset'] = $nextRIFFoffset + 8;
                     $chunkdata['size'] = $nextRIFFsize;
                     $nextRIFFoffset = $chunkdata['offset'] + $chunkdata['size'];
                     switch ($nextRIFFheaderID) {
                         case 'RIFF':
                             $info['avdataend'] = $nextRIFFoffset;
                             if (!getid3_lib::intValueSupported($info['avdataend'])) {
                                 $info['error'][] = 'AVI extends beyond ' . round(PHP_INT_MAX / 1073741824) . 'GB and PHP filesystem functions cannot read that far, playtime is probably wrong';
                                 $info['warning'][] = '[avdataend] value may be incorrect, multiple AVIX chunks may be present';
                             }
                             $chunkdata['chunks'] = $this->ParseRIFF($chunkdata['offset'] + 4, $nextRIFFoffset);
                             if (!isset($thisfile_riff[$nextRIFFtype])) {
                                 $thisfile_riff[$nextRIFFtype] = array();
                             }
                             $thisfile_riff[$nextRIFFtype][] = $chunkdata;
                             break;
                         case 'JUNK':
                             // ignore
                             $thisfile_riff[$nextRIFFheaderID][] = $chunkdata;
                             break;
                         case 'IDVX':
                             $info['divxtag']['comments'] = self::ParseDIVXTAG($this->fread($chunkdata['size']));
                             break;
                         default:
                             if ($info['filesize'] == $chunkdata['offset'] - 8 + 128) {
                                 $DIVXTAG = $nextRIFFheader . $this->fread(128 - 12);
                                 if (substr($DIVXTAG, -7) == 'DIVXTAG') {
                                     // DIVXTAG is supposed to be inside an IDVX chunk in a LIST chunk, but some bad encoders just slap it on the end of a file
                                     $this->warning('Found wrongly-structured DIVXTAG at offset ' . ($this->ftell() - 128) . ', parsing anyway');
                                     $info['divxtag']['comments'] = self::ParseDIVXTAG($DIVXTAG);
//.........這裏部分代碼省略.........
開發者ID:skubij,項目名稱:omxplayer-ui,代碼行數:101,代碼來源:module.audio-video.riff.php

示例15: hash_data

 static function hash_data($file, $offset, $end, $algorithm)
 {
     if (!getid3_lib::intValueSupported($end)) {
         return false;
     }
     switch ($algorithm) {
         case 'md5':
             $hash_function = 'md5_file';
             $unix_call = 'md5sum';
             $windows_call = 'md5sum.exe';
             $hash_length = 32;
             break;
         case 'sha1':
             $hash_function = 'sha1_file';
             $unix_call = 'sha1sum';
             $windows_call = 'sha1sum.exe';
             $hash_length = 40;
             break;
         default:
             throw new Exception('Invalid algorithm (' . $algorithm . ') in getid3_lib::hash_data()');
             break;
     }
     $size = $end - $offset;
     while (true) {
         if (GETID3_OS_ISWINDOWS) {
             // It seems that sha1sum.exe for Windows only works on physical files, does not accept piped data
             // Fall back to create-temp-file method:
             if ($algorithm == 'sha1') {
                 break;
             }
             $RequiredFiles = array('cygwin1.dll', 'head.exe', 'tail.exe', $windows_call);
             foreach ($RequiredFiles as $required_file) {
                 if (!is_readable(GETID3_HELPERAPPSDIR . $required_file)) {
                     // helper apps not available - fall back to old method
                     break;
                 }
             }
             $commandline = GETID3_HELPERAPPSDIR . 'head.exe -c ' . $end . ' "' . escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $file)) . '" | ';
             $commandline .= GETID3_HELPERAPPSDIR . 'tail.exe -c ' . $size . ' | ';
             $commandline .= GETID3_HELPERAPPSDIR . $windows_call;
         } else {
             $commandline = 'head -c' . $end . ' ' . escapeshellarg($file) . ' | ';
             $commandline .= 'tail -c' . $size . ' | ';
             $commandline .= $unix_call;
         }
         if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
             $ThisFileInfo['warning'][] = 'PHP running in Safe Mode - backtick operator not available, using slower non-system-call ' . $algorithm . ' algorithm';
             break;
         }
         return substr(`{$commandline}`, 0, $hash_length);
     }
     // try to create a temporary file in the system temp directory - invalid dirname should force to system temp dir
     if (($data_filename = tempnam(GETID3_TEMP_DIR, 'getID3')) === false) {
         // can't find anywhere to create a temp file, just die
         return false;
     }
     // Init
     $result = false;
     // copy parts of file
     ob_start();
     if ($fp = fopen($file, 'rb')) {
         ob_end_clean();
         ob_start();
         if ($fp_data = fopen($data_filename, 'wb')) {
             fseek($fp, $offset, SEEK_SET);
             $byteslefttowrite = $end - $offset;
             while ($byteslefttowrite > 0 && ($buffer = fread($fp, GETID3_FREAD_BUFFER_SIZE))) {
                 $byteswritten = fwrite($fp_data, $buffer, $byteslefttowrite);
                 $byteslefttowrite -= $byteswritten;
             }
             fclose($fp_data);
             $result = $hash_function($data_filename);
         } else {
             $errormessage = ob_get_contents();
             ob_end_clean();
         }
         fclose($fp);
     } else {
         $errormessage = ob_get_contents();
         ob_end_clean();
     }
     unlink($data_filename);
     return $result;
 }
開發者ID:BGCX261,項目名稱:zillatek-project-svn-to-git,代碼行數:84,代碼來源:getid3.lib.php


注:本文中的getid3_lib::intValueSupported方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。