{"id":16414594,"url":"https://github.com/wapmorgan/mediafile","last_synced_at":"2025-04-05T08:08:31.942Z","repository":{"id":53061307,"uuid":"80989395","full_name":"wapmorgan/MediaFile","owner":"wapmorgan","description":"A unified reader of metadata from audio \u0026 video files.","archived":false,"fork":false,"pushed_at":"2023-01-17T00:20:06.000Z","size":91,"stargazers_count":157,"open_issues_count":7,"forks_count":17,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-10-12T06:54:30.173Z","etag":null,"topics":["aac","amr","audio","avi","flac","mediafiles","mp3","mp4","ogg","video","wav","wma"],"latest_commit_sha":null,"homepage":"https://wapmorgan.github.io/MediaFile/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wapmorgan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-05T11:48:56.000Z","updated_at":"2024-10-08T18:59:08.000Z","dependencies_parsed_at":"2023-02-10T07:01:31.761Z","dependency_job_id":null,"html_url":"https://github.com/wapmorgan/MediaFile","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wapmorgan%2FMediaFile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wapmorgan%2FMediaFile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wapmorgan%2FMediaFile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wapmorgan%2FMediaFile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wapmorgan","download_url":"https://codeload.github.com/wapmorgan/MediaFile/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247305935,"owners_count":20917208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aac","amr","audio","avi","flac","mediafiles","mp3","mp4","ogg","video","wav","wma"],"created_at":"2024-10-11T06:54:31.353Z","updated_at":"2025-04-05T08:08:31.903Z","avatar_url":"https://github.com/wapmorgan.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MediaFile\n\nAllows you easily get meta information about any media file with unified interface.\nThe library has no requirements of external libs or system unitilies.\n\n[![Latest Stable Version](https://poser.pugx.org/wapmorgan/media-file/v/stable)](https://packagist.org/packages/wapmorgan/media-file)\n[![License](https://poser.pugx.org/wapmorgan/media-file/license)](https://packagist.org/packages/wapmorgan/media-file)\n[![Latest Unstable Version](https://poser.pugx.org/wapmorgan/media-file/v/unstable)](https://packagist.org/packages/wapmorgan/media-file)\n[![Tests](https://travis-ci.org/wapmorgan/MediaFile.svg?branch=master)](https://travis-ci.org/wapmorgan/MediaFile)\n\n## Supported formats\n\n| Audio | Video |\n|-------|-------|\n| aac, amr, flac, mp3, ogg, wav, wma | avi, mkv, mp4, wmv |\n| - length | - length |\n| - bitRate | - width |\n| - sampleRate | - height |\n| - channels | - frameRate |\n\n**Table of contents:**\n1. Usage\n2. API\n3. Why not using getID3?\n4. Technical details\n\n## Usage\n\n```php\nuse wapmorgan\\MediaFile\\MediaFile;\n\ntry {\n  $media = MediaFile::open('123.mp3');\n  // for audio\n  if ($media-\u003eisAudio()) {\n    $audio = $media-\u003egetAudio();\n    echo 'Duration: '.$audio-\u003egetLength().PHP_EOL;\n    echo 'Bit rate: '.$audio-\u003egetBitRate().PHP_EOL;\n    echo 'Sample rate: '.$audio-\u003egetSampleRate().PHP_EOL;\n    echo 'Channels: '.$audio-\u003egetChannels().PHP_EOL;\n  }\n  // for video\n  else {\n    $video = $media-\u003egetVideo();\n    // calls to VideoAdapter interface\n    echo 'Duration: '.$video-\u003egetLength().PHP_EOL;\n    echo 'Dimensions: '.$video-\u003egetWidth().'x'.$video-\u003egetHeight().PHP_EOL;\n    echo 'Framerate: '.$video-\u003egetFramerate().PHP_EOL;\n  }\n} catch (wapmorgan\\MediaFile\\Exceptions\\FileAccessException $e) {\n  // FileAccessException throws when file is not a detected media\n} catch (wapmorgan\\MediaFile\\Exceptions\\ParsingException $e) {\n   echo 'File is propably corrupted: '.$e-\u003egetMessage().PHP_EOL;\n}\n```\n\n## API\n### MediaFile\n\n`wapmorgan\\wapmorgan\\MediaFile`\n\n| Method                                   | Description                                                                       | Notes                                                                                                   |\n|------------------------------------------|-----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|\n| `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.                                     |\n| `isAudio(): boolean`                     | Returns true if media is just audio.                                              |                                                                                                         |\n| `isVideo(): boolean`                     | Returns true if media is a video with audio.                                      |                                                                                                         |\n| `isContainer(): boolean`                 | Returns true if media is also a container (can store multiple audios and videos). |                                                                                                         |\n| `getFormat(): string`                    | Returns media file format.                                                        |                                                                                                         |\n| `getAudio(): AudioAdapter`               | Returns an `AudioAdapter` interface for audio.                                    |                                                                                                         |\n| `getVideo(): VideoAdapter`               | Returns an `VideoAdapter` interface for video.                                    |                                                                                                         |\n\n### AudioAdapter\n\n`wapmorgan\\MediaFile\\AudioAdapter`\n\n| Method                         | Description                                                       |\n|--------------------------------|-------------------------------------------------------------------|\n| `getLength(): float`           | Returns audio length in seconds and microseconds as _float_.      |\n| `getBitRate(): int`            | Returns audio bit rate as _int_.                                  |\n| `getSampleRate(): int`         | Returns audio sampling rate as _int_.                             |\n| `getChannels(): int`           | Returns number of channels used in audio as _int_.                |\n| `isVariableBitRate(): boolean` | Returns whether format support VBR and file has VBR as _boolean_. |\n| `isLossless(): boolean`        | Returns whether format has compression lossless as _boolean_.     |\n\n### VideoAdapter\n\n`wapmorgan\\MediaFile\\VideoAdapter`\n\n| Method                | Description                                                  |\n|-----------------------|--------------------------------------------------------------|\n| `getLength(): int`    | Returns video length in seconds and microseconds as _float_. |\n| `getWidth(): int`     | Returns width of video as _int_.                             |\n| `getHeight(): int`    | Returns height of video as _int_.                            |\n| `getFramerate(): int` | Returns video frame rate of video as _int_.                  |\n\n### ContainerAdapter\n\n`wapmorgan\\MediaFile\\ContainerAdapter`\n\n| Method                     | Description                                      |\n|----------------------------|--------------------------------------------------|\n| `countStreams(): int`      | Returns number of streams in container as _int_. |\n| `countVideoStreams(): int` | Returns number of video streams as _int_.        |\n| `countAudioStreams(): int` | Returns number of audio streams as _int_.        |\n| `getStreams(): array`      | Returns streams information as _array_.          |\n\n## Why not using getID3?\n\ngetID3 library is very popular and has a lot of features, but it's old and too slow.\n\nFollowing table shows comparation of analyzing speed of fixtures, distributed with first release of MediaFile:\n\n| File       | getID3 | MediaFile | Speed gain |\n|------------|--------|-----------|------------|\n| video.avi  | 0.215  | 0.126     | 1.71x      |\n| video.mp4  | 3.055  | 0.429     | 7.12x      |\n| video.wmv  | 0.354  | 0.372     | 0.95x      |\n| audio.aac  | 0.560  | 0.262     | 2.13x      |\n| audio.amr  | 8.241  | 12.248    | 0.67x      |\n| audio.flac | 1.880  | 0.071     | 26.41x     |\n| audio.m4a  | 13.372 | 0.169     | 79.14x     |\n| audio.mp3  | 10.931 | 0.077     | 141.54x    |\n| audio.ogg  | 0.170  | 0.096     | 1.78x      |\n| audio.wav  | 0.114  | 0.070     | 1.64x      |\n| audio.wma  | 0.195  | 0.158     | 1.23x      |\n\n## Technical information\n\n| Format | Full format name                                             | Specifications                                                                                                                                                                                                     | Notes                                 |\n|--------|--------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------|\n| aac    | MPEG 4 Part 12 container with audio only                     | http://l.web.umkc.edu/lizhu/teaching/2016sp.video-communication/ref/mp4.pdf                                                                                                                                        | Does not provide support of MPEG2-AAC |\n| amr    | AMR-NB                                                       | http://hackipedia.org/File%20formats/Containers/AMR,%20Adaptive%20MultiRate/AMR%20format.pdf                                                                                                                       | Does not provide support of AMR-WB    |\n| avi    | -                                                            | http://www.alexander-noe.com/video/documentation/avi.pdf                                                                                                                                                           |                                       |\n| flac   | -                                                            | -                                                                                                                                                                                                                  | Support based on third-party library  |\n| mkv    | Matroska container                                           | https://www.matroska.org/technical/specs/index.html                                                                                                                                                                |                                       |\n| mp3    | MPEG 1/2 Layer 1/2/3                                         | https://github.com/wapmorgan/mp3info#technical-information                                                                                                                                                         |                                       |\n| mp4    | MPEG 4 Part 12/14 container with few audio and video streams | Part 12 specification: http://l.web.umkc.edu/lizhu/teaching/2016sp.video-communication/ref/mp4.pdf Part 14 extension: https://www.cmlab.csie.ntu.edu.tw/~cathyp/eBooks/14496_MPEG4/ISO_IEC_14496-14_2003-11-15.pdf |                                       |\n| ogg    | Ogg container with Vorbis audio                              | https://xiph.org/vorbis/doc/Vorbis_I_spec.html                                                                                                                                                                     |                                       |\n| wav    | -                                                            | -                                                                                                                                                                                                                  | Support based on third-party library  |\n| wma    | ASF container with only one audio stream                     | http://go.microsoft.com/fwlink/p/?linkid=31334                                                                                                                                                                     |                                       |\n| wmv    | ASF container with few audio and video streams               | http://go.microsoft.com/fwlink/p/?linkid=31334                                                                                                                                                                     |                                       |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwapmorgan%2Fmediafile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwapmorgan%2Fmediafile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwapmorgan%2Fmediafile/lists"}