diff --git a/README.md b/README.md index d22a13b..df51845 100644 --- a/README.md +++ b/README.md @@ -8,30 +8,163 @@ PHP library to run `mediainfo` command You should install [mediainfo](http://manpages.ubuntu.com/manpages/gutsy/man1/mediainfo.1.html): On linux: + ```bash $ sudo apt-get install mediainfo ``` On Mac: + ```bash $ brew install mediainfo ``` To use this class install it through [Composer](https://getcomposer.org/), add: + ```bash $ composer require mhor/php-mediainfo ``` ## How to use + + +### Retrieve media information container ```php getInfo('music.mp3'); +$mediaInfoContainer = $mediaInfo->getInfo('music.mp3'); //... ``` +### Get general information from media information container + +```php +$general = $mediaInfoContainer->getGeneral(); +``` + +### Get videos information from media information container + +```php +$videos = $mediaInfoContainer->getVideos(); + +foreach($videos as $video) { + // ... do something +} +``` + +### Get audios information from media information container + +```php +$audios = $mediaInfoContainer->getAudios(); + +foreach($audios as $audio) { + // ... do something +} +``` + +### Get images information from media information container + +```php +$images = $mediaInfoContainer->getImages(); + +foreach($images as $image) { + // ... do something +} +``` + +### Access to information + +#### Get all information into an array + +```php +$informationArray = $general->get(); +``` + +#### Get one information by field name + +Field Name are in lower case separated by "_" + +```php +$oneInformation = $general->get('count_of_audio_streams'); +``` + +### Specials types + +#### Cover +For fields: + +- cover_data + +[Cover](src/Attribute/Cover) type will be applied + +#### Duration +For fields: + +- duration +- delay_relative_to_video +- video0_delay +- delay + +[Duration](src/Attribute/Duration) type will be applied + +#### Mode +For fields: + +- overall_bit_rate_mode +- overall_bit_rate +- bit_rate_mode +- compression_mode +- codec +- format +- kind_of_stream +- writing_library +- id +- format_settings_sbr +- channel_positions +- default +- forced +- delay_origin +- scan_type +- interlacement +- scan_type +- frame_rate_mode +- format_settings_cabac +- unique_id + +[Mode](src/Attribute/Mode) type will be applied + +#### Rate +For fields: + +- channel_s +- bit_rate +- sampling_rate +- bit_depth +- width +- nominal_bit_rate +- frame_rate +- display_aspect_ratio +- frame_rate +- format_settings_reframes +- height +- resolution +- original_display_aspect_ratio + +[Rate](src/Attribute/Rate) type will be applied + +#### Size +For fields: + +- file_size +- stream_size + +[Size](src/Attribute/Sire) type will be applied + +#### Others +- All date fields will be transformed into [`Datetime`](src/Attribute/Datetime) php object + ##LICENSE See `LICENSE` for more information diff --git a/src/MediaInfo.php b/src/MediaInfo.php index 2d4771f..c50215c 100644 --- a/src/MediaInfo.php +++ b/src/MediaInfo.php @@ -3,10 +3,15 @@ namespace Mhor\MediaInfo; use Mhor\MediaInfo\Builder\MediaInfoCommandBuilder; +use Mhor\MediaInfo\Container\MediaInfoContainer; use Mhor\MediaInfo\Parser\MediaInfoOutputParser; class MediaInfo { + /** + * @param $filePath + * @return MediaInfoContainer + */ public function getInfo($filePath) { $mediaInfoCommandBuilder = new MediaInfoCommandBuilder();