13 define(
'GETID3_VERSION',
'1.7.7');
14 define(
'GETID3_FREAD_BUFFER_SIZE', 16384);
53 $this->startup_error =
'';
54 $this->startup_warning =
'';
57 if (phpversion() <
'4.1.0') {
58 $this->startup_error .=
'getID3() requires PHP v4.1.0 or higher - you are running v'.phpversion();
62 $memory_limit = ini_get(
'memory_limit');
63 if (eregi(
'([0-9]+)M', $memory_limit, $matches)) {
65 $memory_limit = $matches[1] * 1048576;
67 if ($memory_limit <= 0) {
69 }
elseif ($memory_limit <= 3145728) {
70 $this->startup_error .=
'PHP has less than 3MB available memory and will very likely run out. Increase memory_limit in php.ini';
71 }
elseif ($memory_limit <= 12582912) {
72 $this->startup_warning .=
'PHP has less than 12MB available memory and might run out if all modules are loaded. Increase memory_limit in php.ini';
76 if ((
bool) ini_get(
'safe_mode')) {
77 $this->
warning(
'WARNING: Safe mode is on, shorten support disabled, md5data/sha1data for ogg vorbis disabled, ogg vorbos/flac tag writing disabled.');
82 if (!defined(
'GETID3_OS_ISWINDOWS')) {
83 if (strtoupper(substr(PHP_OS, 0, 3)) ==
'WIN') {
84 define(
'GETID3_OS_ISWINDOWS',
true);
86 define(
'GETID3_OS_ISWINDOWS',
false);
91 if (!defined(
'GETID3_INCLUDEPATH')) {
92 foreach (get_included_files() as
$key => $val) {
93 if (basename($val) ==
'getid3.php') {
94 define(
'GETID3_INCLUDEPATH', dirname($val).DIRECTORY_SEPARATOR);
101 if (!include_once(GETID3_INCLUDEPATH.
'getid3.lib.php')) {
102 $this->startup_error .=
'getid3.lib.php is missing or corrupt';
112 if (GETID3_OS_ISWINDOWS && !defined(
'GETID3_HELPERAPPSDIR')) {
113 $helperappsdir = GETID3_INCLUDEPATH.
'..'.DIRECTORY_SEPARATOR.
'helperapps';
115 if (!is_dir($helperappsdir)) {
117 $this->startup_error .=
'"'.$helperappsdir.
'" cannot be defined as GETID3_HELPERAPPSDIR because it does not exist';
119 }
elseif (strpos(realpath($helperappsdir),
' ') !==
false) {
121 $DirPieces = explode(DIRECTORY_SEPARATOR, realpath($helperappsdir));
122 $DirPieces8 = $DirPieces;
124 $CLIdir = $DirPieces[0].
' && cd \\';
125 for ($i = 1; $i < count($DirPieces); $i++) {
126 if (strpos($DirPieces[$i],
' ') ===
false) {
127 $CLIdir .=
' && cd '.$DirPieces[$i];
130 system($CLIdir.
' && dir /ad /x');
131 $subdirsraw = explode(
"\n", ob_get_contents());
133 foreach ($subdirsraw as $dummy => $line) {
134 if (eregi(
'^[0-9]{4}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2} [AP]M <DIR> ([^ ]{8}) '.preg_quote($DirPieces[$i]).
'$', trim($line), $matches)) {
135 $CLIdir .=
' && cd '.$matches[1];
139 $DirPieces8[$i] = $matches[1];
142 $helperappsdir = implode(DIRECTORY_SEPARATOR, $DirPieces8);
145 define(
'GETID3_HELPERAPPSDIR', realpath($helperappsdir).DIRECTORY_SEPARATOR);
154 if (!is_array($optArray) || empty($optArray)) {
157 foreach ($optArray as $opt => $val) {
158 if (isset($this, $opt) ===
false) {
170 if (!empty($this->startup_error)) {
171 return $this->
error($this->startup_error);
173 if (!empty($this->startup_warning)) {
174 $this->
warning($this->startup_warning);
178 $this->info = array();
182 if (!function_exists(
'iconv') && !in_array($this->encoding, array(
'ISO-8859-1',
'UTF-8',
'UTF-16LE',
'UTF-16BE',
'UTF-16'))) {
183 $errormessage =
'iconv() support is needed for encodings other than ISO-8859-1, UTF-8, UTF-16LE, UTF16-BE, UTF-16. ';
184 if (GETID3_OS_ISWINDOWS) {
185 $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';
187 $errormessage .=
'PHP is not compiled with iconv() support. Please recompile with the --with-iconv switch';
189 return $this->
error($errormessage);
193 $old_magic_quotes_runtime = get_magic_quotes_runtime();
194 if ($old_magic_quotes_runtime) {
195 set_magic_quotes_runtime(0);
196 if (get_magic_quotes_runtime()) {
197 return $this->
error(
'Could not disable magic_quotes_runtime - getID3() cannot work properly with this setting enabled');
202 if (preg_match(
'/^(ht|f)tp:\/\//',
$filename)) {
203 return $this->
error(
'Remote files are not supported in this version of getID3() - please copy the file locally first');
212 $this->info[
'filesize'] = filesize(
$filename);
215 if ($this->option_max_2gb_check) {
219 fseek($fp, 0, SEEK_END);
220 if ((($this->info[
'filesize'] != 0) && (ftell($fp) == 0)) ||
221 ($this->info[
'filesize'] < 0) ||
223 unset($this->info[
'filesize']);
225 return $this->
error(
'File is most likely larger than 2GB and is not supported by PHP');
230 $this->info[
'avdataoffset'] = 0;
231 $this->info[
'avdataend'] = $this->info[
'filesize'];
232 $this->info[
'fileformat'] =
'';
233 $this->info[
'audio'][
'dataformat'] =
'';
234 $this->info[
'video'][
'dataformat'] =
'';
235 $this->info[
'tags'] = array();
236 $this->info[
'error'] = array();
237 $this->info[
'warning'] = array();
238 $this->info[
'comments'] = array();
242 $this->info[
'filename'] = basename(
$filename);
243 $this->info[
'filepath'] = str_replace(
'\\',
'/', realpath(dirname(
$filename)));
244 $this->info[
'filenamepath'] = $this->info[
'filepath'].
'/'.$this->info[
'filename'];
249 if ($this->option_tag_id3v2) {
251 $GETID3_ERRORARRAY = &$this->info[
'warning'];
258 fseek($fp, 0, SEEK_SET);
259 $header = fread($fp, 10);
260 if (substr($header, 0, 3) ==
'ID3') {
261 $this->info[
'id3v2'][
'header'] =
true;
262 $this->info[
'id3v2'][
'majorversion'] = ord($header{3});
263 $this->info[
'id3v2'][
'minorversion'] = ord($header{4});
266 $this->info[
'id3v2'][
'tag_offset_start'] = 0;
267 $this->info[
'id3v2'][
'tag_offset_end'] = $this->info[
'id3v2'][
'tag_offset_start'] + $this->info[
'id3v2'][
'headerlength'];
268 $this->info[
'avdataoffset'] = $this->info[
'id3v2'][
'tag_offset_end'];
275 if ($this->option_tag_id3v1) {
276 if (!@include_once(GETID3_INCLUDEPATH.
'module.tag.id3v1.php')) {
277 return $this->
error(
'module.tag.id3v1.php is missing - you may disable option_tag_id3v1.');
283 if ($this->option_tag_apetag) {
284 if (!@include_once(GETID3_INCLUDEPATH.
'module.tag.apetag.php')) {
285 return $this->
error(
'module.tag.apetag.php is missing - you may disable option_tag_apetag.');
291 if ($this->option_tag_lyrics3) {
292 if (!@include_once(GETID3_INCLUDEPATH.
'module.tag.lyrics3.php')) {
293 return $this->
error(
'module.tag.lyrics3.php is missing - you may disable option_tag_lyrics3.');
299 fseek($fp, $this->info[
'avdataoffset'], SEEK_SET);
300 $formattest = fread($fp, 32774);
306 if (!$determined_format) {
308 return $this->
error(
'unable to determine file format');
312 if (isset($determined_format[
'fail_id3']) && (in_array(
'id3v1', $this->info[
'tags']) || in_array(
'id3v2', $this->info[
'tags']))) {
313 if ($determined_format[
'fail_id3'] ===
'ERROR') {
315 return $this->
error(
'ID3 tags not allowed on this file type.');
316 }
elseif ($determined_format[
'fail_id3'] ===
'WARNING') {
317 $this->info[
'warning'][] =
'ID3 tags not allowed on this file type.';
322 if (isset($determined_format[
'fail_ape']) && in_array(
'ape', $this->info[
'tags'])) {
323 if ($determined_format[
'fail_ape'] ===
'ERROR') {
325 return $this->
error(
'APE tags not allowed on this file type.');
326 }
elseif ($determined_format[
'fail_ape'] ===
'WARNING') {
327 $this->info[
'warning'][] =
'APE tags not allowed on this file type.';
332 $this->info[
'mime_type'] = $determined_format[
'mime_type'];
335 if (!file_exists(GETID3_INCLUDEPATH.$determined_format[
'include'])) {
337 return $this->
error(
'Format not supported, module, '.$determined_format[
'include'].
', was removed.');
341 if (!function_exists(
'iconv') && @$determined_format[
'iconv_req']) {
342 return $this->
error(
'iconv support is required for this module ('.$determined_format[
'include'].
').');
346 include_once(GETID3_INCLUDEPATH.$determined_format[
'include']);
349 $class_name =
'getid3_'.$determined_format[
'module'];
350 if (!class_exists($class_name)) {
351 return $this->
error(
'Format not supported, module, '.$determined_format[
'include'].
', is corrupt.');
353 if (isset($determined_format[
'option'])) {
354 $class =
new $class_name($fp, $this->info, $determined_format[
'option']);
356 $class =
new $class_name($fp, $this->info);
363 if ($this->option_tags_process) {
368 if ($this->option_extra_info) {
377 if ($this->option_md5_data) {
379 if (!$this->option_md5_data_source || empty($this->info[
'md5_data_source'])) {
385 if ($this->option_sha1_data) {
393 set_magic_quotes_runtime($old_magic_quotes_runtime);
405 $this->info[
'error'][] = $message;
412 $this->info[
'warning'][] = $message;
421 $AVpossibleEmptyKeys = array(
'dataformat',
'bits_per_sample',
'encoder_options',
'streams');
422 foreach ($AVpossibleEmptyKeys as $dummy =>
$key) {
423 if (empty($this->info[
'audio'][
$key]) && isset($this->info[
'audio'][$key])) {
424 unset($this->info[
'audio'][$key]);
426 if (empty($this->info[
'video'][$key]) && isset($this->info[
'video'][$key])) {
427 unset($this->info[
'video'][$key]);
432 if (!empty($this->info)) {
433 foreach ($this->info as
$key => $value) {
434 if (empty($this->info[
$key]) && ($this->info[$key] !== 0) && ($this->info[$key] !==
'0')) {
435 unset($this->info[$key]);
441 if (empty($this->info[
'fileformat'])) {
442 if (isset($this->info[
'avdataoffset'])) {
443 unset($this->info[
'avdataoffset']);
445 if (isset($this->info[
'avdataend'])) {
446 unset($this->info[
'avdataend']);
454 static $format_info = array();
455 if (empty($format_info)) {
456 $format_info = array(
462 'pattern' =>
'^\x0B\x77',
465 'mime_type' =>
'audio/ac3',
470 'pattern' =>
'^ADIF',
474 'mime_type' =>
'application/octet-stream',
475 'fail_ape' =>
'WARNING',
481 'pattern' =>
'^\xFF[\xF0-\xF1\xF8-\xF9]',
485 'mime_type' =>
'application/octet-stream',
486 'fail_ape' =>
'WARNING',
492 'pattern' =>
'^\.snd',
495 'mime_type' =>
'audio/basic',
500 'pattern' =>
'^2BIT',
503 'mime_type' =>
'application/octet-stream',
508 'pattern' =>
'^\x00(BONK|INFO|META| ID3)',
511 'mime_type' =>
'audio/xmms-bonk',
516 'pattern' =>
'^fLaC',
519 'mime_type' =>
'audio/x-flac',
524 'pattern' =>
'^LA0[2-4]',
527 'mime_type' =>
'application/octet-stream',
532 'pattern' =>
'^LPAC',
535 'mime_type' =>
'application/octet-stream',
540 'pattern' =>
'^MThd',
543 'mime_type' =>
'audio/midi',
548 'pattern' =>
'^MAC ',
550 'module' =>
'monkey',
551 'mime_type' =>
'application/octet-stream',
556 'pattern' =>
'^.{1080}(M.K.|[5-9]CHN|[1-3][0-9]CH)',
560 'mime_type' =>
'audio/mod',
565 'pattern' =>
'^IMPM',
569 'mime_type' =>
'audio/it',
574 'pattern' =>
'^Extended Module',
578 'mime_type' =>
'audio/xm',
583 'pattern' =>
'^.{44}SCRM',
587 'mime_type' =>
'audio/s3m',
592 'pattern' =>
'^(MP\+|[\x00\x01\x10\x11\x40\x41\x50\x51\x80\x81\x90\x91\xC0\xC1\xD0\xD1][\x20-37][\x00\x20\x40\x60\x80\xA0\xC0\xE0])',
595 'mime_type' =>
'application/octet-stream',
600 'pattern' =>
'^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\xEB]',
603 'mime_type' =>
'audio/mpeg',
608 'pattern' =>
'^(\*RIFF|OFR)',
610 'module' =>
'optimfrog',
611 'mime_type' =>
'application/octet-stream',
619 'mime_type' =>
'application/octet-stream',
624 'pattern' =>
'^ajkg',
626 'module' =>
'shorten',
627 'mime_type' =>
'audio/xmms-shn',
628 'fail_id3' =>
'ERROR',
629 'fail_ape' =>
'ERROR',
637 'mime_type' =>
'application/octet-stream',
642 'pattern' =>
'^Creative Voice File',
645 'mime_type' =>
'audio/voc',
650 'pattern' =>
'^TWIN',
653 'mime_type' =>
'application/octet-stream',
658 'pattern' =>
'^wvpk',
660 'module' =>
'wavpack',
661 'mime_type' =>
'application/octet-stream',
669 'pattern' =>
'^\x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C',
670 'group' =>
'audio-video',
672 'mime_type' =>
'video/x-ms-asf',
673 'iconv_req' =>
false,
678 'pattern' =>
'^(BIK|SMK)',
679 'group' =>
'audio-video',
681 'mime_type' =>
'application/octet-stream',
686 'pattern' =>
'^FLV\x01',
687 'group' =>
'audio-video',
689 'mime_type' =>
'video/x-flv',
694 'pattern' =>
'^\x1A\x45\xDF\xA3',
695 'group' =>
'audio-video',
696 'module' =>
'matroska',
697 'mime_type' =>
'application/octet-stream',
702 'pattern' =>
'^\x00\x00\x01(\xBA|\xB3)',
703 'group' =>
'audio-video',
705 'mime_type' =>
'video/mpeg',
710 'pattern' =>
'^NSV[sf]',
711 'group' =>
'audio-video',
713 'mime_type' =>
'application/octet-stream',
718 'pattern' =>
'^OggS',
721 'mime_type' =>
'application/ogg',
722 'fail_id3' =>
'WARNING',
723 'fail_ape' =>
'WARNING',
727 'quicktime' => array(
728 'pattern' =>
'^.{4}(cmov|free|ftyp|mdat|moov|pnot|skip|wide)',
729 'group' =>
'audio-video',
730 'module' =>
'quicktime',
731 'mime_type' =>
'video/quicktime',
736 'pattern' =>
'^(RIFF|SDSS|FORM)',
737 'group' =>
'audio-video',
739 'mime_type' =>
'audio/x-wave',
740 'fail_ape' =>
'WARNING',
745 'pattern' =>
'^(\.RMF|.ra)',
746 'group' =>
'audio-video',
748 'mime_type' =>
'audio/x-realaudio',
753 'pattern' =>
'^(F|C)WS',
754 'group' =>
'audio-video',
756 'mime_type' =>
'application/x-shockwave-flash',
765 'group' =>
'graphic',
767 'mime_type' =>
'image/bmp',
768 'fail_id3' =>
'ERROR',
769 'fail_ape' =>
'ERROR',
775 'group' =>
'graphic',
777 'mime_type' =>
'image/gif',
778 'fail_id3' =>
'ERROR',
779 'fail_ape' =>
'ERROR',
784 'pattern' =>
'^\xFF\xD8\xFF',
785 'group' =>
'graphic',
787 'mime_type' =>
'image/jpeg',
788 'fail_id3' =>
'ERROR',
789 'fail_ape' =>
'ERROR',
794 'pattern' =>
'^.{2048}PCD_IPI\x00',
795 'group' =>
'graphic',
797 'mime_type' =>
'image/x-photo-cd',
798 'fail_id3' =>
'ERROR',
799 'fail_ape' =>
'ERROR',
805 'pattern' =>
'^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A',
806 'group' =>
'graphic',
808 'mime_type' =>
'image/png',
809 'fail_id3' =>
'ERROR',
810 'fail_ape' =>
'ERROR',
816 'pattern' =>
'^(II\x2A\x00|MM\x00\x2A)',
817 'group' =>
'graphic',
819 'mime_type' =>
'image/tiff',
820 'fail_id3' =>
'ERROR',
821 'fail_ape' =>
'ERROR',
829 'pattern' =>
'^.{32769}CD001',
832 'mime_type' =>
'application/octet-stream',
833 'fail_id3' =>
'ERROR',
834 'fail_ape' =>
'ERROR',
835 'iconv_req' =>
false,
840 'pattern' =>
'^Rar\!',
841 'group' =>
'archive',
843 'mime_type' =>
'application/octet-stream',
844 'fail_id3' =>
'ERROR',
845 'fail_ape' =>
'ERROR',
850 'pattern' =>
'^SZ\x0A\x04',
851 'group' =>
'archive',
853 'mime_type' =>
'application/octet-stream',
854 'fail_id3' =>
'ERROR',
855 'fail_ape' =>
'ERROR',
860 'pattern' =>
'^.{100}[0-9\x20]{7}\x00[0-9\x20]{7}\x00[0-9\x20]{7}\x00[0-9\x20\x00]{12}[0-9\x20\x00]{12}',
861 'group' =>
'archive',
863 'mime_type' =>
'application/x-tar',
864 'fail_id3' =>
'ERROR',
865 'fail_ape' =>
'ERROR',
870 'pattern' =>
'^\x1F\x8B\x08',
871 'group' =>
'archive',
873 'mime_type' =>
'application/x-gzip',
874 'fail_id3' =>
'ERROR',
875 'fail_ape' =>
'ERROR',
880 'pattern' =>
'^PK\x03\x04',
881 'group' =>
'archive',
883 'mime_type' =>
'application/zip',
884 'fail_id3' =>
'ERROR',
885 'fail_ape' =>
'ERROR',
893 'pattern' =>
'^\x25PDF',
896 'mime_type' =>
'application/pdf',
897 'fail_id3' =>
'ERROR',
898 'fail_ape' =>
'ERROR',
903 'pattern' =>
'^\xD0\xCF\x11\xE0',
905 'module' =>
'msoffice',
906 'mime_type' =>
'application/octet-stream',
907 'fail_id3' =>
'ERROR',
908 'fail_ape' =>
'ERROR',
929 if (preg_match(
'/'.$info[
'pattern'].
'/s', $filedata)) {
930 $info[
'include'] =
'module.'.$info[
'group'].
'.'.$info[
'module'].
'.php';
936 if (preg_match(
'/\.mp[123a]$/i',
$filename)) {
940 $info = $GetFileFormatArray[
'mp3'];
941 $info[
'include'] =
'module.'.$info[
'group'].
'.'.$info[
'module'].
'.php';
958 foreach ($array as
$key => $value) {
961 if (is_array($value)) {
966 elseif (is_string($value)) {
979 'asf' => array(
'asf' ,
'UTF-16LE'),
980 'midi' => array(
'midi' ,
'ISO-8859-1'),
981 'nsv' => array(
'nsv' ,
'ISO-8859-1'),
982 'ogg' => array(
'vorbiscomment' ,
'UTF-8'),
983 'png' => array(
'png' ,
'UTF-8'),
984 'tiff' => array(
'tiff' ,
'ISO-8859-1'),
985 'quicktime' => array(
'quicktime' ,
'ISO-8859-1'),
986 'real' => array(
'real' ,
'ISO-8859-1'),
987 'vqf' => array(
'vqf' ,
'ISO-8859-1'),
988 'zip' => array(
'zip' ,
'ISO-8859-1'),
989 'riff' => array(
'riff' ,
'ISO-8859-1'),
990 'lyrics3' => array(
'lyrics3' ,
'ISO-8859-1'),
991 'id3v1' => array(
'id3v1' , $this->encoding_id3v1),
992 'id3v2' => array(
'id3v2' ,
'UTF-8'),
993 'ape' => array(
'ape' ,
'UTF-8')
998 foreach ($tags as $comment_name => $tagname_encoding_array) {
999 list($tag_name,
$encoding) = $tagname_encoding_array;
1002 if (isset($this->info[$comment_name]) && !isset($this->info[$comment_name][
'encoding'])) {
1003 $this->info[$comment_name][
'encoding'] =
$encoding;
1007 if (!empty($this->info[$comment_name][
'comments'])) {
1009 foreach ($this->info[$comment_name][
'comments'] as $tag_key => $valuearray) {
1010 foreach ($valuearray as
$key => $value) {
1011 if (strlen(trim($value)) > 0) {
1012 $this->info[
'tags'][trim($tag_name)][trim($tag_key)][] = $value;
1017 if (!isset($this->info[
'tags'][$tag_name])) {
1022 if ($this->option_tags_html) {
1023 foreach ($this->info[
'tags'][$tag_name] as $tag_key => $valuearray) {
1024 foreach ($valuearray as
$key => $value) {
1025 if (is_string($value)) {
1029 $this->info[
'tags_html'][$tag_name][$tag_key][
$key] = $value;
1044 switch ($algorithm) {
1050 return $this->
error(
'bad algorithm "'.$algorithm.
'" in getHashdata()');
1054 if ((@$this->info[
'fileformat'] ==
'ogg') && (@$this->info[
'audio'][
'dataformat'] ==
'vorbis')) {
1074 if ((
bool) ini_get(
'safe_mode')) {
1076 $this->info[
'warning'][] =
'Failed making system call to vorbiscomment.exe - '.$algorithm.
'_data is incorrect - error returned: PHP running in Safe Mode (backtick operator not available)';
1077 $this->info[$algorithm.
'_data'] =
false;
1082 $old_abort = ignore_user_abort(
true);
1085 $empty = tempnam(
'*',
'getID3');
1090 $temp = tempnam(
'*',
'getID3');
1091 $file = $this->info[
'filenamepath'];
1093 if (GETID3_OS_ISWINDOWS) {
1095 if (file_exists(GETID3_HELPERAPPSDIR.
'vorbiscomment.exe')) {
1097 $commandline =
'"'.GETID3_HELPERAPPSDIR.
'vorbiscomment.exe" -w -c "'.
$empty.
'" "'.
$file.
'" "'.$temp.
'"';
1098 $VorbisCommentError = `$commandline`;
1102 $VorbisCommentError =
'vorbiscomment.exe not found in '.GETID3_HELPERAPPSDIR;
1108 $commandline =
'vorbiscomment -w -c "'.$empty.
'" "'.
$file.
'" "'.$temp.
'" 2>&1';
1109 $commandline =
'vorbiscomment -w -c '.escapeshellarg(
$empty).
' '.escapeshellarg(
$file).
' '.escapeshellarg($temp).
' 2>&1';
1110 $VorbisCommentError = `$commandline`;
1114 if (!empty($VorbisCommentError)) {
1116 $this->info[
'warning'][] =
'Failed making system call to vorbiscomment(.exe) - '.$algorithm.
'_data will be incorrect. If vorbiscomment is unavailable, please download from http://www.vorbis.com/download.psp and put in the getID3() directory. Error returned: '.$VorbisCommentError;
1117 $this->info[$algorithm.
'_data'] =
false;
1122 switch ($algorithm) {
1138 ignore_user_abort($old_abort);
1144 if (!empty($this->info[
'avdataoffset']) || (isset($this->info[
'avdataend']) && ($this->info[
'avdataend'] < $this->info[
'filesize']))) {
1147 $this->info[$algorithm.
'_data'] =
getid3_lib::hash_data($this->info[
'filenamepath'], $this->info[
'avdataoffset'], $this->info[
'avdataend'], $algorithm);
1152 switch ($algorithm) {
1171 if (@$this->info[
'audio'][
'channels'] ==
'1') {
1172 $this->info[
'audio'][
'channelmode'] =
'mono';
1173 }
elseif (@$this->info[
'audio'][
'channels'] ==
'2') {
1174 $this->info[
'audio'][
'channelmode'] =
'stereo';
1178 $CombinedBitrate = 0;
1179 $CombinedBitrate += (isset($this->info[
'audio'][
'bitrate']) ? $this->info[
'audio'][
'bitrate'] : 0);
1180 $CombinedBitrate += (isset($this->info[
'video'][
'bitrate']) ? $this->info[
'video'][
'bitrate'] : 0);
1181 if (($CombinedBitrate > 0) && empty($this->info[
'bitrate'])) {
1182 $this->info[
'bitrate'] = $CombinedBitrate;
1190 if (!isset($this->info[
'playtime_seconds']) && !empty($this->info[
'bitrate'])) {
1191 $this->info[
'playtime_seconds'] = (($this->info[
'avdataend'] - $this->info[
'avdataoffset']) * 8) / $this->info[
'bitrate'];
1195 if (!empty($this->info[
'playtime_seconds']) && empty($this->info[
'playtime_string'])) {
1202 if (empty($this->info[
'video'])) {
1205 if (empty($this->info[
'video'][
'resolution_x']) || empty($this->info[
'video'][
'resolution_y'])) {
1208 if (empty($this->info[
'video'][
'bits_per_sample'])) {
1212 switch ($this->info[
'video'][
'dataformat']) {
1220 $PlaytimeSeconds = 1;
1221 $BitrateCompressed = $this->info[
'filesize'] * 8;
1225 if (!empty($this->info[
'video'][
'frame_rate'])) {
1226 $FrameRate = $this->info[
'video'][
'frame_rate'];
1230 if (!empty($this->info[
'playtime_seconds'])) {
1231 $PlaytimeSeconds = $this->info[
'playtime_seconds'];
1235 if (!empty($this->info[
'video'][
'bitrate'])) {
1236 $BitrateCompressed = $this->info[
'video'][
'bitrate'];
1242 $BitrateUncompressed = $this->info[
'video'][
'resolution_x'] * $this->info[
'video'][
'resolution_y'] * $this->info[
'video'][
'bits_per_sample'] * $FrameRate;
1244 $this->info[
'video'][
'compression_ratio'] = $BitrateCompressed / $BitrateUncompressed;
1250 if (empty($this->info[
'audio'][
'bitrate']) || empty($this->info[
'audio'][
'channels']) || empty($this->info[
'audio'][
'sample_rate'])) {
1253 $this->info[
'audio'][
'compression_ratio'] = $this->info[
'audio'][
'bitrate'] / ($this->info[
'audio'][
'channels'] * $this->info[
'audio'][
'sample_rate'] * (!empty($this->info[
'audio'][
'bits_per_sample']) ? $this->info[
'audio'][
'bits_per_sample'] : 16));
1255 if (!empty($this->info[
'audio'][
'streams'])) {
1256 foreach ($this->info[
'audio'][
'streams'] as $streamnumber => $streamdata) {
1257 if (!empty($streamdata[
'bitrate']) && !empty($streamdata[
'channels']) && !empty($streamdata[
'sample_rate'])) {
1258 $this->info[
'audio'][
'streams'][$streamnumber][
'compression_ratio'] = $streamdata[
'bitrate'] / ($streamdata[
'channels'] * $streamdata[
'sample_rate'] * (!empty($streamdata[
'bits_per_sample']) ? $streamdata[
'bits_per_sample'] : 16));
1267 if (isset($this->info[
'replay_gain'])) {
1268 $this->info[
'replay_gain'][
'reference_volume'] = 89;
1269 if (isset($this->info[
'replay_gain'][
'track'][
'adjustment'])) {
1270 $this->info[
'replay_gain'][
'track'][
'volume'] = $this->info[
'replay_gain'][
'reference_volume'] - $this->info[
'replay_gain'][
'track'][
'adjustment'];
1272 if (isset($this->info[
'replay_gain'][
'album'][
'adjustment'])) {
1273 $this->info[
'replay_gain'][
'album'][
'volume'] = $this->info[
'replay_gain'][
'reference_volume'] - $this->info[
'replay_gain'][
'album'][
'adjustment'];
1276 if (isset($this->info[
'replay_gain'][
'track'][
'peak'])) {
1277 $this->info[
'replay_gain'][
'track'][
'max_noclip_gain'] = 0 -
getid3_lib::RGADamplitude2dB($this->info[
'replay_gain'][
'track'][
'peak']);
1279 if (isset($this->info[
'replay_gain'][
'album'][
'peak'])) {
1280 $this->info[
'replay_gain'][
'album'][
'max_noclip_gain'] = 0 -
getid3_lib::RGADamplitude2dB($this->info[
'replay_gain'][
'album'][
'peak']);
1287 if (!empty($this->info[
'audio'][
'bitrate']) || !empty($this->info[
'audio'][
'channels']) || !empty($this->info[
'audio'][
'sample_rate'])) {
1288 if (!isset($this->info[
'audio'][
'streams'])) {
1289 foreach ($this->info[
'audio'] as
$key => $value) {
1290 if (
$key !=
'streams') {
1291 $this->info[
'audio'][
'streams'][0][
$key] = $value;
1300 return tempnam($this->tempdir,
'gI3');