PHPackages                             holine/mp3 - 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. holine/mp3

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

holine/mp3
==========

PHP-MP3 is a simple library for reading and manipulating MPEG audio (MP3)

0.0.1(4y ago)08LGPL-3.0PHPPHP &gt;=5.4

Since Nov 29Pushed 4y agoCompare

[ Source](https://github.com/holine/MP3)[ Packagist](https://packagist.org/packages/holine/mp3)[ Docs](https://github.com/holine/MP3)[ RSS](/packages/holine-mp3/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

PHP-MP3
=======

[](#php-mp3)

[![](https://camo.githubusercontent.com/d29a9c1d2b316ba24ffd02a6a6060b2fd99ade91bf0a968ef30700e8826478b3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f66616c61686174692f5048502d4d50332e7376673f7374796c653d666c61742d737175617265)](https://github.com/falahati/PHP-MP3/blob/master/LICENSE)[![](https://camo.githubusercontent.com/00de3502ce241cbbcc020f62f07144a89d96c2d7f2b663f53c93c654b6aef556/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6d6d69742d61637469766974792f792f66616c61686174692f5048502d4d50332e7376673f7374796c653d666c61742d737175617265)](https://github.com/falahati/PHP-MP3/commits/master)[![](https://camo.githubusercontent.com/5edcebe7860acdb154af1c76d0a10342b52ccc90b29a3a9c5b4db893a809eceb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f66616c61686174692f5048502d4d50332e7376673f7374796c653d666c61742d737175617265)](https://github.com/falahati/PHP-MP3/issues)

PHP-MP3 is a simple library for reading and manipulating MPEG audio (MP3).

This library is based on a similar project with the same name written by [thegallagher](https://github.com/thegallagher/PHP-MP3) which it-self was based on an script from [regin](https://web.archive.org/web/20120211192505/http://www.sourcerally.net/Scripts/20-PHP-MP3-Class).

This is not an encoder or decoder and therefore can't change the MP3 properties like bitrate, sample size, and sample rate. It's a MPEG Audio **parser** and therefore it should only be used to modify/create/read valid MP3 containers.

How to get
----------

[](#how-to-get)

[![](https://camo.githubusercontent.com/5d0909fb9528f5cdb5d26edf41d24cffdddce739133e4519d74d9795960377ed/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f66616c61686174692f7068702d6d70332e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/falahati/php-mp3)[![](https://camo.githubusercontent.com/a89f5c92a49a0070455821c01f9464391c5f8a33bfe73ea879939c10b7eb69ae/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f66616c61686174692f7068702d6d70332e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/falahati/php-mp3)

You can install and use this library with composer:

```
composer require falahati/php-mp3:dev-master

```

Features
--------

[](#features)

- Correctly identifies MPEG Audio Version 1, 2 and 2.5
- Correctly identifies MPEG Audio Profile 1, 2 and 3
- Correctly extracts bitrate and sample rate information
- Correctly calculates MPEG Audio stream duration
- Frame address recovery allows the code to correctly parse corrupt data
- Trim (Cut) a MPEG Audio data and merge multiple MPEG audio streams
- Ability to strip MPEG Audio data from starting and ending ID3 (or similar) metadata information

Help me fund my own Death Star
------------------------------

[](#help-me-fund-my-own-death-star)

[![](https://camo.githubusercontent.com/c0333ad73caef9015077444187e0779adb884421ad092bc07151a403c1998bf7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f63727970746f2d436f696e5061796d656e74732d3861303061332e7376673f7374796c653d666c61742d737175617265)](https://www.coinpayments.net/index.php?cmd=_donate&reset=1&merchant=820707aded07845511b841f9c4c335cd&item_name=Donate&currency=USD&amountf=20.00000000&allow_amount=1&want_shipping=0&allow_extra=1)[![](https://camo.githubusercontent.com/85a1d6d90499bb16a576cf8fccb5132ee657780740b232420761c8602634fedf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7368657461622d5a6172696e50616c2d3861303061332e7376673f7374796c653d666c61742d737175617265)](https://zarinp.al/@falahati)[![](https://camo.githubusercontent.com/dbf2e5dc8f2c00e7ca9b2aab7f477230733601d184864da5d6aa99e595905652/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7573642d50617970616c2d3861303061332e7376673f7374796c653d666c61742d737175617265)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ramin.graphix@gmail.com&lc=US&item_name=Donate&no_note=0&cn=&curency_code=USD&bn=PP-DonationsBF:btn_donateCC_LG.gif:NonHosted)

**--OR--**

You can always donate your time by contributing to the project or by introducing it to others.

Samples
-------

[](#samples)

Strip ID3 tags from a MP3 file:

```
\falahati\PHPMP3\MpegAudio::fromFile("old.mp3")->stripTags()->saveFile("new.mp3");
```

Cut a MP3 file to extract a 30sec preview starting at the 10th second:

```
\falahati\PHPMP3\MpegAudio::fromFile("old.mp3")->trim(10, 30)->saveFile("new.mp3");
```

Append memory stored MP3 data to the end of a MP3 file:

```
\falahati\PHPMP3\MpegAudio::fromFile("old.mp3")->append(\falahati\PHPMP3\MpegAudio::fromData(base64_decode("/**BASE64-DATA**/")))->saveFile("new.mp3");
```

Extracting MP3 file total duration:

```
echo \falahati\PHPMP3\MpegAudio::fromFile("old.mp3")->getTotalDuration();
```

To Do List
----------

[](#to-do-list)

- Add Unit Tests
- Ability to load and manipulate data directly from, and to a `resource`
- Ability to add simple ID3 metadata information to the MPEG Audio before saving

License
-------

[](#license)

Copyright (C) 2017-2020 Soroush Falahati

This project is licensed under the GNU Lesser General Public License ("LGPL") and therefore can be used in closed source or commercial projects. However, any commit or change to the main code must be public and there should be a read me file along with the DLL clarifying the license and its terms as part of your project as well as a hyperlink to this repository. [Read more about LGPL](LICENSE).

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor2

2 contributors hold 50%+ of commits

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

Unknown

Total

1

Last Release

1631d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1ef1c76aac908849b948d03d0efceb51d88bd81bc958a81e5766d9f8c1a91d5c?d=identicon)[holine](/maintainers/holine)

---

Top Contributors

[![thegallagher](https://avatars.githubusercontent.com/u/486626?v=4)](https://github.com/thegallagher "thegallagher (14 commits)")[![falahati](https://avatars.githubusercontent.com/u/2479372?v=4)](https://github.com/falahati "falahati (10 commits)")[![holine](https://avatars.githubusercontent.com/u/2540932?v=4)](https://github.com/holine "holine (3 commits)")[![hostcomm-steve](https://avatars.githubusercontent.com/u/32366686?v=4)](https://github.com/hostcomm-steve "hostcomm-steve (2 commits)")[![BenseidSeid](https://avatars.githubusercontent.com/u/41877007?v=4)](https://github.com/BenseidSeid "BenseidSeid (1 commits)")

---

Tags

audiomp3edit

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/holine-mp3/health.svg)

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

###  Alternatives

[php-ffmpeg/php-ffmpeg

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

5.0k21.7M165](/packages/php-ffmpeg-php-ffmpeg)[danog/madelineproto

Async PHP client API for the telegram MTProto protocol.

3.4k855.0k18](/packages/danog-madelineproto)[wapmorgan/mp3info

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

1481.4M7](/packages/wapmorgan-mp3info)[falahati/php-mp3

PHP-MP3 is a simple library for reading and manipulating MPEG audio (MP3)

5069.3k1](/packages/falahati-php-mp3)[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.

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

PHP wrapper for FFmpeg application

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

PHPackages © 2026

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