wapmorgan / media-file
A unified reader of metadata from audio & video files
Installs: 180 860
Dependents: 3
Suggesters: 0
Security: 0
Stars: 157
Watchers: 8
Forks: 17
Open Issues: 7
Requires
- bluemoehre/flac-php: 1.0.2
- wapmorgan/binary-stream: ~0.4.0
- wapmorgan/file-type-detector: ^1.0.2
- wapmorgan/mp3info: ~0.0
Requires (Dev)
- phpunit/phpunit: ~4.8
Suggests
- boyhagemann/wave: Wav support
This package is auto-updated.
Last update: 2024-10-17 04:10:23 UTC
README
Allows you easily get meta information about any media file with unified interface. The library has no requirements of external libs or system unitilies.
Supported formats
Table of contents:
- Usage
- API
- Why not using getID3?
- Technical details
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
MediaFile
wapmorgan\wapmorgan\MediaFile
AudioAdapter
wapmorgan\MediaFile\AudioAdapter
VideoAdapter
wapmorgan\MediaFile\VideoAdapter
ContainerAdapter
wapmorgan\MediaFile\ContainerAdapter
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: