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


PHP getID3类代码示例

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


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

示例1: metadata_video

/**
 * Fonction de récupération des métadonnées sur les fichiers vidéo
 * appelée à l'insertion en base dans le plugin medias (inc/renseigner_document)
 *
 * @param string $file
 *    Le chemin du fichier à analyser
 * @return array $metas
 *    Le tableau comprenant les différentes metas à mettre en base
 */
function metadata_video($file)
{
    $meta = array();
    include_spip('lib/getid3/getid3');
    $getID3 = new getID3();
    $getID3->setOption(array('tempdir' => _DIR_TMP));
    // Scan file - should parse correctly if file is not corrupted
    $file_info = $getID3->analyze($file);
    /**
     * Les pistes vidéos
     */
    if (isset($file_info['video'])) {
        $id3['hasvideo'] = 'oui';
        if (isset($file_info['video']['resolution_x'])) {
            $meta['largeur'] = $file_info['video']['resolution_x'];
        }
        if (isset($file_info['video']['resolution_y'])) {
            $meta['hauteur'] = $file_info['video']['resolution_y'];
        }
        if (isset($file_info['video']['frame_rate'])) {
            $meta['framerate'] = $file_info['video']['frame_rate'];
        }
    }
    if (isset($file_info['playtime_seconds'])) {
        $meta['duree'] = round($file_info['playtime_seconds'], 0);
    }
    return $meta;
}
开发者ID:xablen,项目名称:Semaine14_SPIP_test,代码行数:37,代码来源:video.php

示例2: fileinfo

 function fileinfo($file)
 {
     App::import('Vendor', 'Paperclip.getid3/getid3');
     $getID3 = new getID3();
     $file_class = new File($file['tmp_name']);
     $fileinfo = $getID3->analyze($file['tmp_name']);
     if (!empty($fileinfo['mime_type'])) {
         $results['content_type'] = $fileinfo['mime_type'];
     }
     if (!empty($fileinfo['jpg']['exif']['COMPUTED']['Height']) && !empty($fileinfo['jpg']['exif']['COMPUTED']['Width'])) {
         $results['width'] = $fileinfo['jpg']['exif']['COMPUTED']['Width'];
         $results['height'] = $fileinfo['jpg']['exif']['COMPUTED']['Height'];
     }
     if (!empty($fileinfo['png']['IHDR']['width']) && !empty($fileinfo['png']['IHDR']['height'])) {
         $results['width'] = $fileinfo['png']['IHDR']['width'];
         $results['height'] = $fileinfo['png']['IHDR']['height'];
     }
     if (!empty($fileinfo['gif']['header']['raw']['width']) && !empty($fileinfo['gif']['header']['raw']['height'])) {
         $results['width'] = $fileinfo['gif']['header']['raw']['width'];
         $results['height'] = $fileinfo['gif']['header']['raw']['height'];
     }
     $results['filename'] = $file_class->safe($file['name']);
     $results['filesize'] = $file_class->size();
     return $results;
 }
开发者ID:Emerson,项目名称:PaperclipPHP,代码行数:25,代码来源:asset.php

示例3: index

 public function index()
 {
     require_once APPPATH . 'libraries/getid3/getid3.php';
     $getID3 = new getID3();
     // Analyze file and store returned data in $ThisFileInfo
     $ThisFileInfo = $getID3->analyze('musica/rick/Natalia Kills - Trouble.mp3');
     print_r($ThisFileInfo['tags']);
 }
开发者ID:nuukcillo,项目名称:MusicBox-,代码行数:8,代码来源:testid3.php

