Giter Site home page Giter Site logo

php-mp3's Introduction

PHP-MP3

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 which it-self was based on an script from regin.

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

You can install and use this library with composer:

composer require falahati/php-mp3:dev-master

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

--OR--

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

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

  • 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

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.

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.