PHPackages                             codememory/media-file-fork - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. codememory/media-file-fork

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

codememory/media-file-fork
==========================

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

v1.0(3y ago)010MITPHPPHP &gt;=5.5

Since Feb 6Pushed 3y agoCompare

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

READMEChangelog (1)Dependencies (7)Versions (8)Used By (0)

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

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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 ~326 days

Recently: every ~484 days

Total

7

Last Release

1428d ago

Major Versions

0.1.4 → v1.02022-06-17

### Community

Maintainers

![](https://www.gravatar.com/avatar/4f0d8298c7a2a11b533d914c47247df660c778a99fb682320df53be7b42d941a?d=identicon)[codememory1](/maintainers/codememory1)

---

Top Contributors

[![wapmorgan](https://avatars.githubusercontent.com/u/6000618?v=4)](https://github.com/wapmorgan "wapmorgan (79 commits)")[![austinkregel](https://avatars.githubusercontent.com/u/5355937?v=4)](https://github.com/austinkregel "austinkregel (1 commits)")

---

Tags

mp3mp4wavoggflacaacamraviwmawmv

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[wapmorgan/media-file

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

158232.7k3](/packages/wapmorgan-media-file)[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k472.8M135](/packages/mtdowling-jmespathphp)[opis/closure

A library that can be used to serialize closures (anonymous functions) and arbitrary data.

2.6k230.0M284](/packages/opis-closure)[kiwilan/php-audio

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

3012.6k1](/packages/kiwilan-php-audio)[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)

PHPackages © 2026

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