Download .zip |
Info | Example | View files (24) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2017-02-14 (15 days ago) | Not enough user ratings | Total: 49 This week: 49 | All time: 8,751 This week: 14 |
Version | License | PHP version | Categories | |||
mediafile 0.1.0 | MIT/X Consortium ... | 5.3.6 | Utilities and Tools, Files and Folders |
Description | Author | |||
This package can extract metadata from audio and video files. Innovation Award
|
Allows you easily get meta information about any media file with unified interface.
It can retrieve following information:
Table of contents:
try {
$media = wapmorgan\MediaFile\MediaFile::open('123.mp3');
// for audio
if ($media->isAudio()) {
// calls to AudioAdapter interface
echo 'Duration: '.$media->getAudio()->getLength().PHP_EOL;
echo 'Bit rate: '.$media->getAudio()->getBitRate().PHP_EOL;
echo 'Sample rate: '.$media->getAudio()->getSampleRate().PHP_EOL;
echo 'Channels: '.$media->getAudio()->getChannels().PHP_EOL;
}
// for video
else {
// calls to VideoAdapter interface
echo 'Duration: '.$media->getVideo()->getLength().PHP_EOL;
echo 'Dimensions: '.$media->getVideo()->getWidth().'x'.$media->getVideo()->getHeight().PHP_EOL;
echo 'Framerate: '.$media->getVideo()->getFramerate().PHP_EOL;
}
} catch (wapmorgan\MediaFile\Exception $e) {
// not a media or file is corrupted
}
Other formats support coming soon.
wapmorgan\wapmorgan\MediaFile
| Method | Description | Notes |
|------------------------------------------|-----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|
| static open($filename)
| Detects file type and format and calls constructor with these parameters. | Throws an \Exception
if file is not a media or is not accessible. |
| __construct($filename, $type, $format)
| Opens file and reads metadata. | Available $type
values: MediaFile::AUDIO
, MediaFile::VIDEO
. Available $format
values see below. |
| isAudio()
| Returns true if media is just audio. | |
| isVideo()
| Returns true if media is a video with audio. | |
| isContainer()
| Returns true if media is also a container (can store multiple audios and videos). | |
| getType()
| Returns media file type. | |
| getFormat()
| Returns media file format. | |
| getAudio()
| Returns an AudioAdapter interface for audio. | |
| getVideo()
| Returns an VideoAdapter interface for video. | |
Available formats:
For MediaFile::AUDIO
:
| MediaFile::WAV
| MediaFile::FLAC
| MediaFile::AAC
| MediaFile::OGG
|
|----------------------|----------------------|----------------------|------------------|
| MediaFile::MP3
| MediaFile::AMR
| MediaFile::WMA
| |
For MediaFile::VIDEO
:
| MediaFile::AVI
| MediaFile::WMV
| MediaFile::MP4
|
|------------------|------------------|------------------|
wapmorgan\MediaFile\AudioAdapter
| Method | Description |
|-----------------------|-------------------------------------------------------------------|
| getLength()
| Returns audio length in seconds and microseconds as _float_. |
| getBitRate()
| Returns audio bit rate as _int_. |
| getSampleRate()
| Returns audio sampling rate as _int_. |
| getChannels()
| Returns number of channels used in audio as _int_. |
| isVariableBitRate()
| Returns whether format support VBR and file has VBR as _boolean_. |
| isLossless()
| Returns whether format has compression lossless as _boolean_. |
wapmorgan\MediaFile\VideoAdapter
| Method | Description |
|------------------|--------------------------------------------------------------|
| getLength()
| Returns video length in seconds and microseconds as _float_. |
| getWidth()
| Returns width of video as _int_. |
| getHeight()
| Returns height of video as _int_. |
| getFramerate()
| Returns video frame rate of video as _int_. |
wapmorgan\MediaFile\ContainerAdapter
| Method | Description |
|-----------------------|--------------------------------------------------|
| countStreams()
| Returns number of streams in container as _int_. |
| countVideoStreams()
| Returns number of video streams as _int_. |
| countAudioStreams()
| Returns number of audio streams as _int_. |
| getStreams()
| Returns streams information as _array_. |
| Format | Full format name | Specifications | Notes | |--------|--------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------| | 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 | | amr | AMR-NB | http://hackipedia.org/File%20formats/Containers/AMR,%20Adaptive%20MultiRate/AMR%20format.pdf | Does not provide support of AMR-WB | | avi | - | http://www.alexander-noe.com/video/documentation/avi.pdf | | | flac | - | - | Support based on third-party library | | mp3 | MPEG 1/2 Layer 1/2/3 | https://github.com/wapmorgan/mp3info#technical-information | | | 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 | | | ogg | Ogg container with Vorbis audio | https://xiph.org/vorbis/doc/Vorbis_I_spec.html | | | wav | - | - | Support based on third-party library | | wma | ASF container with only one audio stream | http://go.microsoft.com/fwlink/p/?linkid=31334 | | | wmv | ASF container with few audio and video streams | http://go.microsoft.com/fwlink/p/?linkid=31334 | |
Files |
File | Role | Description | ||
---|---|---|---|---|
bin (1 file) | ||||
src (19 files) | ||||
composer.json | Data | Auxiliary data | ||
LICENSE | Lic. | License text | ||
README.md | Doc. | Documentation | ||
_config.yml | Data | Auxiliary data |
Files | / | src |
File | Role | Description |
---|---|---|
AacAdapter.php | Class | Class source |
AmrAdapter.php | Class | Class source |
AsfAdapter.php | Class | Class source |
AudioAdapter.php | Class | Class source |
AviAdapter.php | Class | Class source |
ContainerAdapter.php | Class | Class source |
Exception.php | Class | Class source |
FileAccessException.php | Class | Class source |
FlacAdapter.php | Class | Class source |
MediaFile.php | Class | Class source |
Mp3Adapter.php | Class | Class source |
Mp4Adapter.php | Class | Class source |
Mpeg4Part12Adapter.php | Class | Class source |
OggAdapter.php | Class | Class source |
ParsingException.php | Class | Class source |
VideoAdapter.php | Class | Class source |
WavAdapter.php | Class | Class source |
WmaAdapter.php | Class | Class source |
WmvAdapter.php | Class | Class source |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.