sharapov/php-ffmpeg-extensions
Composer 安装命令:
composer require sharapov/php-ffmpeg-extensions
包简介
An extensions library for the PHP FFMpeg (https://github.com/PHP-FFMpeg/PHP-FFMpeg)
关键字:
README 文档
README
An extensions library for the PHP FFMpeg (https://github.com/PHP-FFMpeg/PHP-FFMpeg)
Installation (via Composer):
For composer installation, add:
"require": { "sharapov/php-ffmpeg-extensions": "^0.2" },
to your composer.json file and update your dependencies. Or you can run:
$ composer require sharapov/php-ffmpeg-extensions
Notes:
Tested with ffmpeg 3+, not tested with ffmpeg 4+
Usage:
Now you can autoload or use the class via its namespace. Below are examples of how to use the library.
Draw texts and boxes
// Init FFMpeg library $ffmpeg = \Sharapov\FFMpegExtensions\FFMpeg::create(array( 'ffmpeg.binaries' => '/path/to/ffmpeg', // Path to FFMpeg 'ffprobe.binaries' => '/path/to/ffprobe', // Path to FFProbe 'timeout' => 3600, // The timeout for the underlying process 'ffmpeg.threads' => 12, // The number of threads that FFMpeg should use )); // Open source video $video = $ffmpeg->open( new InputFile( 'source/Coast - 1270.mp4' ) ); // Apply filter options to video $video ->filters() ->complex( new OptionsCollection( [ ( ( new FilterComplexOptions\OptionDrawText() ) // Set z-index property. Greater value is always in front ->setZIndex( 160 ) // You can use fade-in and fade-out effects. Set time in seconds ->setFadeIn( 1 ) ->setFadeOut( 2 ) // Set font path ->setFontFile( new InputFile( 'source/arial.ttf' ) ) // Set font color. Accepts transparency value as the second argument. Float value between 0 and 1. ->setFontColor( '#ffffff' ) // Set font size in pixels ->setFontSize( 33 ) // Set text string ->setText( 'php-ffmpeg-extensions library' ) // Coordinates where the text should be rendered. Accepts positive integer or // constants "(w-tw)/2", "(h-th)/2" to handle auto-horizontal, auto-vertical values ->setCoordinates( new Coordinate\Point( Coordinate\Point::AUTO_HORIZONTAL, 50 ) ) // Set timings (start, stop) in seconds. Accepts float values as well ->setTimeLine( new Coordinate\TimeLine( 1, 20 ) ) ), ( ( new FilterComplexOptions\OptionDrawText() ) ->setZIndex( 160 ) ->setFadeIn( 1 ) ->setFadeOut( 2 ) ->setFontFile( new InputFile( 'source/arial.ttf' ) ) ->setFontColor( '#ffffff' ) ->setFontSize( 28 ) ->setText( 'Sharapov A. (www.sharapov.biz)' ) ->setCoordinates( new Coordinate\Point( 15, 600 ) ) ->setTimeLine( new Coordinate\TimeLine( 2, 20 ) ) ), ( ( new FilterComplexOptions\OptionDrawBox() ) ->setZIndex( 130 ) ->setColor( '000000', 0.6 ) ->setDimensions( new Coordinate\Dimension( Coordinate\Dimension::WIDTH_MAX, 60 ) ) ->setCoordinates( new Coordinate\Point( 0, 580 ) ) ), ( ( new FilterComplexOptions\OptionDrawText() ) ->setZIndex( 160 ) ->setFadeIn( 1 ) ->setFadeOut( 2 ) ->setFontFile( new InputFile( 'source/arial.ttf' ) ) ->setFontColor( '#ffffff' ) ->setFontSize( 28 ) ->setText( 'v2.0' ) ->setCoordinates( new Coordinate\Point( 1200, 600 ) ) ->setTimeLine( new Coordinate\TimeLine( 3, 20 ) ) ) ] ) ); // Run render $format = new \FFMpeg\Format\Video\X264( 'libmp3lame' ); $format->on( 'progress', function ( $video, $format, $percentage ) { echo "$percentage% transcoded\n"; } ); try { $video ->save( $format, 'output/output.mp4' ); print 'Done!'; } catch ( ExecutionFailureException $e ) { print $e->getMessage(); }
You will find other examples in "/examples" folder.
Changelog
Links
sharapov/php-ffmpeg-extensions 适用场景与选型建议
sharapov/php-ffmpeg-extensions 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 679 次下载、GitHub Stars 达 15, 最近一次更新时间为 2016 年 06 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「audio」 「video processing」 「video」 「audio processing」 「avconv」 「ffmpeg」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sharapov/php-ffmpeg-extensions 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sharapov/php-ffmpeg-extensions 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sharapov/php-ffmpeg-extensions 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Easy to use SDK with grabber for multiple platforms at once like YouTube, Dailymotion, Facebook and more.
Library for manipulating audio files (validating, transcoding, and tagging)
paywant api php client
The yii2-videojs-widget is a Yii 2 wrapper for the [video.js](http://www.videojs.com/). A JavaScript and CSS library that makes it easier to work with and build on HTML5 video. This is also known as an HTML5 Video Player.
Display a video using native HTML5 video
Convert and operate with FIPS codes for states, counties, etc.
统计信息
- 总下载量: 679
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 15
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2016-06-28