Code Monkey home page Code Monkey logo

getid3's Introduction

getID3() by James Heinrich ([email protected])

Available at http://getid3.sourceforge.net or https://www.getid3.org

getID3() is released under multiple licenses. You may choose from the following licenses, and use getID3 according to the terms of the license most suitable to your project.

GNU GPL:

GNU LGPL:

Mozilla MPL:

getID3 Commercial License:

  • gCL (no longer available, existing licenses remain valid)

Copies of each of the above licenses are included in the licenses/ directory of the getID3 distribution.

If you want to donate, there is a link on https://www.getid3.org for PayPal donations.

Quick Start

Q: How can I check that getID3() works on my server/files?

A: Unzip getID3() to a directory, then access /demos/demo.browse.php

Support

Q: I have a question, or I found a bug. What do I do?

A: The preferred method of support requests and/or bug reports is the forum at http://support.getid3.org/

Sourceforge Notification

It's highly recommended that you sign up for notification from Sourceforge for when new versions are released. Please visit: http://sourceforge.net/project/showfiles.php?group_id=55859 and click the little "monitor package" icon/link. If you're previously signed up for the mailing list, be aware that it has been discontinued, only the automated Sourceforge notification will be used from now on.

What does getID3() do?

Reads & parses (to varying degrees):

  • tags:

    • APE (v1 and v2)
    • ID3v1 (& ID3v1.1)
    • ID3v2 (v2.4, v2.3, v2.2)
    • Lyrics3 (v1 & v2)
  • audio-lossy:

    • MP3/MP2/MP1
    • MPC / Musepack
    • Ogg (Vorbis, OggFLAC, Speex, Opus)
    • AAC / MP4
    • AC3
    • DTS
    • RealAudio
    • Speex
    • DSS
    • VQF
  • audio-lossless:

    • AIFF
    • AU
    • Bonk
    • CD-audio (*.cda)
    • FLAC
    • LA (Lossless Audio)
    • LiteWave
    • LPAC
    • MIDI
    • Monkey's Audio
    • OptimFROG
    • RKAU
    • Shorten
    • Tom's lossless Audio Kompressor (TAK)
    • TTA
    • VOC
    • WAV (RIFF)
    • WavPack
  • audio-video:

    • ASF: ASF, Windows Media Audio (WMA), Windows Media Video (WMV)
    • AVI (RIFF)
    • Flash
    • Matroska (MKV)
    • MPEG-1 / MPEG-2
    • NSV (Nullsoft Streaming Video)
    • Quicktime (including MP4)
    • RealVideo
  • still image:

    • BMP
    • GIF
    • JPEG
    • PNG
    • TIFF
    • SWF (Flash)
    • PhotoCD
  • data:

    • ISO-9660 CD-ROM image (directory structure)
    • SZIP (limited support)
    • ZIP (directory structure)
    • TAR
    • CUE
  • Writes:

    • ID3v1 (& ID3v1.1)
    • ID3v2 (v2.3 & v2.4)
    • VorbisComment on OggVorbis
    • VorbisComment on FLAC (not OggFLAC)
    • APE v2
    • Lyrics3 (delete only)

Requirements

  • PHP 4.2.0 up to 5.2.x for getID3() 1.7.x (and earlier)
  • PHP 5.0.5 (or higher) for getID3() 1.8.x (and up)
  • PHP 5.0.5 (or higher) for getID3() 2.0.x (and up)
  • at least 4MB memory for PHP. 8MB or more is highly recommended. 12MB is required with all modules loaded.

Installation

The preferred method is via composer. Follow the installation instructions if you do not already have composer installed.

Once composer is installed, execute the following command in your project root to install this library:

composer require james-heinrich/getid3

Usage

See /demos/demo.basic.php for a very basic use of getID3() with no fancy output, just scanning one file.

See structure.txt for the returned data structure.

For an example of a complete directory-browsing, file-scanning implementation of getID3(), please run /demos/demo.browse.php

See /demos/demo.mysql.php for a sample recursive scanning code that scans every file in a given directory, and all sub-directories, stores the results in a database and allows various analysis / maintenance operations

To analyze remote files over HTTP or FTP you need to copy the file locally first before running getID3(). Your code would look something like this:

<?php

// Copy remote file locally to scan with getID3()
$remotefilename = 'http://www.example.com/filename.mp3';
if ($fp_remote = fopen($remotefilename, 'rb')) {
    $localtempfilename = tempnam('/tmp', 'getID3');
    if ($fp_local = fopen($localtempfilename, 'wb')) {
        while ($buffer = fread($fp_remote, 8192)) {
            fwrite($fp_local, $buffer);
        }
        fclose($fp_local);
        // Initialize getID3 engine
        $getID3 = new getID3;
        $ThisFileInfo = $getID3->analyze($localtempfilename);
        // Delete temporary file
        unlink($localtempfilename);
    }
    fclose($fp_remote);
}

See /demos/demo.write.php for how to write tags.

What does the returned data structure look like?

See structure.txt

It is recommended that you look at the output of /demos/demo.browse.php scanning the file(s) you're interested in to confirm what data is actually returned for any particular filetype in general, and your files in particular, as the actual data returned may vary considerably depending on what information is available in the file itself.

Notes

getID3() 1.x:

If the format parser encounters a critical problem, it will return something in $fileinfo['error'], describing the encountered error. If a less critical error or notice is generated it will appear in $fileinfo['warning']. Both keys may contain more than one warning or error. If something is returned in ['error'] then the file was not correctly parsed and returned data may or may not be correct and/or complete. If something is returned in ['warning'] (and not ['error']) then the data that is returned is OK - usually getID3() is reporting errors in the file that have been worked around due to known bugs in other programs. Some warnings may indicate that the data that is returned is OK but that some data could not be extracted due to errors in the file.

getID3() 2.x:

See above except errors are thrown (so you will only get one error).

Disclaimer

getID3() has been tested on many systems, on many types of files, under many operating systems, and is generally believe to be stable and safe. That being said, there is still the chance there is an undiscovered and/or unfixed bug that may potentially corrupt your file, especially within the writing functions. By using getID3() you agree that it's not my fault if any of your files are corrupted. In fact, I'm not liable for anything :)

License

GNU General Public License - see license.txt

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to: Free Software Foundation, Inc. 59 Temple Place - Suite 330 Boston, MA 02111-1307, USA.

FAQ:

Q: Can I use getID3() in my program? Do I need a commercial license?

