PHPackages                             wapmorgan/media-file - 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/media-file

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

wapmorgan/media-file
====================

A unified reader of metadata from audio &amp; video files

0.1.4(8y ago)158232.7k—7.7%18[6 issues](https://github.com/wapmorgan/MediaFile/issues)[1 PRs](https://github.com/wapmorgan/MediaFile/pulls)3MITPHP

Since Feb 6Pushed 3y ago8 watchersCompare

[ Source](https://github.com/wapmorgan/MediaFile)[ Packagist](https://packagist.org/packages/wapmorgan/media-file)[ RSS](/packages/wapmorgan-media-file/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (5)Versions (8)Used By (3)

MediaFile
=========

[](#mediafile)

Allows you easily get meta information about any media file with unified interface. The library has no requirements of external libs or system unitilies.

[![Latest Stable Version](https://camo.githubusercontent.com/09d12e7f39245fe362bad3ba86daead1f6965639e8dacd33a97b52292fe2a7db/68747470733a2f2f706f7365722e707567782e6f72672f7761706d6f7267616e2f6d656469612d66696c652f762f737461626c65)](https://packagist.org/packages/wapmorgan/media-file)[![License](https://camo.githubusercontent.com/c7f656e761c70e4064f867e4d81da059412f4ed56e0a7464ccbd52c34466e611/68747470733a2f2f706f7365722e707567782e6f72672f7761706d6f7267616e2f6d656469612d66696c652f6c6963656e7365)](https://packagist.org/packages/wapmorgan/media-file)[![Latest Unstable Version](https://camo.githubusercontent.com/0a1b74daac554bdae544deb6236c550f60674251f205faffe5ed077bff2886e9/68747470733a2f2f706f7365722e707567782e6f72672f7761706d6f7267616e2f6d656469612d66696c652f762f756e737461626c65)](https://packagist.org/packages/wapmorgan/media-file)[![Tests](https://camo.githubusercontent.com/a9f7240b8e567eabc0dacbb23441c99f800762c0c1825e4d0728c9459e5edb1a/68747470733a2f2f7472617669732d63692e6f72672f7761706d6f7267616e2f4d6564696146696c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/wapmorgan/MediaFile)

Supported formats
-----------------

[](#supported-formats)

AudioVideoaac, amr, flac, mp3, ogg, wav, wmaavi, mkv, mp4, wmv- length- length- bitRate- width- sampleRate- height- channels- frameRate**Table of contents:**

1. Usage
2. API
3. Why not using getID3?
4. Technical details

Usage
-----

[](#usage)

```
use wapmorgan\MediaFile\MediaFile;

try {
  $media = MediaFile::open('123.mp3');
  // for audio
  if ($media->isAudio()) {
    $audio = $media->getAudio();
    echo 'Duration: '.$audio->getLength().PHP_EOL;
    echo 'Bit rate: '.$audio->getBitRate().PHP_EOL;
    echo 'Sample rate: '.$audio->getSampleRate().PHP_EOL;
    echo 'Channels: '.$audio->getChannels().PHP_EOL;
  }
  // for video
  else {
    $video = $media->getVideo();
    // calls to VideoAdapter interface
    echo 'Duration: '.$video->getLength().PHP_EOL;
    echo 'Dimensions: '.$video->getWidth().'x'.$video->getHeight().PHP_EOL;
    echo 'Framerate: '.$video->getFramerate().PHP_EOL;
  }
} catch (wapmorgan\MediaFile\Exceptions\FileAccessException $e) {
  // FileAccessException throws when file is not a detected media
} catch (wapmorgan\MediaFile\Exceptions\ParsingException $e) {
   echo 'File is propably corrupted: '.$e->getMessage().PHP_EOL;
}
```

API
---

[](#api)

### MediaFile

[](#mediafile-1)

`wapmorgan\wapmorgan\MediaFile`

MethodDescriptionNotes`static open($filename): MediaFile`Detects file type and format and calls constructor with these parameters.Throws an `\Exception` if file is not a media or is not accessible.`isAudio(): boolean`Returns true if media is just audio.`isVideo(): boolean`Returns true if media is a video with audio.`isContainer(): boolean`Returns true if media is also a container (can store multiple audios and videos).`getFormat(): string`Returns media file format.`getAudio(): AudioAdapter`Returns an `AudioAdapter` interface for audio.`getVideo(): VideoAdapter`Returns an `VideoAdapter` interface for video.### AudioAdapter

[](#audioadapter)

`wapmorgan\MediaFile\AudioAdapter`

MethodDescription`getLength(): float`Returns audio length in seconds and microseconds as *float*.`getBitRate(): int`Returns audio bit rate as *int*.`getSampleRate(): int`Returns audio sampling rate as *int*.`getChannels(): int`Returns number of channels used in audio as *int*.`isVariableBitRate(): boolean`Returns whether format support VBR and file has VBR as *boolean*.`isLossless(): boolean`Returns whether format has compression lossless as *boolean*.### VideoAdapter

[](#videoadapter)

`wapmorgan\MediaFile\VideoAdapter`

MethodDescription`getLength(): int`Returns video length in seconds and microseconds as *float*.`getWidth(): int`Returns width of video as *int*.`getHeight(): int`Returns height of video as *int*.`getFramerate(): int`Returns video frame rate of video as *int*.### ContainerAdapter

[](#containeradapter)

`wapmorgan\MediaFile\ContainerAdapter`

MethodDescription`countStreams(): int`Returns number of streams in container as *int*.`countVideoStreams(): int`Returns number of video streams as *int*.`countAudioStreams(): int`Returns number of audio streams as *int*.`getStreams(): array`Returns streams information as *array*.Why not using getID3?
---------------------

[](#why-not-using-getid3)

getID3 library is very popular and has a lot of features, but it's old and too slow.

Following table shows comparation of analyzing speed of fixtures, distributed with first release of MediaFile:

FilegetID3MediaFileSpeed gainvideo.avi0.2150.1261.71xvideo.mp43.0550.4297.12xvideo.wmv0.3540.3720.95xaudio.aac0.5600.2622.13xaudio.amr8.24112.2480.67xaudio.flac1.8800.07126.41xaudio.m4a13.3720.16979.14xaudio.mp310.9310.077141.54xaudio.ogg0.1700.0961.78xaudio.wav0.1140.0701.64xaudio.wma0.1950.1581.23xTechnical information
---------------------

[](#technical-information)

FormatFull format nameSpecificationsNotesaacMPEG 4 Part 12 container with audio onlyDoes not provide support of MPEG2-AACamrAMR-NBDoes not provide support of AMR-WBavi-flac--Support based on third-party librarymkvMatroska containermp3MPEG 1/2 Layer 1/2/3mp4MPEG 4 Part 12/14 container with few audio and video streamsPart 12 specification:  Part 14 extension: [https://www.cmlab.csie.ntu.edu.tw/~cathyp/eBooks/14496\_MPEG4/ISO\_IEC\_14496-14\_2003-11-15.pdf](https://www.cmlab.csie.ntu.edu.tw/~cathyp/eBooks/14496_MPEG4/ISO_IEC_14496-14_2003-11-15.pdf)oggOgg container with Vorbis audio[https://xiph.org/vorbis/doc/Vorbis\_I\_spec.html](https://xiph.org/vorbis/doc/Vorbis_I_spec.html)wav--Support based on third-party librarywmaASF container with only one audio streamwmvASF container with few audio and video streams

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity50

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.8% 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 ~79 days

Recently: every ~98 days

Total

6

Last Release

2992d 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 (81 commits)")[![austinkregel](https://avatars.githubusercontent.com/u/5355937?v=4)](https://github.com/austinkregel "austinkregel (1 commits)")

---

Tags

aacamraudioaviflacmediafilesmp3mp4oggvideowavwmamp3mp4wavoggflacaacamraviwmawmv

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[kiwilan/php-audio

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

3012.6k1](/packages/kiwilan-php-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.

26382.1k1](/packages/buggedcom-phpvideotoolkit)[wapmorgan/mp3info

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

1481.4M7](/packages/wapmorgan-mp3info)[meema/laravel-media-converter

Easily &amp; quickly integrate your application with AWS MediaConvert.

5790.6k](/packages/meema-laravel-media-converter)[falahati/php-mp3

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

5069.3k1](/packages/falahati-php-mp3)[acekyd/laravelmp3

A light weight Laravel package for simple operations with mp3 files

213.7k](/packages/acekyd-laravelmp3)

PHPackages © 2026

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