Ejemplo n.º 1
32
 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;
 }
Ejemplo n.º 2
5
/**
 * 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;
}
Ejemplo n.º 3
4
 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']);
 }
Ejemplo n.º 4
3
 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;
 }
Ejemplo n.º 5
3
 function getFileInfo($absolute_path = null)
 {
     if (file_exists($absolute_path)) {
         $getID3 = new getID3();
         return $getID3->analyze($absolute_path);
     } else {
         return false;
     }
 }
Ejemplo n.º 6
3
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;
}
Ejemplo n.º 7
3
 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;
 }
Ejemplo n.º 8
2
 /**
  * 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;
 }
Ejemplo n.º 9
2
 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;
 }
Ejemplo n.º 10
2
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);
    }
}
 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;
     }
 }
 protected function extractDataFromFilename($filename)
 {
     if (empty($filename)) {
         return null;
     }
     $id3 = new getID3();
     $data = $id3->analyze($filename);
     getid3_lib::CopyTagsToComments($data);
     return $data;
 }
 /**
  * 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);
     }
 }
Ejemplo n.º 14
1
 /**
  * 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);
 }
Ejemplo n.º 15
1
 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;
 }
Ejemplo n.º 16
1
function import_show($showid, $dir, $type)
{
    // Initialize getID3 engine
    $getID3 = new getID3();
    // Read files and directories
    if (is_dir($dir)) {
        if ($dh = opendir($dir)) {
            while (($file = readdir($dh)) !== false) {
                $full_name = $dir . "/" . $file;
                if (is_file($full_name) || $file[0] != '.') {
                    $ThisFileInfo = $getID3->analyze($full_name);
                    if ($ThisFileInfo['fileformat'] == "mp3") {
                        getid3_lib::CopyTagsToComments($ThisFileInfo);
                        $album = mysql_real_escape_string(@implode(@$ThisFileInfo['comments_html']['album']));
                        $play_time = mysql_real_escape_string(@$ThisFileInfo['playtime_seconds']);
                        $title_name = mysql_real_escape_string(@implode(@$ThisFileInfo['comments_html']['title']));
                        $artist_name = mysql_real_escape_string(@implode(@$ThisFileInfo['comments_html']['artist']));
                        $full_name = mysql_real_escape_string($full_name);
                        if ($id = song_non_existant($full_name, $showid)) {
                            $artist_id = check_or_insert_artist($artist_name);
                            insert_into_tunes($title_name, $artist_id, $full_name, $album, $play_time, $showid, -1, $type);
                        } else {
                            $artist_id = check_or_insert_artist($artist_name);
                            update_tunes($title_name, $id, $artist_id, $full_name, $album, $play_time);
                        }
                    }
                }
            }
            closedir($dh);
        }
    }
}
Ejemplo n.º 17
1
 /**
  * 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;
 }
Ejemplo n.º 18
1
 function DeleteLyrics3()
 {
     // Initialize getID3 engine
     $getID3 = new getID3();
     $ThisFileInfo = $getID3->analyze($this->filename);
     if (isset($ThisFileInfo['lyrics3']['tag_offset_start']) && isset($ThisFileInfo['lyrics3']['tag_offset_end'])) {
         if (is_readable($this->filename) && is_writable($this->filename) && is_file($this->filename) && ($fp = fopen($this->filename, 'a+b'))) {
             flock($fp, LOCK_EX);
             $oldignoreuserabort = ignore_user_abort(true);
             fseek($fp, $ThisFileInfo['lyrics3']['tag_offset_end'], SEEK_SET);
             $DataAfterLyrics3 = '';
             if ($ThisFileInfo['filesize'] > $ThisFileInfo['lyrics3']['tag_offset_end']) {
                 $DataAfterLyrics3 = fread($fp, $ThisFileInfo['filesize'] - $ThisFileInfo['lyrics3']['tag_offset_end']);
             }
             ftruncate($fp, $ThisFileInfo['lyrics3']['tag_offset_start']);
             if (!empty($DataAfterLyrics3)) {
                 fseek($fp, $ThisFileInfo['lyrics3']['tag_offset_start'], SEEK_SET);
                 fwrite($fp, $DataAfterLyrics3, strlen($DataAfterLyrics3));
             }
             flock($fp, LOCK_UN);
             fclose($fp);
             ignore_user_abort($oldignoreuserabort);
             return true;
         } else {
             $this->errors[] = 'Cannot fopen(' . $this->filename . ', "a+b")';
             return false;
         }
     }
     // no Lyrics3 present
     return true;
 }
Ejemplo n.º 19
1
 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;
 }
Ejemplo n.º 20
1
	function getMetadata( $image, $path ) {
		// Create new id3 object:		
		$getID3 = new getID3();
		
		// Don't grab stuff we don't use: 
		$getID3->option_tag_id3v1         = false;  // Read and process ID3v1 tags
		$getID3->option_tag_id3v2         = false;  // Read and process ID3v2 tags
		$getID3->option_tag_lyrics3       = false;  // Read and process Lyrics3 tags
		$getID3->option_tag_apetag        = false;  // Read and process APE tags
		$getID3->option_tags_process      = false;  // Copy tags to root key 'tags' and encode to $this->encoding
		$getID3->option_tags_html         = false;  // Copy tags to root key 'tags_html' properly translated from various encodings to HTML entities
	
		// Analyze file to get metadata structure:
		$id3 = $getID3->analyze( $path );
		
		// Unset some parts of id3 that are too detailed and matroska specific:
		unset( $id3['matroska'] ); 
		// remove file paths
		unset( $id3['filename'] );
		unset( $id3['filepath'] );
		unset( $id3['filenamepath']);

		// Update the version
		$id3['version'] = self::METADATA_VERSION;
		
		return serialize( $id3 );
	}	
Ejemplo n.º 21
1
 protected function invokeHandler()
 {
     $pos = strpos($this->file->mime, '/');
     $mediatype = substr($this->file->mime, 0, strlen($this->file->mime) - $pos);
     $this->smarty->assign('mediatype', $mediatype);
     $specific = array();
     $getid3 = new getID3();
     $infos = $getid3->analyze($this->file->getAbsPath());
     $width = 320;
     $height = 240;
     if ($mediatype == 'video') {
         $specific['audioBitrate'] = Utils::formatBitrate($infos['audio']['bitrate']);
         if (!empty($infos['video']['display_x']) && !empty($infos['video']['display_y'])) {
             $width = $infos['video']['display_x'];
             $height = $infos['video']['display_y'];
             $specific['ResolutionX'] = $infos['video']['resolution_x'] . ' px';
             $specific['ResolutionY'] = $infos['video']['resolution_y'] . ' px';
             $specific['Length'] = $infos['playtime_string'] . ' min';
         }
         $this->smarty->assign("options", 'id="player1" width="' . $width . '" height="' . $height . '" controls="controls"');
     } elseif ($mediatype == 'audio') {
         $specific['Bitrate'] = Utils::formatBitrate($infos['bitrate']);
         $specific['Length'] = $infos['playtime_string'] . ' min';
         $width = 400;
         $height = 30;
         $this->smarty->assign("options", 'id="player1" controls="controls" type="' . $this->file->mime . '"');
     }
     $this->smarty->assign('specific', $specific);
     $this->smarty->assign('mime', $this->file->mime);
     $this->smarty->assign('width', $width);
     $this->smarty->requireResource('mediaelement');
     $this->smarty->display('handler/media.tpl');
 }
Ejemplo n.º 22
1
 /**
  *
  *
  * @return array
  */
 public function getId3Data() : array
 {
     $reader = new \getID3();
     $info = $reader->analyze($this->path);
     \getid3_lib::CopyTagsToComments($info);
     return $info;
 }