A: You're generally free to use getID3 however you see fit. The only case in which you would require a commercial license is if you're selling your closed-source program that integrates getID3. If you sell your program including a copy of getID3, that's fine as long as you include a copy of the sourcecode when you sell it. Or you can distribute your code without getID3 and say "download it from getid3.sourceforge.net"

Why is it called "getID3()" if it does so much more than just that?

v0.1 did in fact just do that. I don't have a copy of code that old, but I could essentially write it today with a one-line function:

function getID3($filename) { return unpack('a3TAG/a30title/a30artist/a30album/a4year/a28comment/c1track/c1genreid', substr(file_get_contents($filename), -128)); }

Future Plans

https://www.getid3.org/phpBB3/viewforum.php?f=7

Known Bugs/Issues in getID3() that may be fixed eventually

https://www.getid3.org/phpBB3/viewtopic.php?t=25

  • Cannot determine bitrate for MPEG video with VBR video data (need documentation)
  • Interlace/progressive cannot be determined for MPEG video (need documentation)
  • MIDI playtime is sometimes inaccurate
  • AAC-RAW mode files cannot be identified
  • WavPack-RAW mode files cannot be identified
  • mp4 files report lots of "Unknown QuickTime atom type" (need documentation)
  • Encrypted ASF/WMA/WMV files warn about "unhandled GUID ASF_Content_Encryption_Object"
  • Bitrate split between audio and video cannot be calculated for NSV, only the total bitrate. (need documentation)
  • All Ogg formats (Vorbis, OggFLAC, Speex) are affected by the problem of large VorbisComments spanning multiple Ogg pages, but but only OggVorbis files can be processed with vorbiscomment.
  • The version of "head" supplied with Mac OS 10.2.8 (maybe other versions too) does only understands a single option (-n) and therefore fails. getID3 ignores this and returns wrong md5_data.

Known Bugs/Issues in getID3() that cannot be fixed

