# Laravel FFMpeg
[![Latest Version on Packagist](https://img.shields.io/packagist/v/pbmedia/laravel-ffmpeg.svg?style=flat-square)](https://packagist.org/packages/pbmedia/laravel-ffmpeg)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
![run-tests](https://github.com/protonemedia/laravel-ffmpeg/workflows/run-tests/badge.svg)
[![Total Downloads](https://img.shields.io/packagist/dt/pbmedia/laravel-ffmpeg.svg?style=flat-square)](https://packagist.org/packages/pbmedia/laravel-ffmpeg)
This package provides an integration with FFmpeg for Laravel 9. [Laravel's Filesystem](http://laravel.com/docs/9.x/filesystem) handles the storage of the files.
## Sponsor this package!
�씍截� We proudly support the community by developing Laravel packages and giving them away for free. If this package saves you time or if you're relying on it professionally, please consider [sponsoring the maintenance and development](https://github.com/sponsors/pascalbaljet). Keeping track of issues and pull requests takes time, but we're happy to help!
## Laravel Splade
**Did you hear about Laravel Splade? �윣�**
It's the *magic* of Inertia.js with the *simplicity* of Blade. [Splade](https://github.com/protonemedia/laravel-splade) provides a super easy way to build Single Page Applications using Blade templates. Besides that magic SPA-feeling, it comes with more than ten components to sparkle your app and make it interactive, all without ever leaving Blade.
## Features
* Super easy wrapper around [PHP-FFMpeg](https://github.com/PHP-FFMpeg/PHP-FFMpeg), including support for filters and other advanced features.
* Integration with [Laravel's Filesystem](http://laravel.com/docs/9.x/filesystem), [configuration system](https://laravel.com/docs/9.x/configuration) and [logging handling](https://laravel.com/docs/9.x/errors).
* Compatible with Laravel 9, support for [Package Discovery](https://laravel.com/docs/9.x/packages#package-discovery).
* Built-in support for HLS.
* Built-in support for encrypted HLS (AES-128) and rotating keys (optional).
* Built-in support for concatenation, multiple inputs/outputs, image sequences (timelapse), complex filters (and mapping), frame/thumbnail exports.
* Built-in support for watermarks (positioning and manipulation).
* Built-in support for creating a mosaic/sprite/tile from a video.
* Built-in support for generating *VTT Preview Thumbnail* files.
* Requires PHP 8.0, 8.1, and 8.2.
* Tested with FFmpeg 4.4 and 5.0.
## Installation
Verify you have the latest version of FFmpeg installed:
```bash
ffmpeg -version
```
You can install the package via composer:
```bash
composer require pbmedia/laravel-ffmpeg
```
Add the Service Provider and Facade to your ```app.php``` config file if you're not using Package Discovery.
```php
// config/app.php
'providers' => [
...
ProtoneMedia\LaravelFFMpeg\Support\ServiceProvider::class,
...
];
'aliases' => [
...
'FFMpeg' => ProtoneMedia\LaravelFFMpeg\Support\FFMpeg::class
...
];
```
Publish the config file using the artisan CLI tool:
```bash
php artisan vendor:publish --provider="ProtoneMedia\LaravelFFMpeg\Support\ServiceProvider"
```
## Upgrading to v8
* The `set_command_and_error_output_on_exception` configuration key now defaults to `true`, making exceptions more informative. Read more at the [Handling exceptions](#handling-exceptions) section.
* The `enable_logging` configuration key has been replaced by `log_channel` to choose the log channel used when writing messages to the logs. If you still want to disable logging entirely, you may set the new configuration key to `false`.
* The *segment length* and *keyframe interval* of [HLS exports](#HLS) should be `2` or more; less is not supported anymore.
* As Laravel 9 has migrated from [Flysystem 1.x to 3.x](https://laravel.com/docs/9.x/upgrade#flysystem-3), this version is not compatible with Laravel 8 or earlier.
* If you're using the [Watermark manipulation](#watermark-manipulation) feature, make sure you upgrade [`spatie/image`](https://github.com/spatie/image) to v2.
## Upgrading to v7
* The namespace has changed to `ProtoneMedia\LaravelFFMpeg`, the facade has been renamed to `ProtoneMedia\LaravelFFMpeg\Support\FFMpeg`, and the Service Provider has been renamed to `ProtoneMedia\LaravelFFMpeg\Support\ServiceProvider`.
* Chaining exports are still supported, but you have to reapply filters for each export.
* HLS playlists now include bitrate, framerate and resolution data. The segments also use a new naming pattern ([read more](#using-custom-segment-patterns)). Please verify your exports still work in your player.
* HLS export is now executed as *one* job instead of exporting each format/stream separately. This uses FFMpeg's `map` and `filter_complex` features. It might be sufficient to replace all calls to `addFilter` with `addLegacyFilter`, but some filters should be migrated manually. Please read the [documentation on HLS](#hls) to find out more about adding filters.
## Usage
Convert an audio or video file:
```php
FFMpeg::fromDisk('songs')
->open('yesterday.mp3')
->export()
->toDisk('converted_songs')
->inFormat(new \FFMpeg\Format\Audio\Aac)
->save('yesterday.aac');
```
Instead of the ```fromDisk()``` method you can also use the ```fromFilesystem()``` method, where ```$filesystem``` is an instance of ```Illuminate\Contracts\Filesystem\Filesystem```.
```php
$media = FFMpeg::fromFilesystem($filesystem)->open('yesterday.mp3');
```
### Progress monitoring
You can monitor the transcoding progress. Use the ```onProgress``` method to provide a callback, which gives you the completed percentage. In previous versions of this package you had to pass the callback to the format object.
```php
FFMpeg::open('steve_howe.mp4')
->export()
->onProgress(function ($percentage) {
echo "{$percentage}% transcoded";
});
```
The callback may also expose `$remaining` (in seconds) and `$rate`:
```php
FFMpeg::open('steve_howe.mp4')
->export()
->onProgress(function ($percentage, $remaining, $rate) {
echo "{$remaining} seconds left at rate: {$rate}";
});
```
### Opening uploaded files
You can open uploaded files directly from the `Request` instance. It's probably better to first save the uploaded file in case the request aborts, but if you want to, you can open a `UploadedFile` instance:
```php
class UploadVideoController
{
public function __invoke(Request $request)
{
FFMpeg::open($request->file('video'));
}
}
```
### Open files from the web
You can open files from the web by using the `openUrl` method. You can specify custom HTTP headers with the optional second parameter:
```php
FFMpeg::openUrl('https://videocoursebuilder.com/lesson-1.mp4');
FFMpeg::openUrl('https://videocoursebuilder.com/lesson-2.mp4', [
'Authorization' => 'Basic YWRtaW46MTIzNA==',
]);
```
### Handling exceptions
When the encoding fails, a `ProtoneMedia\LaravelFFMpeg\Exporters\EncodingException` shall be thrown, which extends the underlying `FFMpeg\Exception\RuntimeException` class. This class has two methods that can help you identify the problem. Using the `getCommand` method, you can get the executed command with all parameters. The `getErrorOutput` method gives you a full output log.
In previous versions of this package, the message of the exception was always *Encoding failed*. You can downgrade to this message by updating the `set_command_and_error_output_on_exception` configuration key to `false`.
```php
try {
FFMpeg::open('yesterday.mp3')
->export()
->inFormat(new Aac)
->save('yesterday.aac');
} catch (EncodingException $exception) {
$command = $exception->getCommand();
$errorLog = $exception->getErrorOutput();
}
```
### Filters
You can add filters through a ```Closure``` or by using PHP-FFMpeg's Filter objects:
```php
use FFMpeg\Filters\Video\VideoFilters;
FFMpeg::fromDisk('videos
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
您是否正在为您的企业寻找一个完整的按需电影流媒体解决方案系统,那么您来对地方了。无需支付数千美元聘请开发人员来构建您的电影流媒体平台。PlayLab是一个完整的在线电影和视频流媒体平台,为用户提供了用户友好的体验,并为管理员提供了一个易于管理的环境 突出显示的功能 即时直播视频播放。 免费和付费,这两种类型的视频. 第三方链接和自我上传系统。 带有FTP和芥末存储设施。 即时订阅,20+自动支付网关。 现代和干净的用户界面。 优质和快速的支持。
资源推荐
资源详情
资源评论
收起资源包目录
PlayLab v2.6-跨平台点播电影流移动的Flutter应用程序项目源码支持android ios (2000个子文件)
app.css 162KB
bootstrap.min.css 160KB
bootstrap.min.css 160KB
line-awesome.css 115KB
main.css 90KB
line-awesome.min.css 88KB
line-awesome.min.css 88KB
style.css 81KB
font-awesome.css 76KB
animate.css 73KB
animate.min.css 67KB
all.min.css 58KB
fontawesome-all.min.css 56KB
video.min.css 50KB
iziToast.min.css 41KB
main.css 27KB
swiper.min.css 19KB
lightcase.css 17KB
exception.css 17KB
select2.min.css 15KB
spectrum.css 15KB
datepicker.min.css 12KB
installer.css 9KB
fontawesome-iconpicker.min.css 6KB
codemirror.min.css 6KB
default.css 5KB
nice-select.css 4KB
simplebar.css 4KB
bootstrap-clockpicker.min.css 4KB
custom.css 4KB
custom.css 4KB
verification_code.css 4KB
verification-code.css 3KB
htmlDescriptor.css 3KB
exception_full.css 3KB
main.css 3KB
bootstrap-fileinput.css 3KB
monokai.min.css 2KB
slick.css 2KB
bootstrap-toggle.min.css 2KB
global.css 754B
ConfigForm.css 301B
error.css 275B
.editorconfig 276B
.env 0B
la-solid-900.eot 221KB
la-solid-900.eot 221KB
fa-solid-900.eot 198KB
fa-solid-900.eot 188KB
la-brands-400.eot 153KB
la-brands-400.eot 153KB
fa-brands-400.eot 131KB
fa-brands-400.eot 128KB
fa-regular-400.eot 34KB
fa-regular-400.eot 33KB
la-regular-400.eot 33KB
la-regular-400.eot 33KB
airplayButton.eot 1KB
airplayButton.eot 1KB
.env.example 964B
.env.example 62B
preloader.gif 161KB
nicEditIcons-latest.gif 4KB
.gitattributes 162B
.gitignore 128B
.gitignore 70B
.gitignore 47B
.gitignore 26B
.gitignore 24B
.gitignore 16B
.gitignore 16B
.gitignore 16B
.gitignore 16B
.gitignore 16B
.gitignore 16B
.gitignore 16B
.gitignore 11B
.htaccess 707B
index.html 47KB
report.html 2KB
preview.jpg 931KB
preview.jpg 701KB
login.jpg 536KB
62920e60e3c0c1653739104.jpg 189KB
62920e56dabf91653739094.jpg 189KB
6292131bcf52b1653740315.jpg 189KB
62920e53857211653739091.jpg 189KB
62920368a68be1653736296.jpg 189KB
62920e5d5edfb1653739101.jpg 189KB
62920081836521653735553.jpg 189KB
628a12b93737b1653215929.jpg 174KB
628b92fcca1391653314300.jpg 117KB
62aad5d5eeb5d1655363029.jpg 117KB
63fa0dfb407711677331963.jpg 117KB
video.min.js 909KB
firebase-8.3.2.js 840KB
video.min.js 546KB
apexcharts.min.js 448KB
chart.js.2.8.0.js 357KB
fontawesome-iconpicker.js 338KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
小云同志你好
- 粉丝: 1049
- 资源: 935
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功