folour/flavy

为 Laravel 5.2-5.4 提供的 FFmpeg 层,这是 rafasamp/sonus 包的分支

v1.0.2 2017-05-08 22:22 UTC

This package is not auto-updated.

Last update: 2024-09-20 21:47:38 UTC


README

Scrutinizer Code Quality downloads license

为 Laravel 5.2-5.4 提供的 FFmpeg 层,这是 rafasamp/sonus 包的分支。

简单的音频/视频文件转换 API,从视频中获取缩略图,获取文件信息

安装

使用 composer 安装 Flavy

composer require folour/flavy

在 config/app.php 的 providers 数组中添加

Folour\Flavy\Provider\FlavyServiceProvider::class,

并在 aliases 数组中添加

'Flavy' => Folour\Flavy\FlavyFacade::class,

在项目根目录的终端中运行

php artisan vendor:publish

用法

将 ogg 文件转换为 mp3,并更改比特率

Flavy::from('path/to/file.ogg')
	->to('path/to/converted/file.mp3')
	->aBitrate(128)
	->aCodec('libmp3lame')
	->overwrite()
->run();

降低比特率并将通道数更改为 1(单声道)

Flavy::from('path/to/file.mp3')
	->to('paths/to/new_file.mp3')
	->aBitrate(64)
	->channels(1)
->run();

获取文件信息

Flavy::info('path/to/file.mp3'); //returns array with file info
Flavy::info('path/to/file.mp3', 'xml'); //returns xml string with file info
Flavy::info('path/to/file.mp3', 'csv'); //returns csv string with file info
Flavy::info('path/to/file.mp3', 'json', false); //returns json string with file info

制作缩略图

Flavy::thumbnail('path/to/video.mov', 'path/to/images/thumb_%d.jpg', 10); //Make 10 thumbnail and calculate time interval $duration/$count
Flavy::thumbnail('path/to/video.mov', 'path/to/images/thumb_%d.jpg', 10, 30); //Make 10 thumbnail with specified interval

获取 ffmpeg 基本信息

Flavy::encoders(); //return a nested array with audio and video encoders
Flavy::decoders(); //return a nested array with audio and video decoders
Flavy::formats(); //return array with supported formats

Flavy::canEncode('encoder'); //Check encoder support
Flavy::canDecode('decoder'); //Check decoder support