https://www.getid3.org/phpBB3/viewtopic.php?t=25

  • 32-bit PHP installations only: Files larger than 2GB cannot always be parsed fully by getID3() due to limitations in the 32-bit PHP filesystem functions. NOTE: Since v1.7.8b3 there is partial support for larger-than- 2GB files, most of which will parse OK, as long as no critical data is located beyond the 2GB offset. Known will-work:
    • all file formats on 64-bit PHP
    • ZIP (format doesn't support files >2GB)
    • FLAC (current encoders don't support files >2GB) Known will-not-work:
    • ID3v1 tags (always located at end-of-file)
    • Lyrics3 tags (always located at end-of-file)
    • APE tags (always located at end-of-file) Maybe-will-work:
    • Quicktime (will work if needed metadata is before 2GB offset, that is if the file has been hinted/optimized for streaming)
    • RIFF.WAV (should work fine, but gives warnings about not being able to parse all chunks)
    • RIFF.AVI (playtime will probably be wrong, is only based on "movi" chunk that fits in the first 2GB, should issue error to show that playtime is incorrect. Other data should be mostly correct, assuming that data is constant throughout the file)

Known Bugs/Issues in other programs

https://www.getid3.org/phpBB3/viewtopic.php?t=25

  • Windows Media Player (up to v11) and iTunes (up to v10+) do not correctly handle ID3v2.3 tags with UTF-16BE+BOM encoding (they assume the data is UTF-16LE+BOM and either crash (WMP) or output Asian character set (iTunes)
  • Winamp (up to v2.80 at least) does not support ID3v2.4 tags, only ID3v2.3 see: http://forums.winamp.com/showthread.php?postid=387524
  • Some versions of Helium2 (www.helium2.com) do not write ID3v2.4-compliant Frame Sizes, even though the tag is marked as ID3v2.4) (detected by getID3())
  • MP3ext V3.3.17 places a non-compliant padding string at the end of the ID3v2 header. This is supposedly fixed in v3.4b21 but only if you manually add a registry key. This fix is not yet confirmed. (detected by getID3())
  • CDex v1.40 (fixed by v1.50b7) writes non-compliant Ogg comment strings, supposed to be in the format "NAME=value" but actually written just "value" (detected by getID3())
  • Oggenc 0.9-rc3 flags the encoded file as ABR whether it's actually ABR or VBR.
  • iTunes (versions "X v2.0.3", "v3.0.1" are known-guilty, probably other versions are too) writes ID3v2.3 comment tags using a frame name 'COM ' which is not valid for ID3v2.3+ (it's an ID3v2.2-style frame name) (detected by getID3())
  • MP2enc does not encode mono CBR MP2 files properly (half speed sound and double playtime)
  • MP2enc does not encode mono VBR MP2 files properly (actually encoded as stereo)
  • tooLAME does not encode mono VBR MP2 files properly (actually encoded as stereo)
  • AACenc encodes files in VBR mode (actually ABR) even if CBR is specified
  • AAC/ADIF - bitrate_mode = cbr for vbr files
  • LAME 3.90-3.92 prepends one frame of null data (space for the LAME/VBR header, but it never gets written) when encoding in CBR mode with the DLL
  • Ahead Nero encodes TwinVQF with a DSIZ value (which is supposed to be the filesize in bytes) of "0" for TwinVQF v1.0 and "1" for TwinVQF v2.0 (detected by getID3())
  • Ahead Nero encodes TwinVQF files 1 second shorter than they should be
  • AAC-ADTS files are always actually encoded VBR, even if CBR mode is specified (the CBR-mode switches on the encoder enable ABR mode, not CBR as such, but it's not possible to tell the difference between such ABR files and true VBR)
  • STREAMINFO.audio_signature in OggFLAC is always null. "The reason it's like that is because there is no seeking support in libOggFLAC yet, so it has no way to go back and write the computed sum after encoding. Seeking support in Ogg FLAC is the #1 item for the next release." - Josh Coalson (FLAC developer) NOTE: getID3() will calculate md5_data in a method similar to other file formats, but that value cannot be compared to the md5_data value from FLAC data in a FLAC file format.
  • STREAMINFO.audio_signature is not calculated in FLAC v0.3.0 & v0.4.0 - getID3() will calculate md5_data in a method similar to other file formats, but that value cannot be compared to the md5_data value from FLAC v0.5.0+
  • RioPort (various versions including 2.0 and 3.11) tags ID3v2 with a WCOM frame that has no data portion
  • Earlier versions of Coolplayer adds illegal ID3 tags to Ogg Vorbis files, thus making them corrupt.
  • Meracl ID3 Tag Writer v1.3.4 (and older) incorrectly truncates the last byte of data from an MP3 file when appending a new ID3v1 tag. (detected by getID3())
  • Lossless-Audio files encoded with and without the -noseek switch do actually differ internally and therefore cannot match md5_data
  • iTunes has been known to append a new ID3v1 tag on the end of an existing ID3v1 tag when ID3v2 tag is also present (detected by getID3())
  • MediaMonkey may write a blank RGAD ID3v2 frame but put actual replay gain adjustments in a series of user-defined TXXX frames (detected and handled by getID3() since v1.9.2)

Reference material:

www.id3.org material now mirrored at http://id3lib.sourceforge.net/id3/

getid3's People

Contributors

aflowofcode avatar alex-enchi avatar aonamrata avatar appchecker avatar ben-xo avatar bvibber avatar carlcs avatar devzing avatar eevan78 avatar ekzobrain avatar eventideglow avatar fatindeed avatar jamesheinrich avatar jmper avatar jrfnl avatar lifeofguenter avatar mitchray avatar morrisjobke avatar paulijar avatar phansys avatar presskopp avatar rafiahmedd avatar reedy avatar rello avatar studiomax avatar szepeviktor avatar tstarling avatar vinnikovv avatar weikinhuang avatar xhenner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

getid3's Issues

Write aiff metadata and add cover art.

Hello, is posible to add aiff metadata and cover art?
I am trying but I am getting the message that aiff not support ID3v2.2 tags.

Can you give me a simple example?
Thanks so much.
Best.
Pablo.

Invalid argument supplied for foreach - Line 1229

Using version 1.9.7-20130705 of getID3 we're getting the following error occasionally:

PHP Warning: Invalid argument supplied for foreach() in /path/to/getid3/getid3.lib.php on line 1229 (I changed the path shown in the error).

Unfortunately we haven't got a test file to give as it came from a user, just showed up in our error log on a busy system.. so there's no easy way of finding the user/file which caused it. I just know it was either a WAV or MP3 file.

Any ideas?

UTF-8 encoding of metadata

Hi,
I'm looking at your module. It looks very convenient and usefull.
Did you consider UTF-8 encoding of metadata ?
Like IPTC tags and EXIF can be utf encoded strings for images.

Just an example. The copyright information can of course contain ©MyName, but when I look with getID3-master/demos/demo.browse.php at an image having this copyright Notice in the IPTC it is shown as ?MyName, so the copyright character is not ok any more.

wrong break

getid3lib.php line 285

{
                throw new Exception('ERROR: Cannot have signed integers larger than '.(8 * PHP_INT_SIZE).'-bits ('.strlen($byteword).') in self::BigEndian2Int()');
                break;
            }

break is incorrect, since we are in level 1 - could be removed, because of the exception.

Composer support

This package does not currently have Composer support. There are a few forks that add such support. However, for including in my project, I prefer the main version to have the Composer support I need.

If I create a pull request that adds such support, can I expect it to be merged (assuming the PR done properly)?

Wrong mimetype for m4v files (video/quicktime)

The issue was first opened in:
ampache/ampache#909

The wrong mime-type is assigned to m4v files.
In the database table "video" it is "video/quicktime" which is not correct. Should be "video/mp4".
And not every browser supports quicktime as container.

During the scan following method is called:
GetFileFormat in getId3.php

The method iterates over a set of fileformat objects, that have a defined pattern field, which are checked with the header of the file(if it matches). Unfortunately it also matches with m4v files.

For quick time the entry is the following:
// QT - audio/video - Quicktime
'quicktime' => array(
'pattern' => '^.{4}(cmov|free|ftyp|mdat|moov|pnot|skip|wide)',
'group' => 'audio-video',
'module' => 'quicktime',
'mime_type' => 'video/quicktime',
)

Release 1.9.8

Since there are quite some bug fixes in, after the previous release, how about making a new one?

Typo in composer.json

"name": "jamesheinrich/getid3", but it should be "name": "james-heinrich/getid3",

Japanese tags

I upload mp3 files with Japanese tags and get '???' in the fields. How to fix it?

Move global constants to class constants

We have a load of constants that are relevant to particular classes, but are created into the global namespace, these should be added to the classes they relate to

PHP version requirement for 1.9.8?

There's nothing noting it that I can see in the changelog or the getID3 homepage, but version 1.9.8 now appears to require PHP 5.3 or higher.

Is that intended?

(Unrelated note: the homepage seems to be off by a year on the release date of 1.9.8)

getID3 replaces "gs://" with "gs:/" in Google Cloud Storage filenames leading file not found errors

Hi,

I was trying to integrate getID3 in a google app engine project, I am currently working on. We use google cloud storage for storing audio files. The PHP runtime on appengine has the Google Cloud Storage stream wrapper built in, thus allowing use of standard PHP file system functions to access the objects using the 'gs://' stream.

However getID3 replaces the two forward slashes in 'gs://' with a single slash thus making the file path invalid and eventually failing (since it could not find the file).

I am using (if it is relevant by any chance)

  • getID3 v1.9.9
  • PHP 5.5 running on Google app engine

Thanks

GetID3 and Php 7

Hi,

GetID3 uses a lot the "list()" function, but its behavior has changed in php7. Don't check for other changes, but do you plan to update getId3 1.x?

Sincerely,

Daniel Berthereau
Infodoc & Knowledge management

Arrays not working to write

demos/demo.simple.write.php (line 48):
'popularimeter' => array('email'=>'[email protected]', 'rating'=>128, 'data'=>0),

Always throw:
WriteID3v2() failed with message(s):
[email] not specified for POPM
Frame "POPM" is NOT allowed
$this->GenerateID3v2FrameData() failed for "POPM"
$this->GenerateID3v2Tag() failed

Too for 'unique_file_identifier', never find 'ownerid'

Support for extracting images

Stumbled upon this awesome php library yesterday in my quest for an on demand and properly formatted JSON mp3 parser for use with an android app that I am building - cannot believe this library is this powerful in comparison with some of the outdated and inconvenient alternatives.
I am no good at php and yet I got the data I needed within minutes of copying this library to my server.
Now, I am working on adding cache support for the extracted data and extracting the album art - but first, I would like to make sure that it is possible to do so and how (meaning, can you provide a sample of how to do this with php - do I need an array of some sort to be able to take an embedded album art and output to a file with $fopen($filename, w)).
I have looked at the browse demo file but some of that code goes right over my head...

(Speaking of cache, the my sqlite3 db keeps growing instead of caching, just checked the tables and the data is the same, just duplicated - but that is another issue)

This is what I put together in order to build that JSON:

<?php

require_once('/volume1/auto/getID3/getid3/getid3.php');
//require_once('/volume1/auto/getID3/getid3/extension.cache.sqlite3.php');

setlocale(LC_ALL, 'en_US.UTF-8');

// Where are we running on?
// if (PHP_SAPI === 'cli') {
//     $argument1 = $argv[1];
//     $argument2 = $argv[2];
// } else {
//     $argument1 = $_GET['argument1'];
//     $argument2 = $_GET['argument2'];
// }

/*
 * @param Array $types
 * @abstract Array of allowed file types
 */
$types = ['mp3'];
$ignoreDir = ['@eaDir'];

/*
 * @name getList
 * @param Array $dir
 * @param Array $types
 * @param Array $ignoreDir
 * @abstract Recursively iterates over specified directory
 *           populating array based on array of file extensions
 *           while ignoring directories specified in ignoreDir
 * @return Array $files
 */

function getList($dir, $types, $ignoreDir) {
    $it = new RecursiveDirectoryIterator($dir);
    foreach (new RecursiveIteratorIterator($it) as $file) {
        if (in_array(strtolower(array_pop(explode('.', $file))), $types)) {
            if (!in_array($it, $ignoreDir)) {
                $files[] = $file->__toString();
            }
        }
    }
    return $files;
}

/*
 * @name getDetails
 * @param Array $dir
 * @param Array $types
 * @abstract Recursively iterates over specified directory
 *           populating array with details of each file
 * @return Array $files
 */

function getDetails($types, $array) {
    foreach ($types as $type) {
        $getID3 = new getID3;                                               // Initialize getID3 engine
        //$getID3 = new getID3_cached_mysql('localhost', 'getid3', 'id3', 'id3_cache', 'getid3_cache'); // MySQL
        //$getID3 = new getID3_cached_sqlite3($table='getid3_cache', $hide=FALSE);                      // SQLite3
        $getID3->encoding = 'UTF-8';
        foreach ($array as $file) {
            if (strcasecmp($type, array_pop(explode('.', $file))) == 0) {
                $info = $getID3->analyze($file);                            // Analyse each file
                //getid3_lib::CopyTagsToComments($info);                    // Copy tags to comments
                $title = $info['tags']['id3v2']['title'][0];                // title from ID3v2
                $artist = $info['tags']['id3v2']['artist'][0];              // artist from ID3v2
                $bitrate = round($info['audio']['bitrate'] / 1000).' kbps'; // audio bitrate
                $playtime = $info['playtime_string'];                       // playtime in minutes:seconds, formatted string
                $details = array(
                    'title' => $title,
                    'artist' => $artist,
                    'size' => filesize($file),
                    'bitrate' => $bitrate,
                    'playtime' => $playtime,
                    'source' => $file,
                    'date' => date ("F d Y H:i:s", filemtime($file))
                );
            $files[$type][] = $details;
            }
        }
    }
    return array('files' => $files);
}

$scanDir = ('/volume1/web/.apps/nightmistful/assets/');
$to_encode = getDetails($types, getList($scanDir, $types, $ignoreDir));
echo json_encode($to_encode, JSON_PRETTY_PRINT);
exit();

BOM showing as text in TXXX tag description

I have some files encoded in UTF-16 and if I check the frame headers of the TXXX tags, the encoding byte is set to 01.

encoding

But when getid3 reads the TXXX tags, it shows the bom before the text description. I don't think it's the tagger - tried both mp3tag and picard. Here it is in mp3tag showing the charset and the extended tags:

charset

mp3tag

and here is the output from demo.basic.php:

bom1

Then if I look at the same file in mp3diag it shows the bom on the text value which is what I thought getid3 was doing at first:

mp3diags

Confusing. Any ideas?

Cyrillics detect fix

Hello, guys! I'm from russian-speaking country and I must notice, that the "ID3v1 encoding detection hack" in the getid3.php line 1246 does not work.

This code looks through all the tags, looking for one which contains only cyrillics:

if (preg_match('#^[\\x80-\\xFF]+$#', $value))

But no one of them match because of..... spaces :-) Cause 0x80...0xFF covers only the alphabet and does not cover special chars, see: http://vk.cc/5ua21p

So, if we rewrite it like this '#^[\\x00-\\x40\\xA8\\B8\\x80-\\xFF]+$#' we'll make the world better.

beforeafter

Actually I can't say it will fix 100% tracks, cause it's not uncommon to name a group or track with latin includings. Like The Very Best Of (cyrillic_artist_name), or foreign artist with only the song name translated, or special remarks like "Luciano Pavarotti - Вернись в Сорренто (remastered)". And so on.

Test .mp3 set: https://yadi.sk/d/1DZiwg8ru8h4M

Ensure all classes can be autoloaded

This has mostly been completed, although the Module\AudioVideo\Matroska class still uses some old dynamically generated class names.

We should create a document listing the old class names and their new ones as part of the upgrade guide

Multiple genres on AAC/M4A (quicktime) files treated as one tag

Initially reported on Ampache github issue tracker
ampache/ampache#970

Determined that mutliple genres, regardless of delimiter separator, are being treated as a single tag for quicktime audio files. For example, a quicktime file tagged with genre 'Rock;Hard Rock;Metal' will display that tag availability as 'Rock;Hard Rock;Metal'.

Confirmed that this same issue does not exist for MP3s. MP3s using the same tagging convention will split the tags as expected.

Remove support for deprecated/removed php features

The minimum php version we will support is 5.4, so anything that was removed by then should not be used/considered inside getID3.

We should also look to avoid any deprecated features, the obvious one is the mysql cache which uses the mysql_ functions, but there are a few others. We could provide an interface to allow developers to create their own cache handlers

This will likely need multiple issues to follow once we've identified all the features that need updating

Strict Errors

I'm getting these errors after moving to a new server, I've used this library for a long without any issues. I even have ~E_Strict turned off in php.ini but to no avail!

Strict Standards: Non-static method getid3_lib::IncludeDependency() should not be called statically, assuming $this from incompatible context in /home/rsv/subdomains/mwbe/admin/includes/getid3/getid3.php on line 266

Strict Standards: Non-static method getid3_lib::BigEndian2Int() should not be called statically, assuming $this from incompatible context in /home/rsv/subdomains/mwbe/admin/includes/getid3/module.tag.id3v2.php on line 99

Strict Standards: Non-static method getid3_lib::CastAsInt() should not be called statically, assuming $this from incompatible context in /home/rsv/subdomains/mwbe/admin/includes/getid3/getid3.lib.php on line 265

Strict Standards: Non-static method getid3_lib::trunc() should not be called statically, assuming $this from incompatible context in /home/rsv/subdomains/mwbe/admin/includes/getid3/getid3.lib.php on line 65

Strict Standards: Non-static method getid3_lib::BigEndian2Int() should not be called statically, assuming $this from incompatible context in /home/rsv/subdomains/mwbe/admin/includes/getid3/module.tag.id3v2.php on line 264

Strict Standards: Non-static method getid3_lib::CastAsInt() should not be called statically, assuming $this from incompatible context in /home/rsv/subdomains/mwbe/admin/includes/getid3/getid3.lib.php on line 265

Strict Standards: Non-static method getid3_lib::trunc() should not be called statically, assuming $this from incompatible context in /home/rsv/subdomains/mwbe/admin/includes/getid3/getid3.lib.php on line 65

Strict Standards: Non-static method getid3_lib::BigEndian2Int() should not be called statically, assuming $this from incompatible context in /home/rsv/subdomains/mwbe/admin/includes/getid3/module.tag.id3v2.php on line 283

Strict Standards: Non-static method getid3_lib::CastAsInt() should not be called statically, assuming $this from incompatible context in /home/rsv/subdomains/mwbe/admin/includes/getid3/getid3.lib.php on line 265

Strict Standards: Non-static method getid3_lib::trunc() should not be called statically, assuming $this from incompatible context in /home/rsv/subdomains/mwbe/admin/includes/getid3/getid3.lib.php on line 65

Strict Standards: Non-static method getid3_lib::CastAsInt() should not be called statically, assuming $this from incompatible context in /home/rsv/subdomains/mwbe/admin/includes/getid3/module.tag.id3v2.php on line 315

Setup phpunit

We need to get some unit tests set up, phpunit is the accepted way of running these so create a phpunit.xml configuration and a tests directory and update .gitattributes to not package them

Files with UTF-16 TIT2 (and others) have invalid bytes before name

I have some files that have utf-16 titles. When looking at them in demo.browse, the values get prefixed with invalid characters. These show up as ? chars in my browser, but looking at the returned data, they are not valid utf-16 either. For instance, for one file, the comments_html section contains:

album   array (1)   0   string (22)     &#2089536;[correct subsequent characters for album]

This is for a number of different files, and other tools process the tags correctly.

Let me know if you need more info, or what else I can do to help track down what's wrong. I'm on version 1.9.10-20150914

Specified key was too long; max key length is 1000 bytes

I ship getid3 with a Joomla extension, and have found that where users have a multi-byte default character set like UTF8 in MySQL, the create_table() in extension.cache.mysql.php blows up with "Specified key was too long; max key length is 1000 bytes", because the VARCHAR(500) filename field index winds up being too long, as each character is 3 bytes.

I've kind of hacked around it by adding "CHARACTER SET latin1" to the CREATE TABLE, although I'm not sure if this is a valid fix, as I'm really not sure what different OS's do with multibyte characters in filenames.

GPS Coordinates

We are trying to use getID3 to get meta data of videos uploaded to our service. It is working great but for some reason never returns any GPS information. The output we are receiving from ExifTool is here:
https://gist.github.com/CMDann/15f02efb3d71143b3677

Most important is this information:
GPS Altitude : 236 m
GPS Altitude Ref : Above Sea Level
GPS Latitude : 49 deg 40' 22.80" N
GPS Longitude : 97 deg 6' 24.12" W
GPS Position : 49 deg 40' 22.80" N, 97 deg 6' 24.12" W

The getID3 is super long so you can view it over here: https://gist.github.com/CMDann/8a0146b0e4644c858bdb

if it helps. Is there any way to get this information from getID3?

Roadmap for 2.0?

Wanted to know if there's a roadmap for 2.0? Would like to contribute, but not sure where to start or what exactly is needed. Thanks 😄

open_base_dir restriction

Can you consider changing this line to:

$tempdir = sys_get_temp_dir();

My php install has an open_base_dir restriction in effect and generating album art using getID3 floods my command line with warnings - an example is provided here.

Working with temp files

The following functions in PHP fail to provide the correct result with files created using tempnam(…) function

  • is_readable
  • is_writeable

Imagine a file is being read into a tempfile from the internet, getID3 will fail to process it.

PHP 5.5.30

No meta from m4a files

Scanning through the moov array I am not seeing any artist or title information being retrieved from these files, nor do they show up in comments or tags.

They do show up in other players, like VLC here.
VLC media info

Download m4a file from MediaFire

Note that moov udta meta has a 4149 size, but no sub atoms.

Array
(
    [GETID3_VERSION] => 1.9.11-201512241248
    [filesize] => 13771853
    [filepath] => /var/music/Techno/Len Faki
    [filename] => Len Faki - Death by House.m4a
    [filenamepath] => /var/music/Techno/Len Faki/Len Faki - Death by House.m4a
    [avdataoffset] => 80021
    [avdataend] => 13771853
    [fileformat] => mp4
    [audio] => Array
        (
            [dataformat] => mp4
            [codec] => ISO/IEC 14496-3 AAC
            [sample_rate] => 44100
            [channels] => 2
            [bits_per_sample] => 16
            [lossless] => 
            [channelmode] => stereo
            [bitrate] => 253589.07610741
            [compression_ratio] => 0.17969747456591
            [streams] => Array
                (
                    [0] => Array
                        (
                            [dataformat] => mp4
                            [codec] => ISO/IEC 14496-3 AAC
                            [sample_rate] => 44100
                            [channels] => 2
                            [bits_per_sample] => 16
                            [lossless] => 
                            [channelmode] => stereo
                            [bitrate] => 253589.07610741
                            [compression_ratio] => 0.17969747456591
                        )

                )

        )

    [video] => Array
        (
            [resolution_x] => 0
            [resolution_y] => 0
            [frame_rate] => 43.06640625
            [dataformat] => quicktime
        )

    [comments] => Array
        (
            [language] => Array
                (
                    [0] => Undetermined
                )

        )

    [encoding] => UTF-8
    [mime_type] => audio/mp4
    [quicktime] => Array
        (
            [hinting] => 
            [controller] => standard
            [ftyp] => Array
                (
                    [hierarchy] => ftyp
                    [name] => ftyp
                    [size] => 32
                    [offset] => 0
                    [signature] => M4A 
                    [unknown_1] => 0
                    [fourcc] => M4A 
                )

            [moov] => Array
                (
                    [hierarchy] => moov
                    [name] => moov
                    [size] => 79981
                    [offset] => 32
                    [subatoms] => Array
                        (
                            [0] => Array
                                (
                                    [hierarchy] => moov mvhd
                                    [name] => mvhd
                                    [size] => 108
                                    [offset] => 40
                                    [version] => 0
                                    [flags_raw] => 0
                                    [creation_time] => 3535552270
                                    [modify_time] => 3535552270
                                    [time_scale] => 44100
                                    [duration] => 19048448
                                    [preferred_rate] => 1
                                    [preferred_volume] => 1
                                    [reserved] => 
                                    [matrix_a] => 1
                                    [matrix_b] => 0
                                    [matrix_u] => 0
                                    [matrix_c] => 0
                                    [matrix_d] => 1
                                    [matrix_v] => 0
                                    [matrix_x] => 0
                                    [matrix_y] => 0
                                    [matrix_w] => 1
                                    [preview_time] => 0
                                    [preview_duration] => 0
                                    [poster_time] => 0
                                    [selection_time] => 0
                                    [selection_duration] => 0
                                    [current_time] => 0
                                    [next_track_id] => 2
                                    [creation_time_unix] => 1452707470
                                    [modify_time_unix] => 1452707470
                                )

                            [1] => Array
                                (
                                    [hierarchy] => moov trak
                                    [name] => trak
                                    [size] => 75708
                                    [offset] => 148
                                    [subatoms] => Array
                                        (
                                            [0] => Array
                                                (
                                                    [hierarchy] => moov trak tkhd
                                                    [name] => tkhd
                                                    [size] => 92
                                                    [offset] => 156
                                                    [version] => 0
                                                    [flags_raw] => 15
                                                    [creation_time] => 3512359584
                                                    [modify_time] => 3535552270
                                                    [trackid] => 1
                                                    [reserved1] => 0
                                                    [duration] => 19048448
                                                    [reserved2] => 0
                                                    [layer] => 0
                                                    [alternate_group] => 0
                                                    [volume] => 1
                                                    [reserved3] => 0
                                                    [matrix_a] => 1
                                                    [matrix_b] => 0
                                                    [matrix_u] => 0
                                                    [matrix_c] => 0
                                                    [matrix_d] => 1
                                                    [matrix_v] => 0
                                                    [matrix_x] => 0
                                                    [matrix_y] => 0
                                                    [matrix_w] => 1
                                                    [width] => 0
                                                    [height] => 0
                                                    [flags] => Array
                                                        (
                                                            [enabled] => 1
                                                            [in_movie] => 1
                                                            [in_preview] => 1
                                                            [in_poster] => 1
                                                        )

                                                    [creation_time_unix] => 1429514784
                                                    [modify_time_unix] => 1452707470
                                                )

                                            [1] => Array
                                                (
                                                    [hierarchy] => moov trak mdia
                                                    [name] => mdia
                                                    [size] => 75608
                                                    [offset] => 248
                                                    [subatoms] => Array
                                                        (
                                                            [0] => Array
                                                                (
                                                                    [hierarchy] => moov trak mdia mdhd
                                                                    [name] => mdhd
                                                                    [size] => 32
                                                                    [offset] => 256
                                                                    [version] => 0
                                                                    [flags_raw] => 0
                                                                    [creation_time] => 3512359584
                                                                    [modify_time] => 3535552270
                                                                    [time_scale] => 44100
                                                                    [duration] => 19048448
                                                                    [language_id] => 21956
                                                                    [quality] => 0
                                                                    [creation_time_unix] => 1429514784
                                                                    [modify_time_unix] => 1452707470
                                                                    [playtime_seconds] => 431.93759637188
                                                                    [language] => Undetermined
                                                                )

                                                            [1] => Array
                                                                (
                                                                    [hierarchy] => moov trak mdia hdlr
                                                                    [name] => hdlr
                                                                    [size] => 33
                                                                    [offset] => 288
                                                                    [version] => 0
                                                                    [flags_raw] => 0
                                                                    [component_type] => 
                                                                    [component_subtype] => soun
                                                                    [component_manufacturer] => 
                                                                    [component_flags_raw] => 0
                                                                    [component_flags_mask] => 0
                                                                    [component_name] => 
                                                                )

                                                            [2] => Array
                                                                (
                                                                    [hierarchy] => moov trak mdia minf
                                                                    [name] => minf
                                                                    [size] => 75535
                                                                    [offset] => 321
                                                                    [subatoms] => Array
                                                                        (
                                                                            [0] => Array
                                                                                (
                                                                                    [hierarchy] => moov trak mdia minf smhd
                                                                                    [name] => smhd
                                                                                    [size] => 16
                                                                                    [offset] => 329
                                                                                    [version] => 0
                                                                                    [flags_raw] => 0
                                                                                    [balance] => 0
                                                                                    [reserved] => 0
                                                                                )

                                                                            [1] => Array
                                                                                (
                                                                                    [hierarchy] => moov trak mdia minf dinf
                                                                                    [name] => dinf
                                                                                    [size] => 36
                                                                                    [offset] => 345
                                                                                    [subatoms] => Array
                                                                                        (
                                                                                            [0] => Array
                                                                                                (
                                                                                                    [hierarchy] => moov trak mdia minf dinf dref
                                                                                                    [name] => dref
                                                                                                    [size] => 28
                                                                                                    [offset] => 353
                                                                                                    [version] => 0
                                                                                                    [flags_raw] => 0
                                                                                                    [number_entries] => 1
                                                                                                    [data_references] => Array
                                                                                                        (
                                                                                                            [0] => Array
                                                                                                                (
                                                                                                                    [size] => 12
                                                                                                                    [type] => url 
                                                                                                                    [version] => 0
                                                                                                                    [flags_raw] => 1
                                                                                                                    [data] => 
                                                                                                                    [flags] => Array
                                                                                                                        (
                                                                                                                            [self_reference] => 1
                                                                                                                        )

                                                                                                                )

                                                                                                        )

                                                                                                )

                                                                                        )

                                                                                )

                                                                            [2] => Array
                                                                                (
                                                                                    [hierarchy] => moov trak mdia minf stbl
                                                                                    [name] => stbl
                                                                                    [size] => 75475
                                                                                    [offset] => 381
                                                                                    [subatoms] => Array
                                                                                        (
                                                                                            [0] => Array
                                                                                                (
                                                                                                    [hierarchy] => moov trak mdia minf stbl stsd
                                                                                                    [name] => stsd
                                                                                                    [size] => 91
                                                                                                    [offset] => 389
                                                                                                    [version] => 0
                                                                                                    [flags_raw] => 0
                                                                                                    [number_entries] => 1
                                                                                                    [sample_description_table] => Array
                                                                                                        (
                                                                                                            [0] => Array
                                                                                                                (
                                                                                                                    [size] => 75
                                                                                                                    [data_format] => mp4a
                                                                                                                    [reserved] => 0
                                                                                                                    [reference_index] => 1
                                                                                                                    [encoder_version] => 0
                                                                                                                    [encoder_revision] => 0
                                                                                                                    [encoder_vendor] => 
                                                                                                                    [audio_channels] => 2
                                                                                                                    [audio_bit_depth] => 16
                                                                                                                    [audio_compression_id] => 0
                                                                                                                    [audio_packet_size] => 0
                                                                                                                    [audio_sample_rate] => 44100
                                                                                                                    [temporal_quality] => 131088
                                                                                                                    [spatial_quality] => 0
                                                                                                                    [width] => 44100
                                                                                                                    [height] => 0
                                                                                                                    [resolution_x] => 25971.392379761
                                                                                                                    [resolution_y] => 0
                                                                                                                    [data_size] => 51970049
                                                                                                                    [frame_count] => 4
                                                                                                                    [compressor_name] => �@�
                                                                                                                    [pixel_depth] => 0
                                                                                                                    [color_table_id] => 0
                                                                                                                )
                                                                                                        )

                                                                                                )

                                                                                            [1] => Array
                                                                                                (
                                                                                                    [hierarchy] => moov trak mdia minf stbl stts
                                                                                                    [name] => stts
                                                                                                    [size] => 24
                                                                                                    [offset] => 480
                                                                                                    [version] => 0
                                                                                                    [flags_raw] => 0
                                                                                                    [number_entries] => 1
                                                                                                    [time_to_sample_table] => Array
                                                                                                        (
                                                                                                            [0] => Array
                                                                                                                (
                                                                                                                    [sample_count] => 18602
                                                                                                                    [sample_duration] => 1024
                                                                                                                )

                                                                                                        )

                                                                                                )

                                                                                            [2] => Array
                                                                                                (
                                                                                                    [hierarchy] => moov trak mdia minf stbl stsc
                                                                                                    [name] => stsc
                                                                                                    [size] => 52
                                                                                                    [offset] => 504
                                                                                                )

                                                                                            [3] => Array
                                                                                                (
                                                                                                    [hierarchy] => moov trak mdia minf stbl stsz
                                                                                                    [name] => stsz
                                                                                                    [size] => 74428
                                                                                                    [offset] => 556
                                                                                                )
                                                                                            [4] => Array
                                                                                                (
                                                                                                    [hierarchy] => moov trak mdia minf stbl stco
                                                                                                    [name] => stco
                                                                                                    [size] => 872
                                                                                                    [offset] => 74984
                                                                                                )

                                                                                        )

                                                                                )

                                                                        )

                                                                )

                                                        )

                                                )

                                        )

                                )

                            [2] => Array
                                (
                                    [hierarchy] => moov udta
                                    [name] => udta
                                    [size] => 4157
                                    [offset] => 75856
                                    [subatoms] => Array
                                        (
                                            [0] => Array
                                                (
                                                    [hierarchy] => moov udta meta
                                                    [name] => meta
                                                    [size] => 4149
                                                    [offset] => 75864
                                                    [version] => 0
                                                    [flags_raw] => 0
                                                    [subatoms] => 
                                                )

                                        )

                                )
                            [3] => Array
                                (
                                    [hierarchy] => moov mdat
                                    [name] => mdat
                                    [size] => 13691840
                                    [offset] => 80013
                                )

                        )

                )

            [time_scale] => 44100
            [display_scale] => 1
            [video] => Array
                (
                    [resolution_x] => 0
                    [resolution_y] => 0
                )

            [audio] => Array
                (
                    [codec] => mp4
                    [sample_rate] => 44100
                    [channels] => 2
                    [bit_depth] => 16
                )

            [stts_framecount] => Array
                (
                    [0] => 18602
                )

            [mdat] => Array
                (
                    [hierarchy] => mdat
                    [name] => mdat
                    [size] => 13691840
                    [offset] => 80013
                )

            [encoding] => UTF-8
        )

    [playtime_seconds] => 431.93759637188
    [bitrate] => 253589.07610741
    [playtime_string] => 7:12
)

invalid foreach() arguement

full text of the error message:

WARNING: Invalid argument supplied for foreach() in D:\test_sites\master\zp-core\zp-extensions\class-video\getid3\module.audio-video.quicktime.php on line 207 getid3_quicktime->QuicktimeParseAtom called from getid3_quicktime->QuicktimeParseContainerAtom (module.audio-video.quicktime.php [1421]) from getid3_quicktime->QuicktimeParseAtom (module.audio-video.quicktime.php [1382]) from getid3_quicktime->QuicktimeParseContainerAtom (module.audio-video.quicktime.php [1421]) from getid3_quicktime->QuicktimeParseAtom (module.audio-video.quicktime.php [199]) from getid3_quicktime->QuicktimeParseContainerAtom (module.audio-video.quicktime.php [1421]) from getid3_quicktime->QuicktimeParseAtom (module.audio-video.quicktime.php [199]) from getid3_quicktime->Analyze (module.audio-video.quicktime.php [118]) from getID3->analyze (getid3.php [428])

Methods to clean a given file

Hi,

I have a bunch of files encoded by iTunes, which are poorly encoded. Besides the incorrect frame that was worked around some time ago in getID3, there are also a lot of other issues such as two COMM entries with the same language (eng) and the same description ("").

Then, any attempt to update tags on these files results in an error because they are invalid (just ignore the beginning of the lines, the part after the arrow is the errors from getID3):

2016-06-23 13:56:48 [phyks] (vainfo) -> Failed to write tags! ID3v2: Skipping "RECORDING_TIME" because cannot match it to a known ID3v2 frame type 
2016-06-23 13:56:48 [phyks] (vainfo) -> ID3v2: Skipping "FILE" because cannot match it to a known ID3v2 frame type 
2016-06-23 13:56:48 [phyks] (vainfo) -> ID3v2: Skipping "BITRATE" because cannot match it to a known ID3v2 frame type 
2016-06-23 13:56:48 [phyks] (vainfo) -> ID3v2: Skipping "RATE" because cannot match it to a known ID3v2 frame type 
2016-06-23 13:56:48 [phyks] (vainfo) -> ID3v2: Skipping "MODE" because cannot match it to a known ID3v2 frame type 
2016-06-23 13:56:48 [phyks] (vainfo) -> ID3v2: Skipping "MIME" because cannot match it to a known ID3v2 frame type 
2016-06-23 13:56:48 [phyks] (vainfo) -> ID3v2: Skipping "ALBUMARTIST" because cannot match it to a known ID3v2 frame type 
2016-06-23 13:56:48 [phyks] (vainfo) -> ID3v2: Skipping "MB_TRACKID" because cannot match it to a known ID3v2 frame type 
2016-06-23 13:56:48 [phyks] (vainfo) -> ID3v2: Skipping "MB_ALBUMID" because cannot match it to a known ID3v2 frame type 
2016-06-23 13:56:48 [phyks] (vainfo) -> ID3v2: Skipping "MB_ARTISTID" because cannot match it to a known ID3v2 frame type 
2016-06-23 13:56:48 [phyks] (vainfo) -> ID3v2: Skipping "MB_ALBUMARTISTID" because cannot match it to a known ID3v2 frame type 
2016-06-23 13:56:48 [phyks] (vainfo) -> ID3v2: Skipping "TRACK" because cannot match it to a known ID3v2 frame type 
2016-06-23 13:56:48 [phyks] (vainfo) -> ID3v2: Skipping "REPLAYGAIN_TRACK_GAIN" because cannot match it to a known ID3v2 frame type 
2016-06-23 13:56:48 [phyks] (vainfo) -> ID3v2: Skipping "REPLAYGAIN_TRACK_PEAK" because cannot match it to a known ID3v2 frame type 
2016-06-23 13:56:48 [phyks] (vainfo) -> ID3v2: Skipping "REPLAYGAIN_ALBUM_GAIN" because cannot match it to a known ID3v2 frame type 
2016-06-23 13:56:48 [phyks] (vainfo) -> ID3v2: Skipping "REPLAYGAIN_ALBUM_PEAK" because cannot match it to a known ID3v2 frame type 
2016-06-23 13:56:48 [phyks] (vainfo) -> WriteID3v2() failed with message(s):<pre><ul><li>Only one COMM tag allowed with the same Language + Description (eng + )</li><li>Frame &quot;COMM&quot; is NOT allowed</li><li>$this-&gt;GenerateID3v2FrameData() failed for &quot;COMM&quot;</li><li>$this-&gt;GenerateID3v2Tag() failed</li></ul></pre>

Skipped frames look ok, but the last fail is due to this COMM issue.

I could consider fixing them manually, one by one, but I think it would be really cool to have some "cleanup" method directly built-in getID3, which would mutualize efforts and most likely be safer than anything I could hack myself.

For instance, if I edit the tags of the songs using VLC, I do not have any issue and VLC manages to somehow rebuild a valid tag structure (or at least overcome invalid frames).

I can think of two solutions to this:

  • Either provide a boolean argument to be able to ignore errors and still write the (invalid) file, in the writer.
  • Or provide a cleanup function to be able to clean the file (and could optionally be called from the writer, issuing a warning accordingly).

This is actually linked to an issue encountered with tag edition in Ampache (see ampache/ampache#1271). As Ampache is used by people with various technical background, it would be better to be able to clean files or ignore errors, rather than having to ask people to fix the files by themselves.

Thanks a lot!

Add example files to tests/files/

We need some test files that we can run our test suite against. We have one for mp3, but nothing else.
They should be small files to keep the size of the repo down

Setup travis-ci

Once we have unit testing configured (#28) then we can setup continuous integration using travis-ci to ensure our changes are tested against all php versions we support

wrong encoding windows-1251

Hi
I have wrong encoding windows-1251
My code:
...
$getid3 = new getID3;
$getid3->encoding = 'UTF-8';
$fileinfo = $getid3->Analyze(Yii::getPathOfAlias('webroot').$file);
....
if( !empty($fileinfo['tags']['id3v1']['title']) ){
$audio->name = $fileinfo['tags']['id3v1']['title'][0];
}
...

fileinfo['tags']['id3v1']['title'][0] return string - "Ãîëàÿ" , but the correct result 'Голая'

I did that small fix in file getid3.lib.php:

...
public static function detect_encoding($string) {
static $list = array('ASCII', 'utf-8', 'windows-1251');
foreach ($list as $item) {
if (strcmp(@iconv($item, $item, $string), $string) == 0)
return $item;
}
return null;
}

public static function iconv_fallback($in_charset, $out_charset, $string) {

    if ($in_charset == $out_charset) {
        return $string;
    }

   // windows-1251 encoding
    if(self::detect_encoding($string) == 'windows-1251') {
        $converted_string = mb_convert_encoding($string, "utf-8", "windows-1251");
        return $converted_string;
    }

    // iconv() availble
    if (function_exists('iconv')) {
    if ($converted_string = @iconv($in_charset, $out_charset.'//TRANSLIT', $string)) {
        switch ($out_charset) {
            case 'ISO-8859-1':
                $converted_string = rtrim($converted_string, "\x00");
                break;
        }
        return $converted_string;
    }

    // iconv() may sometimes fail with "illegal character in input string" error message
    // and return an empty string, but returning the unconverted string is more useful
    return $string;
}

....

}

Declaration of getID3_cached_sqlite3

hi, how do i fix this bug?

Declaration of getID3_cached_sqlite3::analyze() should be compatible with getID3::analyze($filename, $filesize = NULL, $original_filename = '') in extension.cache.sqlite3.php on line 265

i think here is the cause

public function analyze($filename) {
...
$analysis = parent::analyze($filename);
...
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.