1 ///////////////////////////////////////////////////////////////// |
1 ///////////////////////////////////////////////////////////////// |
2 /// getID3() by James Heinrich <info@getid3.org> // |
2 /// getID3() by James Heinrich <info@getid3.org> // |
3 // available at http://getid3.sourceforge.net // |
3 // available at http://getid3.sourceforge.net // |
4 // or http://www.getid3.org // |
4 // or https://www.getid3.org // |
5 // also https://github.com/JamesHeinrich/getID3 // |
5 // also https://github.com/JamesHeinrich/getID3 // |
6 ///////////////////////////////////////////////////////////////// |
6 ///////////////////////////////////////////////////////////////// |
7 |
7 |
8 ***************************************************************** |
8 ***************************************************************** |
9 ***************************************************************** |
9 ***************************************************************** |
16 https://gnu.org/licenses/old-licenses/gpl-2.0.html (v2) |
16 https://gnu.org/licenses/old-licenses/gpl-2.0.html (v2) |
17 https://gnu.org/licenses/old-licenses/gpl-1.0.html (v1) |
17 https://gnu.org/licenses/old-licenses/gpl-1.0.html (v1) |
18 |
18 |
19 GNU LGPL: https://gnu.org/licenses/lgpl.html (v3) |
19 GNU LGPL: https://gnu.org/licenses/lgpl.html (v3) |
20 |
20 |
21 Mozilla MPL: http://www.mozilla.org/MPL/2.0/ (v2) |
21 Mozilla MPL: https://www.mozilla.org/MPL/2.0/ (v2) |
22 |
22 |
23 getID3 Commercial License: http://getid3.org/#gCL (payment required) |
23 getID3 Commercial License: https://www.getid3.org/#gCL (payment required) |
24 |
24 |
25 ***************************************************************** |
25 ***************************************************************** |
26 ***************************************************************** |
26 ***************************************************************** |
27 Copies of each of the above licenses are included in the 'licenses' |
27 Copies of each of the above licenses are included in the 'licenses' |
28 directory of the getID3 distribution. |
28 directory of the getID3 distribution. |
29 |
29 |
30 |
30 |
31 +---------------------------------------------+ |
31 +----------------------------------------------+ |
32 | If you want to donate, there is a link on | |
32 | If you want to donate, there is a link on | |
33 | http://www.getid3.org for PayPal donations. | |
33 | https://www.getid3.org for PayPal donations. | |
34 +---------------------------------------------+ |
34 +----------------------------------------------+ |
35 |
35 |
36 |
36 |
37 Quick Start |
37 Quick Start |
38 =========================================================================== |
38 =========================================================================== |
39 |
39 |
143 |
143 |
144 |
144 |
145 Requirements |
145 Requirements |
146 =========================================================================== |
146 =========================================================================== |
147 |
147 |
148 * PHP 4.2.0 up to 5.2.x for getID3() 1.7.x (and earlier) |
148 * PHP 4.2.0 up to 5.2.x for getID3() 1.7.x (and earlier) |
149 * PHP 5.0.5 (or higher) for getID3() 1.8.x (and up) |
149 * PHP 5.0.5 (or higher) for getID3() 1.8.x (and up) |
150 * PHP 5.0.5 (or higher) for getID3() 2.0.x (and up) |
150 * PHP 5.3.0 (or higher) for getID3() 1.9.17 (and up) |
|
151 * PHP 5.3.0 (or higher) for getID3() 2.0.x (and up) |
151 * at least 4MB memory for PHP. 8MB or more is highly recommended. |
152 * at least 4MB memory for PHP. 8MB or more is highly recommended. |
152 12MB is required with all modules loaded. |
153 12MB is required with all modules loaded. |
153 |
154 |
154 |
155 |
155 |
156 |
175 like this: |
176 like this: |
176 |
177 |
177 // Copy remote file locally to scan with getID3() |
178 // Copy remote file locally to scan with getID3() |
178 $remotefilename = 'http://www.example.com/filename.mp3'; |
179 $remotefilename = 'http://www.example.com/filename.mp3'; |
179 if ($fp_remote = fopen($remotefilename, 'rb')) { |
180 if ($fp_remote = fopen($remotefilename, 'rb')) { |
180 $localtempfilename = tempnam('/tmp', 'getID3'); |
181 $localtempfilename = tempnam('/tmp', 'getID3'); |
181 if ($fp_local = fopen($localtempfilename, 'wb')) { |
182 if ($fp_local = fopen($localtempfilename, 'wb')) { |
182 while ($buffer = fread($fp_remote, 8192)) { |
183 while ($buffer = fread($fp_remote, 32768)) { |
183 fwrite($fp_local, $buffer); |
184 fwrite($fp_local, $buffer); |
184 } |
185 } |
185 fclose($fp_local); |
186 fclose($fp_local); |
|
187 |
|
188 $remote_headers = array_change_key_case(get_headers($remotefilename, 1), CASE_LOWER); |
|
189 $remote_filesize = (isset($remote_headers['content-length']) ? (is_array($remote_headers['content-length']) ? $remote_headers['content-length'][count($remote_headers['content-length']) - 1] : $remote_headers['content-length']) : null); |
186 |
190 |
187 // Initialize getID3 engine |
191 // Initialize getID3 engine |
188 $getID3 = new getID3; |
192 $getID3 = new getID3; |
189 |
193 |
190 $ThisFileInfo = $getID3->analyze($filename); |
194 $ThisFileInfo = $getID3->analyze($localtempfilename, $remote_filesize, basename($remotefilename)); |
191 |
195 |
192 // Delete temporary file |
196 // Delete temporary file |
193 unlink($localtempfilename); |
197 unlink($localtempfilename); |
194 } |
198 } |
195 fclose($fp_remote); |
199 fclose($fp_remote); |
196 } |
200 } |
197 |
201 |
|
202 Note: since v1.9.9-20150212 it is possible a second and third parameter |
|
203 to $getID3->analyze(), for original filesize and original filename |
|
204 respectively. This permits you to download only a portion of a large remote |
|
205 file but get accurate playtime estimates, assuming the format only requires |
|
206 the beginning of the file for correct format analysis. |
198 |
207 |
199 See /demos/demo.write.php for how to write tags. |
208 See /demos/demo.write.php for how to write tags. |
200 |
209 |
201 |
210 |
202 |
211 |
290 function getID3($filename) { return unpack('a3TAG/a30title/a30artist/a30album/a4year/a28comment/c1track/c1genreid', substr(file_get_contents($filename), -128)); } |
299 function getID3($filename) { return unpack('a3TAG/a30title/a30artist/a30album/a4year/a28comment/c1track/c1genreid', substr(file_get_contents($filename), -128)); } |
291 |
300 |
292 |
301 |
293 Future Plans |
302 Future Plans |
294 =========================================================================== |
303 =========================================================================== |
295 http://www.getid3.org/phpBB3/viewforum.php?f=7 |
304 https://www.getid3.org/phpBB3/viewforum.php?f=7 |
296 |
305 |
297 * Better support for MP4 container format |
306 * Better support for MP4 container format |
298 * Scan for appended ID3v2 tag at end of file per ID3v2.4 specs (Section 5.0) |
307 * Scan for appended ID3v2 tag at end of file per ID3v2.4 specs (Section 5.0) |
299 * Support for JPEG-2000 (http://www.morgan-multimedia.com/jpeg2000_overview.htm) |
308 * Support for JPEG-2000 (http://www.morgan-multimedia.com/jpeg2000_overview.htm) |
300 * Support for MOD (mod/stm/s3m/it/xm/mtm/ult/669) |
309 * Support for MOD (mod/stm/s3m/it/xm/mtm/ult/669) |
332 (thanks n8n8Øyahoo*com) |
341 (thanks n8n8Øyahoo*com) |
333 * Support for a2b |
342 * Support for a2b |
334 * Optional scan-through-frames for AVI verification |
343 * Optional scan-through-frames for AVI verification |
335 (thanks rockcohenØmassive-interactive*nl) |
344 (thanks rockcohenØmassive-interactive*nl) |
336 * Support for TTF (thanks infoØbutterflyx*com) |
345 * Support for TTF (thanks infoØbutterflyx*com) |
337 * Support for DSS (http://www.getid3.org/phpBB3/viewtopic.php?t=171) |
346 * Support for DSS (https://www.getid3.org/phpBB3/viewtopic.php?t=171) |
338 * Support for SMAF (http://smaf-yamaha.com/what/demo.html) |
347 * Support for SMAF (http://smaf-yamaha.com/what/demo.html) |
339 http://www.getid3.org/phpBB3/viewtopic.php?t=182 |
348 https://www.getid3.org/phpBB3/viewtopic.php?t=182 |
340 * Support for AMR (http://www.getid3.org/phpBB3/viewtopic.php?t=195) |
349 * Support for AMR (https://www.getid3.org/phpBB3/viewtopic.php?t=195) |
341 * Support for 3gpp (http://www.getid3.org/phpBB3/viewtopic.php?t=195) |
350 * Support for 3gpp (https://www.getid3.org/phpBB3/viewtopic.php?t=195) |
342 * Support for ID4 (http://www.wackysoft.cjb.net grizlyY2KØhotmail*com) |
351 * Support for ID4 (http://www.wackysoft.cjb.net grizlyY2KØhotmail*com) |
343 * Parse XML data returned in Ogg comments |
352 * Parse XML data returned in Ogg comments |
344 * Parse XML data from Quicktime SMIL metafiles (klausrathØmac*com) |
353 * Parse XML data from Quicktime SMIL metafiles (klausrathØmac*com) |
345 * ID3v2 genre string creator function |
354 * ID3v2 genre string creator function |
346 * More complete parsing of JPG |
355 * More complete parsing of JPG |
372 |
381 |
373 |
382 |
374 |
383 |
375 Known Bugs/Issues in getID3() that may be fixed eventually |
384 Known Bugs/Issues in getID3() that may be fixed eventually |
376 =========================================================================== |
385 =========================================================================== |
377 http://www.getid3.org/phpBB3/viewtopic.php?t=25 |
386 https://www.getid3.org/phpBB3/viewtopic.php?t=25 |
378 |
387 |
379 * Cannot determine bitrate for MPEG video with VBR video data |
388 * Cannot determine bitrate for MPEG video with VBR video data |
380 (need documentation) |
389 (need documentation) |
381 * Interlace/progressive cannot be determined for MPEG video |
390 * Interlace/progressive cannot be determined for MPEG video |
382 (need documentation) |
391 (need documentation) |
398 |
407 |
399 |
408 |
400 |
409 |
401 Known Bugs/Issues in getID3() that cannot be fixed |
410 Known Bugs/Issues in getID3() that cannot be fixed |
402 -------------------------------------------------- |
411 -------------------------------------------------- |
403 http://www.getid3.org/phpBB3/viewtopic.php?t=25 |
412 https://www.getid3.org/phpBB3/viewtopic.php?t=25 |
404 |
413 |
405 * 32-bit PHP installations only: |
414 * 32-bit PHP installations only: |
406 Files larger than 2GB cannot always be parsed fully by getID3() |
415 Files larger than 2GB cannot always be parsed fully by getID3() |
407 due to limitations in the 32-bit PHP filesystem functions. |
416 due to limitations in the 32-bit PHP filesystem functions. |
408 NOTE: Since v1.7.8b3 there is partial support for larger-than- |
417 NOTE: Since v1.7.8b3 there is partial support for larger-than- |
428 * PHP <= v5 on Windows cannot read UTF-8 filenames |
437 * PHP <= v5 on Windows cannot read UTF-8 filenames |
429 |
438 |
430 |
439 |
431 Known Bugs/Issues in other programs |
440 Known Bugs/Issues in other programs |
432 ----------------------------------- |
441 ----------------------------------- |
433 http://www.getid3.org/phpBB3/viewtopic.php?t=25 |
442 https://www.getid3.org/phpBB3/viewtopic.php?t=25 |
434 |
443 |
|
444 * MusicBrainz Picard (at least up to v1.3.2) writes multiple |
|
445 ID3v2.3 genres in non-standard forward-slash separated text |
|
446 rather than parenthesis-numeric+refinement style per the ID3v2.3 |
|
447 specs. Tags written in ID3v2.4 mode are written correctly. |
|
448 (detected and worked around by getID3()) |
|
449 * PZ TagEditor v4.53.408 has been known to insert ID3v2.3 frames |
|
450 into an existing ID3v2.2 tag which, of course, breaks things |
435 * Windows Media Player (up to v11) and iTunes (up to v10+) do |
451 * Windows Media Player (up to v11) and iTunes (up to v10+) do |
436 not correctly handle ID3v2.3 tags with UTF-16BE+BOM |
452 not correctly handle ID3v2.3 tags with UTF-16BE+BOM |
437 encoding (they assume the data is UTF-16LE+BOM and either |
453 encoding (they assume the data is UTF-16LE+BOM and either |
438 crash (WMP) or output Asian character set (iTunes) |
454 crash (WMP) or output Asian character set (iTunes) |
439 * Winamp (up to v2.80 at least) does not support ID3v2.4 tags, |
455 * Winamp (up to v2.80 at least) does not support ID3v2.4 tags, |
449 * CDex v1.40 (fixed by v1.50b7) writes non-compliant Ogg comment |
465 * CDex v1.40 (fixed by v1.50b7) writes non-compliant Ogg comment |
450 strings, supposed to be in the format "NAME=value" but actually |
466 strings, supposed to be in the format "NAME=value" but actually |
451 written just "value" (detected by getID3()) |
467 written just "value" (detected by getID3()) |
452 * Oggenc 0.9-rc3 flags the encoded file as ABR whether it's |
468 * Oggenc 0.9-rc3 flags the encoded file as ABR whether it's |
453 actually ABR or VBR. |
469 actually ABR or VBR. |
|
470 * iTunes (versions "v7.0.0.70" is known-guilty, probably |
|
471 other versions are too) writes ID3v2.3 comment tags using an |
|
472 ID3v2.2 frame name (3-bytes) null-padded to 4 bytes which is |
|
473 not valid for ID3v2.3+ |
|
474 (detected by getID3() since 1.9.12-201603221746) |
454 * iTunes (versions "X v2.0.3", "v3.0.1" are known-guilty, probably |
475 * iTunes (versions "X v2.0.3", "v3.0.1" are known-guilty, probably |
455 other versions are too) writes ID3v2.3 comment tags using a |
476 other versions are too) writes ID3v2.3 comment tags using a |
456 frame name 'COM ' which is not valid for ID3v2.3+ (it's an |
477 frame name 'COM ' which is not valid for ID3v2.3+ (it's an |
457 ID3v2.2-style frame name) (detected by getID3()) |
478 ID3v2.2-style frame name) (detected by getID3()) |
458 * MP2enc does not encode mono CBR MP2 files properly (half speed |
479 * MP2enc does not encode mono CBR MP2 files properly (half speed |
600 * http://pda.etsi.org/pda/queryform.asp |
621 * http://pda.etsi.org/pda/queryform.asp |
601 * http://cpansearch.perl.org/src/RGIBSON/Audio-DSS-0.02/lib/Audio/DSS.pm |
622 * http://cpansearch.perl.org/src/RGIBSON/Audio-DSS-0.02/lib/Audio/DSS.pm |
602 * http://trac.musepack.net/trac/wiki/SV8Specification |
623 * http://trac.musepack.net/trac/wiki/SV8Specification |
603 * http://wyday.com/cuesharp/specification.php |
624 * http://wyday.com/cuesharp/specification.php |
604 * http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html |
625 * http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html |
|
626 * http://www.codeproject.com/Articles/8295/MPEG-Audio-Frame-Header |
|
627 * http://dsd-guide.com/sites/default/files/white-papers/DSFFileFormatSpec_E.pdf |