Skip to content

Commit

Permalink
add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mhor committed Dec 21, 2014
1 parent cda32c7 commit 76332b6
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 1 deletion.
135 changes: 134 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<?php
//...
use Mhor\MediaInfo\MediaInfo;
//...
$mediaInfo = new MediaInfo();
$mediaInfo->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
5 changes: 5 additions & 0 deletions src/MediaInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 76332b6

Please sign in to comment.