Ejemplo n.º 23
1
 public function checkContentDuration($id)
 {
     $path = "/var/www/vhosts/e-taliano.tv/httpdocs/home/mediatv/_contenuti/{$id}/{$id}.flv";
     $getID3 = new getID3();
     $file = $getID3->analyze($path);
     return (int) $file['playtime_seconds'];
 }
Ejemplo n.º 24
1
 public static function tag($mp3, $image_name, $type)
 {
     $mp3_handler = new \getID3();
     $mp3_handler->setOption(['encoding' => 'UTF-8']);
     $mp3_writter = new \getid3_writetags();
     $mp3_writter->filename = Config::get('site.mp3_upload_path') . '/' . $mp3->mp3name;
     $mp3_writter->tagformats = array('id3v1', 'id3v2.3');
     $mp3_writter->overwrite_tags = true;
     $mp3_writter->tag_encoding = 'UTF-8';
     $mp3_writter->remove_other_tags = true;
     $mp3_data['title'][] = $mp3->name;
     $mp3_data['artist'][] = Config::get('site.name') . ' ' . Config::get('site.separator') . ' ' . Config::get('site.url');
     //$mp3_artist;
     $mp3_data['album'][] = Config::get('site.name') . ' ' . Config::get('site.separator') . ' ' . Config::get('site.url');
     // $mp3_data['year'][]    = $mp3_year;
     // $mp3_data['genre'][]   = $mp3_genre;
     $mp3_data['comment'][] = Config::get('site.name') . ' ' . Config::get('site.separator') . Config::get('site.url');
     if ($mp3->price == 'paid') {
         $mp3_data['attached_picture'][0]['data'] = file_get_contents(Config::get('site.image_upload_path') . '/thumbs/' . $image_name);
         $mp3_data['attached_picture'][0]['picturetypeid'] = $type;
         $mp3_data['attached_picture'][0]['mime'] = $type;
     } else {
         $mp3_data['attached_picture'][0]['data'] = file_get_contents(Config::get('site.logo'));
         $mp3_data['attached_picture'][0]['picturetypeid'] = "image/jpg";
         $mp3_data['attached_picture'][0]['mime'] = "image/jpg";
     }
     $mp3_data['attached_picture'][0]['description'] = Config::get('site.name') . ' ' . Config::get('site.separator') . ' ' . Config::get('site.description');
     $mp3_writter->tag_data = $mp3_data;
     return $mp3_writter->WriteTags();
 }
