All Projects → wapmorgan → Mp3Info

wapmorgan / Mp3Info

Licence: LGPL-3.0 license
The fastest PHP library to extract mp3 meta information (duration, bitrate, samplerate and so on) and tags (id3v1, id3v2).

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to Mp3Info

mp3tag.js
MP3 tagging library written in pure JavaScript for Node.js and browsers
Stars: ✭ 39 (-65.79%)
Mutual labels:  mp3, mp3tag, id3v2, id3v1
audio-metadata
A library for reading and, in the future, writing audio metadata. https://audio-metadata.readthedocs.io/
Stars: ✭ 41 (-64.04%)
Mutual labels:  mp3, id3v2, id3v1
dart-tags
ID3 Tag parser written on the pure dart language.
Stars: ✭ 35 (-69.3%)
Mutual labels:  mp3, id3v2, id3v1
Mp3ID3Tagger
🎶🎵A macOS application to edit the ID3 tag of your mp3 files. Developed with RxSwift and RxCocoa. 🎸🎼
Stars: ✭ 17 (-85.09%)
Mutual labels:  mp3, id3v2, id3v1
meta-audio
A PHP library to read and write metadata tags to audio files (MP3, ID3, APE, etc)
Stars: ✭ 32 (-71.93%)
Mutual labels:  mp3, id3v2, id3v1
TonUINO
Alternative TonUINO Firmware
Stars: ✭ 112 (-1.75%)
Mutual labels:  mp3, media
laravel-getid3
A Laravel package to extract metadata from media files. mp3, aac, etc. It can be used with files stored on different disks such as local disk, S3 etc.
Stars: ✭ 50 (-56.14%)
Mutual labels:  id3v2, id3v1
loudgain
ReplayGain 2.0 loudness normalizer based on the EBU R128/ITU BS.1770 standard (-18 LUFS, FLAC, Ogg, MP2, MP3, MP4, M4A, AAC, ALAC, Opus, ASF, WMA, WAV, AIFF, WavPack, APE)
Stars: ✭ 127 (+11.4%)
Mutual labels:  mp3, id3v2
Flutter Assetsaudioplayer
Play simultaneously music/audio from assets/network/file directly from Flutter, compatible with android / ios / web / macos, displays notifications
Stars: ✭ 458 (+301.75%)
Mutual labels:  mp3, media
Sjmediacacheserver
A HTTP Media Caching Framework. It can cache FILE or HLS media. 音视频边播边缓存框架, 支持 HLS(m3u8) 和 FILE(mp4, mp3等).
Stars: ✭ 87 (-23.68%)
Mutual labels:  mp3, media
Symphonia
Pure Rust multimedia format demuxing, tag reading, and audio decoding library
Stars: ✭ 191 (+67.54%)
Mutual labels:  mp3, media
slibs
Single file libraries for C/C++
Stars: ✭ 80 (-29.82%)
Mutual labels:  mp3, mpeg
DownOnSpot
🎵 A Spotify music and playlist downloader written in Rust which also works with a free Spotify account
Stars: ✭ 309 (+171.05%)
Mutual labels:  mp3, media
MJMediaPicker
A Custom Class to select media from camera ,video or photo library by just adding a single file
Stars: ✭ 15 (-86.84%)
Mutual labels:  media
mpegts
A simple implementation of mpegts(including muxer and demuxer)
Stars: ✭ 21 (-81.58%)
Mutual labels:  mpeg
media-roller
A self hosted server to download videos from social media with an iOS shortcut for on-click saving to camera roll
Stars: ✭ 52 (-54.39%)
Mutual labels:  media
react-native-vlc-media-player
React native media player for video streaming and playing. Supports RTSP, RTMP and other protocols supported by VLC player
Stars: ✭ 221 (+93.86%)
Mutual labels:  media
retro-winamp-block
A Winamp-styled audio block for all your retro music player needs.
Stars: ✭ 14 (-87.72%)
Mutual labels:  mp3
genshin-audio-exporter
Export audio files from Genshin Impact game data into different audio formats.
Stars: ✭ 83 (-27.19%)
Mutual labels:  mp3
uos
United Open-libraries of Sound. United procedures for open-source audio libraries. For FPC/Lazarus/fpGUI/MSEgui.
Stars: ✭ 112 (-1.75%)
Mutual labels:  mp3

Mp3Info

The fastest PHP library to get mp3 tags&meta.

Latest Stable Version Total Downloads Latest Unstable Version License

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:
tag id3v1 id3v2
song song TIT2
artist artist TPE1
album album TALB
year year TYER
comment comment COMM
track track TRCK
genre genre TCON

Content

  1. Usage
  2. Performance
  3. Console scanner
  4. API
    • Audio information
    • Class methods
  5. Technical information

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

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

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

Audio information

Property Description Values
$codecVersion MPEG codec version 1 or 2
$layerVersion Audio layer version 1 or 2 or 3
$audioSize Audio size in bytes. Note that this value is NOT equals file size. int
$duration Audio duration in seconds.microseconds like 3603.0171428571 (means 1 hour and 3 sec)
$bitRate Audio bit rate in bps like 128000 (means 128kb/s)
$sampleRate Audio sample rate in Hz like 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" => "Song name", "year" => 2009]
$tags2 Audio tags ver. 2 (aka id3v2), only text ones. ["TIT2" => "Long song name", ...]
$tags Combined audio tags (from id3v1 & id3v2). Keys as in tags1. ["song" => "Long song name", "year" => 2009, ...]
$coverProperties Information about a bundled with audio image. ["mime_type" => "image/jpeg", "picture_type" => 1, ...]
$_parsingTime Contains time spent to read&extract audio information in sec.msec

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.

Technical information

Supporting features:

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

Used sources:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].