Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add documentation #12

Merged
merged 1 commit into from
Dec 22, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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