示例4: scanID3

 private function scanID3($file)
 {
     $res = false;
     $getID3 = new \getID3();
     $id3 = $getID3->analyze($file);
     if (isset($id3["fileformat"]) && $id3["fileformat"] == "mp3") {
         $res = array();
         $res["file"] = $file;
         $res["album"] = $id3["tags"]["id3v2"]["album"][0];
         $res["title"] = $id3["tags"]["id3v2"]["title"][0];
         if (isset($id3["tags"]["id3v2"]["artist"][0])) {
             $res["artist"] = $id3["tags"]["id3v2"]["artist"][0];
         } else {
             $res["artist"] = "Unknown";
         }
         $res["trackNumber"] = $id3["tags"]["id3v2"]["track_number"][0];
         $res["link"] = str_replace(["_aaID_", "_trackID_"], [md5($res["artist"] . "_" . $res["album"]), $res["trackNumber"]], $this->config["link"]);
         if (strpos($res["trackNumber"], "/")) {
             $res["trackNumber"] = substr($res["trackNumber"], 0, strpos($res["trackNumber"], "/"));
         }
         $res["trackNumber"] = sprintf("%04d", $res["trackNumber"]);
     } else {
         #var_dump($file);
     }
     return $res;
 }
开发者ID:sspssp,项目名称:audiobookServer,代码行数:26,代码来源:Filesystem.php

示例5: getFileInfo

 function getFileInfo($absolute_path = null)
 {
     if (file_exists($absolute_path)) {
         $getID3 = new getID3();
         return $getID3->analyze($absolute_path);
     } else {
         return false;
     }
 }
开发者ID:anandsrijan,项目名称:mahariya-001,代码行数:9,代码来源:CommonComponent.php

示例6: CombineMultipleMP3sTo

function CombineMultipleMP3sTo($FilenameOut, $FilenamesIn)
{
    foreach ($FilenamesIn as $nextinputfilename) {
        if (!is_readable($nextinputfilename)) {
            echo 'Cannot read "' . $nextinputfilename . '"<BR>';
            return false;
        }
    }
    if (!is_writable($FilenameOut)) {
        echo 'Cannot write "' . $FilenameOut . '"<BR>';
        return false;
    }
    require_once '../getid3/getid3.php';
    ob_start();
    if ($fp_output = fopen($FilenameOut, 'wb')) {
        ob_end_clean();
        // Initialize getID3 engine
        $getID3 = new getID3();
        foreach ($FilenamesIn as $nextinputfilename) {
            $CurrentFileInfo = $getID3->analyze($nextinputfilename);
            if ($CurrentFileInfo['fileformat'] == 'mp3') {
                ob_start();
                if ($fp_source = fopen($nextinputfilename, 'rb')) {
                    ob_end_clean();
                    $CurrentOutputPosition = ftell($fp_output);
                    // copy audio data from first file
                    fseek($fp_source, $CurrentFileInfo['avdataoffset'], SEEK_SET);
                    while (!feof($fp_source) && ftell($fp_source) < $CurrentFileInfo['avdataend']) {
                        fwrite($fp_output, fread($fp_source, 32768));
                    }
                    fclose($fp_source);
                    // trim post-audio data (if any) copied from first file that we don't need or want
                    $EndOfFileOffset = $CurrentOutputPosition + ($CurrentFileInfo['avdataend'] - $CurrentFileInfo['avdataoffset']);
                    fseek($fp_output, $EndOfFileOffset, SEEK_SET);
                    ftruncate($fp_output, $EndOfFileOffset);
                } else {
                    $errormessage = ob_get_contents();
                    ob_end_clean();
                    echo 'failed to open ' . $nextinputfilename . ' for reading';
                    fclose($fp_output);
                    return false;
                }
            } else {
                echo $nextinputfilename . ' is not MP3 format';
                fclose($fp_output);
                return false;
            }
        }
    } else {
        $errormessage = ob_get_contents();
        ob_end_clean();
        echo 'failed to open ' . $FilenameOut . ' for writing';
        return false;
    }
    fclose($fp_output);
    return true;
}
开发者ID:Nattpyre,项目名称:rocketfiles,代码行数:57,代码来源:demo.joinmp3.php

