{"id":16414581,"url":"https://github.com/wapmorgan/mp3info","last_synced_at":"2025-04-08T09:07:24.772Z","repository":{"id":15604942,"uuid":"78479758","full_name":"wapmorgan/Mp3Info","owner":"wapmorgan","description":"The fastest PHP library to extract mp3 meta information (duration, bitrate, samplerate and so on) and tags (id3v1, id3v2).","archived":false,"fork":false,"pushed_at":"2024-06-29T22:54:40.000Z","size":99,"stargazers_count":143,"open_issues_count":8,"forks_count":40,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-01T07:46:07.322Z","etag":null,"topics":["id3v1","id3v2","media","mp3","mp3tag","mpeg"],"latest_commit_sha":null,"homepage":"https://wapmorgan.github.io/Mp3Info/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wapmorgan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-09T23:43:55.000Z","updated_at":"2025-01-23T11:48:31.000Z","dependencies_parsed_at":"2024-06-18T12:29:51.876Z","dependency_job_id":"b952c928-cc91-431a-9cf5-27f04b7fa256","html_url":"https://github.com/wapmorgan/Mp3Info","commit_stats":{"total_commits":43,"total_committers":5,"mean_commits":8.6,"dds":"0.11627906976744184","last_synced_commit":"cbbd6b306b28585e3c284b6fb53e250cfc98751e"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wapmorgan%2FMp3Info","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wapmorgan%2FMp3Info/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wapmorgan%2FMp3Info/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wapmorgan%2FMp3Info/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wapmorgan","download_url":"https://codeload.github.com/wapmorgan/Mp3Info/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247809962,"owners_count":20999816,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["id3v1","id3v2","media","mp3","mp3tag","mpeg"],"created_at":"2024-10-11T06:54:30.306Z","updated_at":"2025-04-08T09:07:24.747Z","avatar_url":"https://github.com/wapmorgan.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mp3Info\nThe fastest PHP library to get mp3 tags\u0026meta.\n\n[![Latest Stable Version](https://poser.pugx.org/wapmorgan/mp3info/v/stable)](https://packagist.org/packages/wapmorgan/mp3info)\n[![Total Downloads](https://poser.pugx.org/wapmorgan/mp3info/downloads)](https://packagist.org/packages/wapmorgan/mp3info)\n[![Latest Unstable Version](https://poser.pugx.org/wapmorgan/mp3info/v/unstable)](https://packagist.org/packages/wapmorgan/mp3info)\n[![License](https://poser.pugx.org/wapmorgan/mp3info/license)](https://packagist.org/packages/wapmorgan/mp3info)\n\nThis class extracts information from mpeg/mp3 audio:\n\n- Audio information:\n\t- Duration\n\t- Bit Rate\n\t- Sample Rate\n\t- Channels mode\n\t- Codec and Layer version\n\t- Frames count\n- Audio image (cover)\n- Audio tags:\n\n| tag     | id3v1   | id3v2 |\n|---------|---------|-------|\n| song    | song    | TIT2  |\n| artist  | artist  | TPE1  |\n| album   | album   | TALB  |\n| year    | year    | TYER  |\n| comment | comment | COMM  |\n| track   | track   | TRCK  |\n| genre   | genre   | TCON  |\n\n# Content\n1. [Usage](#usage)\n2. [Performance](#performance)\n3. [Console scanner](#console-scanner)\n4. [API](#api)\n\t- Audio information\n\t- Class methods\n\t- Settings\n4. [Technical information](#technical-information)\n\n## Usage\nAfter creating an instance of `Mp3Info` with passing filename as the first argument to the constructor, you can retrieve data from object properties (listed below).\n\n```php\nuse wapmorgan\\Mp3Info\\Mp3Info;\n// To get basic audio information\n$audio = new Mp3Info('./audio.mp3');\n\n// If you need parse tags, you should set 2nd argument this way:\n$audio = new Mp3Info('./audio.mp3', true);\n```\n\nAnd after that access object properties to get audio information:\n\n```php\necho 'Audio duration: '.floor($audio-\u003eduration / 60).' min '.floor($audio-\u003eduration % 60).' sec'.PHP_EOL;\necho 'Audio bitrate: '.($audio-\u003ebitRate / 1000).' kb/s'.PHP_EOL;\n// and so on ...\n```\n\nTo access id3v1 tags use `$tags1` property.\nTo access id3v2 tags use `$tags2` property.\nAlso, you can use combined list of tags `$tags`, where id3v2 and id3v1 tags united with id3v1 keys.\n\n```php\n// simple id3v1 tags\necho 'Song '.$audio-\u003etags1['song'].' from '.$audio-\u003etags1['artist'].PHP_EOL;\n// specific id3v2 tags\necho 'Song '.$audio-\u003etags2['TIT2'].' from '.$audio-\u003etags2['TPE1'].PHP_EOL;\n\n// combined tags (simplies way to get as more information as possible)\necho 'Song '.$audio-\u003etags['song'].' from '.$audio-\u003etags['artist'].PHP_EOL;\n```\n\n## Performance\n\n* Typically it parses one mp3-file with size around 6-7 mb in less than 0.001 sec.\n* List of 112 files with constant \u0026 variable bitRate with total duration 5:22:28 are parsed in 1.76 sec. *getId3* library against exactly the same mp3 list works for 8x-10x slower - 9.9 sec.\n* If you want, there's a very easy way to compare. Just install `nass600/get-id3` package and run console scanner against any folder with audios. It will print time that Mp3Info spent and that getId3.\n\n## Console scanner\nTo test Mp3Info you can use built-in script that scans dirs and analyzes all mp3-files inside them. To launch script against current folder:\n\n```bash\nphp bin/scan ./\n```\n\n## API\n\n### Audio information\n\n| Property           | Description                                                         | Values                                                      |\n|--------------------|---------------------------------------------------------------------|-------------------------------------------------------------|\n| `$codecVersion`    | MPEG codec version                                                  | 1 or 2                                                      |\n| `$layerVersion`    | Audio layer version                                                 | 1 or 2 or 3                                                 |\n| `$audioSize`       | Audio size in bytes. Note that this value is NOT equals file size.  | *int*                                                       |\n| `$duration`        | Audio duration in seconds.microseconds                              | like 3603.0171428571 (means 1 hour and 3 sec)               |\n| `$bitRate`         | Audio bit rate in bps                                               | like 128000 (means 128kb/s)                                 |\n| `$sampleRate`      | Audio sample rate in Hz                                             | like 44100 (means 44.1KHz)                                  |\n| `$isVbr`           | Contains `true` if audio has variable bit rate                      | *boolean*                                                   |\n| `$hasCover`        | Contains `true` if audio has a bundled image                        | *boolean*                                                   |\n| `$channel`         | Channel mode                                                        | `'stereo'` or `'dual_mono'` or `'joint_stereo'` or `'mono'` |\n| `$tags1`           | Audio tags ver. 1 (aka id3v1).                                      | [\"song\" =\u003e \"Song name\", \"year\" =\u003e 2009]                     |\n| `$tags2`           | Audio tags ver. 2 (aka id3v2), only text ones.                      | [\"TIT2\" =\u003e \"Long song name\", ...]                           |\n| `$tags`            | Combined audio tags (from id3v1 \u0026 id3v2). Keys as in tags1.         | [\"song\" =\u003e \"Long song name\", \"year\" =\u003e 2009, ...]           |\n| `$coverProperties` | Information about a bundled with audio image.                       | [\"mime_type\" =\u003e \"image/jpeg\", \"picture_type\" =\u003e 1, ...]     |\n| `$_parsingTime`    | Contains time spent to read\u0026extract audio information in *sec.msec* |                                                             |\n\n### Class methods\n- `$audio = new Mp3Info($filename, $parseTags = false)`\n    Creates new instance of object and initiate parsing. If you need to parse audio tags (id3v1 and id3v2), pass `true` as second argument is.\n\n- `$audio-\u003egetCover()`\n\tReturns raw content of bundled with audio image.\n\n- `Mp3Info::isValidAudio($filename)`\n    Static method that checks if file `$filename` looks like a mp3-file. Returns `true` if file looks like a mp3, otherwise false.\n\n### Settings\nYou can adjust some variables to reconfigure before instantiating of object:\n\n- `Mp3Info::$headerSeekLimit` - count of bytes to search for the first mpeg header in audio. Default: `2048` (bytes).\n- `Mp3Info::$framesCountRead` - count of mpeg frames to read before compute audio duration. Default: `2` (frames). \n\n## Technical information\nSupporting features:\n* id3v1\n* id3v2.3.0, id3v2.4.0\n* CBR, Variable Bit Rate (VBR)\n\nUsed sources:\n* [mpeg header description](http://mpgedit.org/mpgedit/mpeg_format/mpeghdr.htm)\n* [id3v2 tag specifications](http://id3.org/Developer%20Information). Concretely: [id3v2.3.0](http://id3.org/id3v2.3.0), [id3v2.2.0](http://id3.org/id3v2-00), [id3v2.4.0](http://id3.org/id3v2.4.0-changes)\n* [Descripion of VBR header \"Xing\"](https://multimedia.cx/mp3extensions.txt)\n* [Xing, Info and Lame tags specifications](http://gabriel.mp3-tech.org/mp3infotag.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwapmorgan%2Fmp3info","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwapmorgan%2Fmp3info","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwapmorgan%2Fmp3info/lists"}