https://github.com/selective-php/video-type
Video type detection
https://github.com/selective-php/video-type
forensic php video video-formats
Last synced: about 1 year ago
JSON representation
Video type detection
- Host: GitHub
- URL: https://github.com/selective-php/video-type
- Owner: selective-php
- License: mit
- Created: 2019-08-05T21:55:53.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-09-08T01:41:38.000Z (over 2 years ago)
- Last Synced: 2024-05-06T01:42:15.154Z (almost 2 years ago)
- Topics: forensic, php, video, video-formats
- Language: PHP
- Homepage:
- Size: 1.53 MB
- Stars: 3
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# selective/video-type
Video type detection library for PHP.
[](https://packagist.org/packages/selective/video-type)
[](LICENSE.md)
[](https://github.com/selective-php/video-type/actions)
[](https://scrutinizer-ci.com/g/selective-php/video-type/code-structure)
[](https://scrutinizer-ci.com/g/selective-php/video-type/?branch=master)
[](https://packagist.org/packages/selective/video-type/stats)
## Features
* Detection of the video type based on its header
* No dependencies
* Very fast
### Supported formats
* **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)
## Requirements
* PHP 7.2+
## Installation
```
composer require selective/video-type
```
## Usage
### Detect the video type of file
```php
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
```php
$video = new SplTempFileObject();
$video->fwrite('my file content');
$detector = new VideoTypeDetector();
// Add video detectors
$detector->addProvider(new DefaultVideoProvider());
echo $detector->getVideoTypeFromFile($file)->getFormat();
```
## License
The MIT License (MIT). Please see [License File](LICENSE) for more information.