Ejemplo n.º 25
1
Archivo: 1.php Proyecto: noikiy/Bentley
function test_media_info()
{
    $filename = "1441008750.wav";
    $radio = dirname(__FILE__) . "/" . $filename;
    $getid3 = new getID3();
    $fileInfo = $getid3->analyze($radio);
    $time = $fileInfo["playtime_string"];
}
Ejemplo n.º 26
1
 public function checkContentDuration($id)
 {
     $path = "/var/www/html/ediacademy/mediagg/contenuti/{$id}/{$id}.mp4";
     $getID3 = new getID3();
     $file = $getID3->analyze($path);
     FB::log($file);
     return (int) $file['playtime_seconds'];
 }
Ejemplo n.º 27
1
 public static function readMetadata($file)
 {
     require_once __DIR__ . '/../vendor/autoload.php';
     $getID3 = new \getID3();
     $meta = $getID3->analyze($file);
     \getid3_lib::CopyTagsToComments($meta);
     return $meta;
 }
Ejemplo n.º 28
1
 private function loadInfo(string $path)
 {
     $getID3 = new getID3();
     $info = $getID3->analyze("{$path}");
     $this->author = $info['tags']['id3v1']['artist'][0] ?? null;
     $this->title = $info['tags']['id3v1']['title'][0] ?? null;
     $this->album = $info['tags']['id3v1']['album'][0] ?? null;
     $this->duration = $info['playtime_string'] ?? null;
 }
Ejemplo n.º 29
1
 function getLenght($file)
 {
     if (file_exists($file)) {
         $getID3 = new getID3();
         $ThisFileInfo = $getID3->analyze($file);
         return round($ThisFileInfo['playtime_seconds']);
     } else {
         return 0;
     }
 }
Ejemplo n.º 30
0
 /**
  * Open file
  *
  * @param \SplFileInfo $file
  *
  * @return \GravityMedia\Metadata\GetId3\Factory
  */
 public function open(\SplFileInfo $file)
 {
     if (!$this->getId3->openfile($file->getRealPath())) {
         $this->close();
         throw new \RuntimeException(sprintf('Error while opening file "%s": %s.', $this->filename, implode(PHP_EOL, $this->info['error'])));
     }
     return new Factory($this);
 }