示例7: analyzeFile

 public static function analyzeFile($filename, $mediaInfo = array())
 {
     // Initialize getID3 engine
     $getID3 = new getID3();
     $mediaInfo['id3Info'] = $getID3->analyze($filename);
     $mediaInfo['width'] = 0;
     $mediaInfo['height'] = 0;
     $mediaInfo['duration'] = $mediaInfo['id3Info']['playtime_seconds'];
     return $mediaInfo;
 }
开发者ID:nbey,项目名称:Emergence-Skeleton,代码行数:10,代码来源:AudioMedia.class.php

示例8: __construct

 /**
  * Mx_getid3 function.
  *
  * @access public
  * @return void
  */
 public function __construct()
 {
     $this->EE =& get_instance();
     $conds = array();
     $file = !$this->EE->TMPL->fetch_param('file') ? FALSE : $this->EE->TMPL->fetch_param('file');
     $tagdata = $this->EE->TMPL->tagdata;
     $this->cache_lifetime = $this->EE->TMPL->fetch_param('refresh', $this->cache_lifetime) * 60;
     if ($tagdata != '' && $file) {
         $debug = !$this->EE->TMPL->fetch_param('debug') ? FALSE : TRUE;
         if ($debug || !($this->objTmp = $this->_readCache(md5($file)))) {
             $getID3 = new getID3();
             $response = $getID3->analyze($file);
             $this->objTmp = self::_force_array($response);
             $this->_createCacheFile(json_encode($this->objTmp), md5($file));
         } else {
             $this->objTmp = json_decode($this->objTmp, true);
         }
         if ($debug) {
             $this->return_data .= $this->debug_table();
         }
         //self::_force_array($response)
         return $this->return_data .= $this->EE->TMPL->parse_variables($tagdata, $this->objTmp);
     }
     return;
 }
开发者ID:MaxLazar,项目名称:mx-getid3-ee3,代码行数:31,代码来源:pi.mx_getid3.php

示例9: getAudioInfo

 public static function getAudioInfo($path)
 {
     if (!is_file($path)) {
         kohana::log('debug', 'Asked for audio info on non-existant file: "' . $path . '"');
         return FALSE;
     }
     $id3 = new getID3();
     $info = $id3->analyze($path);
     if (!empty($info['error'])) {
         kohana::log('debug', 'Unable to analyze "' . $path . '" because ' . implode(' - ', $info['error']));
         return FALSE;
     }
     switch ($info['audio']['dataformat']) {
         case 'wav':
             return array('type' => $info['audio']['dataformat'], 'compression' => number_format($info['audio']['compression_ratio'], 4), 'channels' => $info['audio']['channels'], 'rates' => $info['audio']['streams'][0]['sample_rate'], 'byterate' => $info['audio']['bitrate'], 'bits' => $info['audio']['bits_per_sample'], 'size' => $info['filesize'], 'length' => number_format($info['playtime_seconds'], 4));
         case 'mp1':
             return array('type' => $info['audio']['dataformat'], 'compression' => number_format($info['audio']['compression_ratio'], 4), 'channels' => $info['audio']['channels'], 'rates' => $info['audio']['streams'][0]['sample_rate'], 'byterate' => $info['audio']['bitrate'], 'bits' => $info['audio']['bits_per_sample'], 'size' => $info['filesize'], 'length' => number_format($info['playtime_seconds'], 4));
         case 'mp3':
             return array('type' => $info['audio']['dataformat'], 'compression' => number_format($info['audio']['compression_ratio'], 4), 'channels' => $info['audio']['channels'], 'rates' => $info['audio']['sample_rate'], 'byterate' => $info['audio']['bitrate'], 'bits' => NULL, 'size' => $info['filesize'], 'length' => number_format($info['playtime_seconds'], 4));
         case 'ogg':
             return array('type' => $info['audio']['dataformat'], 'compression' => number_format($info['audio']['compression_ratio'], 4), 'channels' => $info['audio']['channels'], 'rates' => $info['audio']['sample_rate'], 'byterate' => $info['audio']['bitrate'], 'bits' => NULL, 'size' => $info['filesize'], 'length' => number_format($info['playtime_seconds'], 4));
         default:
             kohana::log('error', 'Unhandled media type(' . $info['audio']['dataformat'] . ') for file ' . $path);
     }
     return FALSE;
 }
