PHPackages                             wapmorgan/mp3info - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. wapmorgan/mp3info

ActiveLibrary[Image &amp; Media](/categories/media)

wapmorgan/mp3info
=================

The fastest php library to extract mp3 tags &amp; meta information.

0.1.1(1y ago)1461.4M↓39.3%43[5 issues](https://github.com/wapmorgan/Mp3Info/issues)[3 PRs](https://github.com/wapmorgan/Mp3Info/pulls)6LGPL-3.0PHPPHP &gt;=5.4.0CI passing

Since Jan 10Pushed 1y ago7 watchersCompare

[ Source](https://github.com/wapmorgan/Mp3Info)[ Packagist](https://packagist.org/packages/wapmorgan/mp3info)[ RSS](/packages/wapmorgan-mp3info/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)DependenciesVersions (13)Used By (6)

Mp3Info
=======

[](#mp3info)

The fastest PHP library to get mp3 tags&amp;meta.

[![Latest Stable Version](https://camo.githubusercontent.com/d82e9e7679cbbe05c0fd715a54138aa2afb0c7f8990f86233dbcdef13d15533f/68747470733a2f2f706f7365722e707567782e6f72672f7761706d6f7267616e2f6d7033696e666f2f762f737461626c65)](https://packagist.org/packages/wapmorgan/mp3info)[![Total Downloads](https://camo.githubusercontent.com/a02114c6369ac42cda5d3967ab9caed29334b7d1eb1a50beaf1d680ec43e232f/68747470733a2f2f706f7365722e707567782e6f72672f7761706d6f7267616e2f6d7033696e666f2f646f776e6c6f616473)](https://packagist.org/packages/wapmorgan/mp3info)[![Latest Unstable Version](https://camo.githubusercontent.com/e286a9a9db42aee9679c798a48f1047af7ccfbcdb41231b360a665117315453e/68747470733a2f2f706f7365722e707567782e6f72672f7761706d6f7267616e2f6d7033696e666f2f762f756e737461626c65)](https://packagist.org/packages/wapmorgan/mp3info)[![License](https://camo.githubusercontent.com/154c4bc7882c360db4f5bdad0bb1b568c554ecdae475c21ceb79836755a14037/68747470733a2f2f706f7365722e707567782e6f72672f7761706d6f7267616e2f6d7033696e666f2f6c6963656e7365)](https://packagist.org/packages/wapmorgan/mp3info)

This class extracts information from mpeg/mp3 audio:

- Audio information:
    - Duration
    - Bit Rate
    - Sample Rate
    - Channels mode
    - Codec and Layer version
    - Frames count
- Audio image (cover)
- Audio tags:

tagid3v1id3v2songsongTIT2artistartistTPE1albumalbumTALByearyearTYERcommentcommentCOMMtracktrackTRCKgenregenreTCONContent
=======

[](#content)

1. [Usage](#usage)
2. [Performance](#performance)
3. [Console scanner](#console-scanner)
4. [API](#api)
    - Audio information
    - Class methods
    - Settings
5. [Technical information](#technical-information)

Usage
-----

[](#usage)

After creating an instance of `Mp3Info` with passing filename as the first argument to the constructor, you can retrieve data from object properties (listed below).

```
use wapmorgan\Mp3Info\Mp3Info;
// To get basic audio information
$audio = new Mp3Info('./audio.mp3');

// If you need parse tags, you should set 2nd argument this way:
$audio = new Mp3Info('./audio.mp3', true);
```

And after that access object properties to get audio information:

```
echo 'Audio duration: '.floor($audio->duration / 60).' min '.floor($audio->duration % 60).' sec'.PHP_EOL;
echo 'Audio bitrate: '.($audio->bitRate / 1000).' kb/s'.PHP_EOL;
// and so on ...
```

To access id3v1 tags use `$tags1` property. To access id3v2 tags use `$tags2` property. Also, you can use combined list of tags `$tags`, where id3v2 and id3v1 tags united with id3v1 keys.

```
// simple id3v1 tags
echo 'Song '.$audio->tags1['song'].' from '.$audio->tags1['artist'].PHP_EOL;
// specific id3v2 tags
echo 'Song '.$audio->tags2['TIT2'].' from '.$audio->tags2['TPE1'].PHP_EOL;

// combined tags (simplies way to get as more information as possible)
echo 'Song '.$audio->tags['song'].' from '.$audio->tags['artist'].PHP_EOL;
```

Performance
-----------

[](#performance)

- Typically it parses one mp3-file with size around 6-7 mb in less than 0.001 sec.
- List of 112 files with constant &amp; 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.
- 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.

Console scanner
---------------

[](#console-scanner)

To test Mp3Info you can use built-in script that scans dirs and analyzes all mp3-files inside them. To launch script against current folder:

```
php bin/scan ./
```

API
---

[](#api)

### Audio information

[](#audio-information)

PropertyDescriptionValues`$codecVersion`MPEG codec version1 or 2`$layerVersion`Audio layer version1 or 2 or 3`$audioSize`Audio size in bytes. Note that this value is NOT equals file size.*int*`$duration`Audio duration in seconds.microsecondslike 3603.0171428571 (means 1 hour and 3 sec)`$bitRate`Audio bit rate in bpslike 128000 (means 128kb/s)`$sampleRate`Audio sample rate in Hzlike 44100 (means 44.1KHz)`$isVbr`Contains `true` if audio has variable bit rate*boolean*`$hasCover`Contains `true` if audio has a bundled image*boolean*`$channel`Channel mode`'stereo'` or `'dual_mono'` or `'joint_stereo'` or `'mono'``$tags1`Audio tags ver. 1 (aka id3v1).\["song" =&gt; "Song name", "year" =&gt; 2009\]`$tags2`Audio tags ver. 2 (aka id3v2), only text ones.\["TIT2" =&gt; "Long song name", ...\]`$tags`Combined audio tags (from id3v1 &amp; id3v2). Keys as in tags1.\["song" =&gt; "Long song name", "year" =&gt; 2009, ...\]`$coverProperties`Information about a bundled with audio image.\["mime\_type" =&gt; "image/jpeg", "picture\_type" =&gt; 1, ...\]`$_parsingTime`Contains time spent to read&amp;extract audio information in *sec.msec*### Class methods

[](#class-methods)

- `$audio = new Mp3Info($filename, $parseTags = false)`Creates new instance of object and initiate parsing. If you need to parse audio tags (id3v1 and id3v2), pass `true` as second argument is.
- `$audio->getCover()`Returns raw content of bundled with audio image.
- `Mp3Info::isValidAudio($filename)`Static method that checks if file `$filename` looks like a mp3-file. Returns `true` if file looks like a mp3, otherwise false.

### Settings

[](#settings)

You can adjust some variables to reconfigure before instantiating of object:

- `Mp3Info::$headerSeekLimit` - count of bytes to search for the first mpeg header in audio. Default: `2048` (bytes).
- `Mp3Info::$framesCountRead` - count of mpeg frames to read before compute audio duration. Default: `2` (frames).

Technical information
---------------------

[](#technical-information)

Supporting features:

- id3v1
- id3v2.3.0, id3v2.4.0
- CBR, Variable Bit Rate (VBR)

Used sources:

- [mpeg header description](http://mpgedit.org/mpgedit/mpeg_format/mpeghdr.htm)
- [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)
- [Descripion of VBR header "Xing"](https://multimedia.cx/mp3extensions.txt)
- [Xing, Info and Lame tags specifications](http://gabriel.mp3-tech.org/mp3infotag.html)

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance45

Moderate activity, may be stable

Popularity56

Moderate usage in the ecosystem

Community31

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~273 days

Recently: every ~255 days

Total

12

Last Release

459d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6000618?v=4)[Sergey](/maintainers/wapmorgan)[@wapmorgan](https://github.com/wapmorgan)

---

Top Contributors

[![wapmorgan](https://avatars.githubusercontent.com/u/6000618?v=4)](https://github.com/wapmorgan "wapmorgan (48 commits)")[![joshtrichards](https://avatars.githubusercontent.com/u/1731941?v=4)](https://github.com/joshtrichards "joshtrichards (3 commits)")[![kesselb](https://avatars.githubusercontent.com/u/3902676?v=4)](https://github.com/kesselb "kesselb (1 commits)")[![paurakhsharma](https://avatars.githubusercontent.com/u/20378877?v=4)](https://github.com/paurakhsharma "paurakhsharma (1 commits)")[![shannah](https://avatars.githubusercontent.com/u/2677562?v=4)](https://github.com/shannah "shannah (1 commits)")

---

Tags

id3v1id3v2mediamp3mp3tagmpegaudioid3mp3id3v1id3v2mpeg

### Embed Badge

![Health badge](/badges/wapmorgan-mp3info/health.svg)

```
[![Health](https://phpackages.com/badges/wapmorgan-mp3info/health.svg)](https://phpackages.com/packages/wapmorgan-mp3info)
```

###  Alternatives

[php-ffmpeg/php-ffmpeg

FFMpeg PHP, an Object Oriented library to communicate with AVconv / ffmpeg

5.0k24.0M194](/packages/php-ffmpeg-php-ffmpeg)[kiwilan/php-audio

PHP package to parse and update audio files metadata, with `JamesHeinrich/getID3`.

3115.0k1](/packages/kiwilan-php-audio)[danog/madelineproto

Async PHP client API for the telegram MTProto protocol.

3.5k902.0k23](/packages/danog-madelineproto)[duncan3dc/meta-audio

A library to read and write metadata tags to audio files

353.5k](/packages/duncan3dc-meta-audio)[buggedcom/phpvideotoolkit

PHPVideoToolkit is a set of classes aimed to provide a modular, object oriented and accessible interface for interacting with videos and audio through the FFmpeg program.

26385.2k1](/packages/buggedcom-phpvideotoolkit)[codescale/ffmpeg-php

PHP wrapper for FFmpeg application

496275.8k1](/packages/codescale-ffmpeg-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
