Video type detection library for PHP.
- Detection of the video type based on its header
- No dependencies
- Very fast
- AVI (Audio Video Interleave)
- MKV
- MP4
- MPEG-1 Part 2
- MPEG-2 Part 2
- OGG OGV
- 3G2 3GPP2
- 3GP 3GPP
- WEBM
- QuickTime
- RealMedia
- WMV (Windows Media Video)
- FLV (Adobe Flash Video)
- MXF (Material Exchange Format)
- PHP 7.2+
composer require selective/video-type
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
$video = new SplTempFileObject();
$video->fwrite('my file content');
$detector = new VideoTypeDetector();
// Add video detectors
$detector->addProvider(new DefaultVideoProvider());
echo $detector->getVideoTypeFromFile($file)->getFormat();
The MIT License (MIT). Please see License File for more information.