Skip to content

open-source-contributions/video-type

 
 

Repository files navigation

selective/video-type

Video type detection library for PHP.

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

Features

  • Detection of the video type based on its header
  • No dependencies
  • Very fast

Supported formats

  • AVI (Audio Video Interleave)
  • MP4
  • MPEG-2

Requirements

  • PHP 7.2+

Installation

composer require selective/video-type

Usage

Detect the video type of file

use Selective\VideoType\VideoTypeDetector;
use Selective\VideoType\Provider\DefaultVideoProvider;
use SplFileObject;

$file = new SplFileObject('example.mp4');

$detector = new VideoTypeDetector();

// Add video detectors
$detector->addProvider(new DefaultVideoProvider());
$videoType = $detector->getVideoTypeFromFile($file);

// Get the video format
echo $videoType->getFormat(); // mp4

// Get the mime type
echo $videoType->getMimeType(); // video/mp4

Detect the video type of in-memory object

$video = new SplTempFileObject();

$video->fwrite('my file content');

$detector = new VideoTypeDetector();

// Add video detectors
$detector->addProvider(new DefaultVideoProvider());

echo $detector->getVideoTypeFromFile($file)->getFormat();

License

  • MIT

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%