开发者ID:swk,项目名称:bluebox,代码行数:26,代码来源:MediaLib.php

示例10: tag_mp3

function tag_mp3($filename, $songname, $albumname, $artist, $time)
{
    $TaggingFormat = 'UTF-8';
    // Initialize getID3 engine
    $getID3 = new getID3();
    $getID3->setOption(array('encoding' => $TaggingFormat));
    getid3_lib::IncludeDependency('/var/www/html/getid3/getid3/write.php', __FILE__, true);
    // Initialize getID3 tag-writing module
    $tagwriter = new getid3_writetags();
    $tagwriter->filename = $filename;
    $tagwriter->tagformats = array('id3v1', 'id3v2.3');
    // set various options (optional)
    $tagwriter->overwrite_tags = true;
    $tagwriter->tag_encoding = $TaggingFormat;
    $tagwriter->remove_other_tags = true;
    // populate data array
    $TagData['title'][] = $songname;
    $TagData['artist'][] = $artist;
    $TagData['album'][] = $albumname;
    $tagwriter->tag_data = $TagData;
    // write tags
    if ($tagwriter->WriteTags()) {
        echo 'Successfully wrote tags<br>';
        if (!empty($tagwriter->warnings)) {
            echo 'There were some warnings:<br>' . implode('<br><br>', $tagwriter->warnings);
        }
    } else {
        echo 'Failed to write tags!<br>' . implode('<br><br>', $tagwriter->errors);
    }
}
开发者ID:houndbee,项目名称:phqueue,代码行数:30,代码来源:mp3id3write.php

示例11: add

 function add($item)
 {
     global $config;
     if ($item['url']) {
         // this is a remote file
         if ($config['httpStreaming']) {
             $lines = file($item['url']);
             foreach ($lines as $line) {
                 if (!empty($line)) {
                     $this->audioFiles[] = array('url' => $line);
                 }
             }
         } else {
             // nothing to do
             // not tested for Tamburine
         }
     } else {
         // this is a local file
         // CHANGED BY BUDDHAFLY 06-02-20
         if (!in_array(sotf_File::getExtension($item['path']), $config['skipGetID3FileTypes'])) {
             $getID3 = new getID3();
             $mp3info = $getID3->analyze($item['path']);
             getid3_lib::CopyTagsToComments($mp3info);
         } else {
             $fileinfo['video'] = true;
         }
         //$mp3info = GetAllFileInfo($item['path']);
         //debug('mp3info', $mp3info);
         // CHANGED BY BUDDHAFLY 06-02-20
         $bitrate = (string) $mp3info['bitrate'];
         if (!$bitrate) {
             raiseError("Could not determine bitrate, maybe this audio is temporarily unavailable");
         }
         $item['bitrate'] = $bitrate;
         if ($config['httpStreaming']) {
             //$tmpFileName = 'au_' . $item['id'] . '_' . ($item['name'] ? $item['name'] : basename($item['path']));
             $tmpFileName = 'au_' . $item['id'] . '_' . basename($item['path']);
             $tmpFile = $config['tmpDir'] . "/{$tmpFileName}";
             $file = @readlink($tmpFile);
             if ($file) {
                 if (!is_readable($file)) {
                     logError("Bad symlink: {$tmpFile} to {$file}");
                     unlink($tmpFile);
                     $file = false;
                 }
             }
             if (!$file) {
                 if (!symlink($item['path'], $tmpFile)) {
                     raiseError("symlink failed in tmp dir");
                 }
             }
             $item['url'] = $config['tmpUrl'] . "/{$tmpFileName}";
         }
         $this->totalLength += $mp3info["playtime_seconds"];
         $this->audioFiles[] = $item;
     }
 }
