PHP code example of uberchel / mediainfo4php

1. Go to this page and download the library: Download uberchel/mediainfo4php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

uberchel / mediainfo4php example snippets




use uberchel\MediaInfo;
', true);
print_r($data);




 $data = MediaInfo::Get('1.mkv', true);
 print_r($data);




 MediaInfo::Load('1.mkv', true);




// By default, the MediaInfo4PHP class returns an Object anyway, this method supports a Boolean attribute,
// by default it is set to true, and this method can also return all metadata in the selected type.
// Setting the Array type for subsequent calls
 MediaInfo::asObject(false);
 
// Setting the Object type for subsequent calls
 MediaInfo::asObject();

// The following calls will return True / False
 MediaInfo::isObject();

// Checking for the existence of a method value return True / False
// $value - method, example: size or streams audios.size | video.size
// $index - array index in streams, optional parameter
 MediaInfo::Has($value, $index);

// Print the name, return string
 echo MediaInfo::GetTitle();

// Output the Size file, return string
 echo MediaInfo::GetSize();

// Output the Duration, return string
 echo MediaInfo::GetDuration();

// Output the start position, return string
 echo MediaInfo::GetStart();

// Output the Video Codec, return string
 echo MediaInfo::GetVideoCodec();

// Output the Audio Codec, return string
 echo MediaInfo::GetAudioCodec();

// Output the video bitrate, return string
 echo MediaInfo::GetBitrate();

// Output the encoder, return string
 echo MediaInfo::GetEncoder();

// Print the creation date, return string
 echo MediaInfo::GetCreated();

// Output a stream of Video, return Object or Array
 print_r(MediaInfo::GetVideo());

// Output an Audio stream, return Object or Array
 print_r(MediaInfo::GetAudios());

// Output a Subtitle stream, return Object or Array
 print_r(MediaInfo::GetSubtitles());

// Output a stream of Images, return Object or Array
 print_r(MediaInfo::GetPictures());

// Output Stream All streams, return Object or Array
 print_r(MediaInfo::GetStreams());

// Output All information to the stream, return Object or Array
 print_r(MediaInfo::Get());


use uberchel\MediaInfo;
if (MediaInfo::Has('size')) {
    echo MediaInfo::GetSize();
}


use uberchel\MediaInfo;
if (MediaInfo::Has('video.size')) {
    echo MediaInfo::GetVideo()->size;
}


use uberchel\MediaInfo;

foreach (MediaInfo::GetAudios() AS $audio) {
    echo "ID: {$audio['id']}, Title: {$audio['title']}, Codec: {$audio['codec']}";
}



use uberchel\MediaInfo;
print_r(MediaInfo::getVideoCodec() == MediaInfo::getVideoCodec('./2.mkv'));

//The same thing without loading the Load function
print_r(MediaInfo::getVideoCodec('./1.mkv') == MediaInfo::getVideoCodec('./2.mkv'));