123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 |
- <?php
- require_once('../getid3/getid3.php');
- class AudioInfo {
-
- private $result;
- private $info;
- private $getID3;
-
- function __construct() {
-
- $this->getID3 = new getID3;
- $this->getID3->option_md5_data = true;
- $this->getID3->option_md5_data_source = true;
- $this->getID3->encoding = 'UTF-8';
- }
-
- public function Info($file) {
-
- $this->info = $this->getID3->analyze($file);
-
- if (isset($this->info['error'])) {
- return array ('error' => $this->info['error']);
- }
-
- $this->result = array();
- $this->result['format_name'] = (isset($this->info['fileformat']) ? $this->info['fileformat'] : '').'/'.(isset($this->info['audio']['dataformat']) ? $this->info['audio']['dataformat'] : '').(isset($this->info['video']['dataformat']) ? '/'.$this->info['video']['dataformat'] : '');
- $this->result['encoder_version'] = (isset($this->info['audio']['encoder']) ? $this->info['audio']['encoder'] : '');
- $this->result['encoder_options'] = (isset($this->info['audio']['encoder_options']) ? $this->info['audio']['encoder_options'] : '');
- $this->result['bitrate_mode'] = (isset($this->info['audio']['bitrate_mode']) ? $this->info['audio']['bitrate_mode'] : '');
- $this->result['channels'] = (isset($this->info['audio']['channels']) ? $this->info['audio']['channels'] : '');
- $this->result['sample_rate'] = (isset($this->info['audio']['sample_rate']) ? $this->info['audio']['sample_rate'] : '');
- $this->result['bits_per_sample'] = (isset($this->info['audio']['bits_per_sample']) ? $this->info['audio']['bits_per_sample'] : '');
- $this->result['playing_time'] = (isset($this->info['playtime_seconds']) ? $this->info['playtime_seconds'] : '');
- $this->result['avg_bit_rate'] = (isset($this->info['audio']['bitrate']) ? $this->info['audio']['bitrate'] : '');
- $this->result['tags'] = (isset($this->info['tags']) ? $this->info['tags'] : '');
- $this->result['comments'] = (isset($this->info['comments']) ? $this->info['comments'] : '');
- $this->result['warning'] = (isset($this->info['warning']) ? $this->info['warning'] : '');
- $this->result['md5'] = (isset($this->info['md5_data']) ? $this->info['md5_data'] : '');
-
- $method = (isset($this->info['fileformat']) ? $this->info['fileformat'] : '').'Info';
- if ($method && method_exists($this, $method)) {
- $this->$method();
- }
- return $this->result;
- }
-
- private function aacInfo() {
- $this->result['format_name'] = 'AAC';
- }
-
- private function riffInfo() {
- if ($this->info['audio']['dataformat'] == 'wav') {
- $this->result['format_name'] = 'Wave';
- } elseif (preg_match('#^mp[1-3]$#', $this->info['audio']['dataformat'])) {
- $this->result['format_name'] = strtoupper($this->info['audio']['dataformat']);
- } else {
- $this->result['format_name'] = 'riff/'.$this->info['audio']['dataformat'];
- }
- }
-
- private function flacInfo() {
- $this->result['format_name'] = 'FLAC';
- }
-
- private function macInfo() {
- $this->result['format_name'] = 'Monkey\'s Audio';
- }
-
- private function laInfo() {
- $this->result['format_name'] = 'La';
- }
-
- function oggInfo() {
- if ($this->info['audio']['dataformat'] == 'vorbis') {
- $this->result['format_name'] = 'Ogg Vorbis';
- } else if ($this->info['audio']['dataformat'] == 'flac') {
- $this->result['format_name'] = 'Ogg FLAC';
- } else if ($this->info['audio']['dataformat'] == 'speex') {
- $this->result['format_name'] = 'Ogg Speex';
- } else {
- $this->result['format_name'] = 'Ogg '.$this->info['audio']['dataformat'];
- }
- }
-
- function mpcInfo() {
- $this->result['format_name'] = 'Musepack';
- }
-
- function mp3Info() {
- $this->result['format_name'] = 'MP3';
- }
-
- function mp2Info() {
- $this->result['format_name'] = 'MP2';
- }
-
- function mp1Info() {
- $this->result['format_name'] = 'MP1';
- }
-
- function asfInfo() {
- $this->result['format_name'] = strtoupper($this->info['audio']['dataformat']);
- }
-
- function realInfo() {
- $this->result['format_name'] = 'Real';
- }
-
- function vqfInfo() {
- $this->result['format_name'] = 'VQF';
- }
- }
|