开发者ID:BackupTheBerlios,项目名称:sotf-svn,代码行数:57,代码来源:sotf_PlayList.class.php

示例12: extractDataFromFilename

 protected function extractDataFromFilename($filename)
 {
     if (empty($filename)) {
         return null;
     }
     $id3 = new getID3();
     $data = $id3->analyze($filename);
     getid3_lib::CopyTagsToComments($data);
     return $data;
 }
开发者ID:tractorcow,项目名称:silverstripe-mediadata,代码行数:10,代码来源:MediaFileInformation.php

示例13: sotf_AudioFile

 /**
  * Sets up sotf_AudioFile object
  *
  * @constructor sotf_AudioFile
  * @param	string	$path	Path of the file
  */
 function sotf_AudioFile($path)
 {
     $parent = get_parent_class($this);
     parent::$parent($path);
     // Call the constructor of the parent class. lk. super()
     // CHANGED BY BUDDHAFLY 06-05-12
     $getID3 = new getID3();
     $fileinfo = $getID3->analyze($this->path);
     getid3_lib::CopyTagsToComments($fileinfo);
     //$fileinfo = GetAllFileInfo($this->path);
     $this->allInfo = $fileInfo;
     //if ($audioinfo["fileformat"] == 'mp3' || $audioinfo["fileformat"] == 'ogg') {
     //debug("finfo", $fileinfo);
     if (isset($fileinfo['audio'])) {
         $audioinfo = $fileinfo['audio'];
         $this->type = "audio";
         $this->format = $fileinfo["fileformat"];
         if ($audioinfo["bitrate_mode"] == 'vbr') {
             $this->bitrate = "VBR";
         }
         $this->bitrate = round($audioinfo["bitrate"] / 1000);
         $this->average_bitrate = round($audioinfo["bitrate"] / 1000);
         $this->samplerate = $audioinfo["sample_rate"];
         $this->channels = $audioinfo["channels"];
         $this->duration = round($fileinfo["playtime_seconds"]);
         $this->mimetype = $this->determineMimeType($this->format);
     }
 }
开发者ID:BackupTheBerlios,项目名称:sotf-svn,代码行数:34,代码来源:sotf_AudioFile.class.php

示例14: getImage

 /**
  * Extract the image data (if any) from a file
  *
  * @param string $filename
  *
  * @return Image|null
  */
 private static function getImage($filename)
 {
     // check the file
     if (!file_exists($filename)) {
         return null;
     }
     // scan the file
     $getID3 = new getID3();
     // Analyze file and store returned data in $ThisFileInfo
     $file_info = $getID3->analyze($filename);
     // try to extract the album artwork (if any)
     // find the artwork in the $file_info structure
     $artwork = null;
     // try the different places in which I've found artwork
     if (isset($file_info['comments']['picture'][0]['data'])) {
         $artwork = $file_info['comments']['picture'][0]['data'];
     } else {
         if (isset($file_info['id3v2']['APIC'][0]['data'])) {
             $artwork = $file_info['id3v2']['APIC'][0]['data'];
         }
     }
     // did we find some artwork?
     if (!$artwork) {
         return null;
     }
     // create the image object and return it
     return imagecreatefromstring($artwork);
 }
开发者ID:monstergfx,项目名称:pi-music,代码行数:35,代码来源:Scan.php

示例15: updateTypeByGetId3

 public function updateTypeByGetId3()
 {
     $getID3 = new getID3();
     $info = $getID3->analyze(public_path($this->url));
     $this->type = isset($info['mime_type']) ? $info['mime_type'] : null;
     return $this;
 }
开发者ID:OpenSISE,项目名称:Amaoto-L4-WebSite,代码行数:7,代码来源:AmaotoFile.php


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