https://github.com/soluble-io/soluble-mediatools
Video / audio conversion, thumbnailing and more ! PHP FFmpeg wrapper
https://github.com/soluble-io/soluble-mediatools
converter ffmpeg ffmpeg-wrapper ffprobe psr-11 psr-16 psr-3 thumbnailer transcoder video video-converter
Last synced: 3 months ago
JSON representation
Video / audio conversion, thumbnailing and more ! PHP FFmpeg wrapper
- Host: GitHub
- URL: https://github.com/soluble-io/soluble-mediatools
- Owner: soluble-io
- License: mit
- Created: 2018-06-11T10:14:58.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-12-25T12:38:23.000Z (over 4 years ago)
- Last Synced: 2025-03-24T03:47:45.670Z (3 months ago)
- Topics: converter, ffmpeg, ffmpeg-wrapper, ffprobe, psr-11, psr-16, psr-3, thumbnailer, transcoder, video, video-converter
- Language: PHP
- Homepage: https://soluble-io.github.io/soluble-mediatools/
- Size: 4.99 MB
- Stars: 144
- Watchers: 8
- Forks: 11
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README

[](https://packagist.org/packages/soluble/mediatools)
[](https://travis-ci.org/soluble-io/soluble-mediatools)
[](https://codecov.io/gh/soluble-io/soluble-mediatools)
[](https://scrutinizer-ci.com/g/soluble-io/soluble-mediatools/?branch=master)
[](https://packagist.org/packages/soluble/mediatools)
[](https://packagist.org/packages/soluble/mediatools)

[](https://packagist.org/packages/soluble/mediatools)Flexible audio/video conversions and thumbnailing for hi*php*ies.
Wraps around [ffmpeg](https://www.ffmpeg.org/) and [ffprobe](https://www.ffmpeg.org/ffprobe.html)
and exposes most of their features, like scaling, clipping, filters, transcoding, audio extraction
and much more.To prevent limitations, the API rather focus on providing developer fine-tuned parameters
than giving ready-made recipes. Transcoding and conversions generally
requires specific processing, [judge by yourself](https://soluble-io.github.io/soluble-mediatools/video-conversion-service/#notes).
To help starting, the documentation includes a lot of examples and snippets you
can easily try and tune later. Check also [alternatives](./README.md#alternatives) wrappers
for ffmpeg, they are good and sometimes offer more magic if you're looking for it.
On another side, it likes [PSR](https://www.php-fig.org/psr/) (psr-log, psr-container, psr-simplecache), tastes php 7.1 in strict mode, tries to fail as early as possible
with clear exception messages and ensure that substitution is possible when you need to customize
*(SOLID friendly)*.Under the hood, it relies on the battle-tested [symfony/process](https://symfony.com/doc/current/components/process.html), its only dependency.
## DocumentationAll is here: **[https://soluble-io.github.io/soluble-mediatools/](https://soluble-io.github.io/soluble-mediatools/)**
## Requirements
- PHP 7.1+
- FFmpeg/FFProbe 3.4+, 4.0+.
## Features> Check the [doc](https://soluble-io.github.io/soluble-mediatools/) to get a more detailed overview !!!
### Implemented services
#### VideoConverter
> Full doc: [here](https://soluble-io.github.io/soluble-mediatools/video-conversion-service/)
```php
withVideoCodec('libx264')
->withStreamable(true)
->withCrf(24);
try {
$converter->convert(
'/path/inputFile.mov',
'/path/outputFile.mp4',
$params
);
} catch(ConverterExceptionInterface $e) {
// See chapter about exception !!!
}
```
#### VideoInfoReader> Full doc: [here](https://soluble-io.github.io/soluble-mediatools/video-info-service/)
```php
getInfo('/path/video.mp4');
} catch (InfoReaderExceptionInterface $e) {
// not a valid video (see exception)
}$duration = $info->getDuration(); // total duration
$format = $info->getFormatName(); // container format: mkv, mp4// Step 2: Media streams info (video, subtitle, audio, data).
// Example with first video stream (streams are iterable)
try {
$video = $info->getVideoStreams()->getFirst();
} catch (\Soluble\MediaTools\Video\Exception\NoStreamException $e) {
// No video stream,
}
$codec = $video->getCodecName(); // i.e: vp9
$fps = $video->getFps($decimals=0); // i.e: 24
$width = $video->getWidth(); // i.e: 1080
$ratio = $video->getAspectRatio();// Alternate example
if ($info->countStreams(VideoInfo::STREAM_TYPE_SUBTITLE) > 0) {
$sub = $info->getSubtitleStreams()->getFirst();
$sub->getCodecName(); // webvtt
}```
#### VideoThumbGenerator
> Full doc: [here](https://soluble-io.github.io/soluble-mediatools/video-thumb-service/)
```php
withTime(1.25);
try {
$generator->makeThumbnail(
'/path/inputFile.mov',
'/path/outputFile.jpg',
$params
);
} catch(ConverterExceptionInterface $e) {
// See chapter about exception !!!
}
```#### VideoAnalyzer
> Full doc: [here](https://soluble-io.github.io/soluble-mediatools/video-detection-service/)
```php
detectInterlacement(
'/path/input.mov',
// Optional:
// $maxFramesToAnalyze, default: 1000
$maxFramesToAnalyze = 200
);
} catch(AnalyzerExceptionInterface $e) {
// See chapter about exception !!!
}$interlaced = $interlaceGuess->isInterlaced(
// Optional:
// $threshold, default 0.25 (if >=25% interlaced frames, then true)
0.25
);```
## Alternatives
- [https://github.com/PHP-FFMpeg/PHP-FFMpeg](https://github.com/PHP-FFMpeg/PHP-FFMpeg)
- [https://github.com/char0n/ffmpeg-php](https://github.com/char0n/ffmpeg-php)
## Coding standards and interop* [PSR 4 Autoloader](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md)
* [PSR 3 Logger interface](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)
* [PSR 2 Coding Style Guide](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)