本文整理汇总了PHP中getID3::analyze方法的典型用法代码示例。如果您正苦于以下问题:PHP getID3::analyze方法的具体用法?PHP getID3::analyze怎么用?PHP getID3::analyze使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类getID3
的用法示例。
在下文中一共展示了getID3::analyze方法的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;
}
示例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;
}
示例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']);
}
示例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;
}
示例5: getFileInfo
function getFileInfo($absolute_path = null)
{
if (file_exists($absolute_path)) {
$getID3 = new getID3();
return $getID3->analyze($absolute_path);
} else {
return false;
}
}
示例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;
}
示例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;
}
示例8: extract
/**
* get metadata info for a media file
*
* @param $path
* @return array
*/
public function extract($path)
{
if (ini_get('allow_url_fopen')) {
$file = \OC\Files\Filesystem::getView()->getAbsolutePath($path);
$data = @$this->getID3->analyze('oc://' . $file);
} else {
// Fallback to the local FS
$file = \OC\Files\Filesystem::getLocalFile($path);
}
\getid3_lib::CopyTagsToComments($data);
return $data;
}
示例9: __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;
}
示例10: 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;
}
示例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;
}
}
示例12: extractInformation
/**
* Extract file meta data
*
* @param Audio $audio audio file instance
* @return array
*/
protected function extractInformation(Audio $audio)
{
$tmpFile = $this->temp->create($audio->getContent());
$info = $this->reader->analyze($tmpFile->getPathname());
$tmpFile->destroy();
if (isset($info['audio']['streams'])) {
unset($info['audio']['streams']);
}
return [$info['audio'], $info['playtime_seconds'], $info['bitrate']];
}
示例13: extractDataFromFilename
protected function extractDataFromFilename($filename)
{
if (empty($filename)) {
return null;
}
$id3 = new getID3();
$data = $id3->analyze($filename);
getid3_lib::CopyTagsToComments($data);
return $data;
}
示例14: getMediaInfo
public static function getMediaInfo($fileName)
{
$mediaInfo = new self();
$id3 = new \getID3();
$id3->encoding = 'UTF-8';
$finfo = $id3->analyze($fileName);
if (isset($finfo['video']['resolution_x'])) {
$mediaInfo->resolution_x = $finfo['video']['resolution_x'];
}
if (isset($finfo['video']['resolution_y'])) {
$mediaInfo->resolution_y = $finfo['video']['resolution_y'];
}
if (isset($finfo['video']['frame_rate'])) {
$mediaInfo->frame_rate = $finfo['video']['frame_rate'];
}
if (isset($finfo['encoding'])) {
$mediaInfo->encoding = $finfo['encoding'];
}
if (isset($finfo['playtime_string'])) {
$mediaInfo->playtime = $finfo['playtime_string'];
}
if (isset($finfo['bitrate'])) {
$mediaInfo->bitrate = $finfo['bitrate'];
}
if (isset($finfo['video']['bits_per_sample'])) {
$mediaInfo->bits_per_sample = $finfo['video']['bits_per_sample'];
}
return $mediaInfo;
}
示例15: getId3
/**
* Get ID3 Details
*
* @param string $path
*
* @return array
*/
protected function getId3($path)
{
$getID3 = new \getID3();
$analyze = $getID3->analyze($path);
\getid3_lib::CopyTagsToComments($analyze);
return $analyze;
}