# php-ffmpeg
[![Build Status](https://secure.travis-ci.org/PHP-FFMpeg/PHP-FFMpeg.png?branch=master)](http://travis-ci.org/PHP-FFMpeg/PHP-FFMpeg)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/607f3111-e2d7-44e8-8bcc-54dd64521983/big.png)](https://insight.sensiolabs.com/projects/607f3111-e2d7-44e8-8bcc-54dd64521983)
An Object-Oriented library to convert video/audio files with FFmpeg / AVConv.
Check another amazing repo: [PHP FFMpeg extras](https://github.com/alchemy-fr/PHP-FFMpeg-Extras), you will find lots of Audio/Video formats there.
## Your attention please
### How this library works:
This library requires a working FFMpeg install. You will need both FFMpeg and FFProbe binaries to use it.
Be sure that these binaries can be located with system PATH to get the benefit of the binary detection,
otherwise you should have to explicitly give the binaries path on load.
For Windows users: Please find the binaries at http://ffmpeg.zeranoe.com/builds/.
### Known issues:
- Using rotate and resize will produce a corrupted output when using
[libav](http://libav.org/) 0.8. The bug is fixed in version 9. This bug does not
appear in latest ffmpeg version.
## Installation
The recommended way to install PHP-FFMpeg is through [Composer](https://getcomposer.org).
```bash
$ composer require php-ffmpeg/php-ffmpeg
```
## Basic Usage
```php
require 'vendor/autoload.php';
$ffmpeg = FFMpeg\FFMpeg::create();
$video = $ffmpeg->open('video.mpg');
$video
->filters()
->resize(new FFMpeg\Coordinate\Dimension(320, 240))
->synchronize();
$video
->frame(FFMpeg\Coordinate\TimeCode::fromSeconds(10))
->save('frame.jpg');
$video
->save(new FFMpeg\Format\Video\X264(), 'export-x264.mp4')
->save(new FFMpeg\Format\Video\WMV(), 'export-wmv.wmv')
->save(new FFMpeg\Format\Video\WebM(), 'export-webm.webm');
```
## Documentation
This documentation is an introduction to discover the API. It's recommended
to browse the source code as it is self-documented.
### FFMpeg
`FFMpeg\FFMpeg` is the main object to use to manipulate medias. To build it,
use the static `FFMpeg\FFMpeg::create`:
```php
$ffmpeg = FFMpeg\FFMpeg::create();
```
FFMpeg will autodetect ffmpeg and ffprobe binaries. If you want to give binary
paths explicitly, you can pass an array as configuration. A `Psr\Logger\LoggerInterface`
can also be passed to log binary executions.
```php
$ffmpeg = FFMpeg\FFMpeg::create(array(
'ffmpeg.binaries' => '/opt/local/ffmpeg/bin/ffmpeg',
'ffprobe.binaries' => '/opt/local/ffmpeg/bin/ffprobe',
'timeout' => 3600, // The timeout for the underlying process
'ffmpeg.threads' => 12, // The number of threads that FFMpeg should use
), $logger);
```
### Manipulate media
`FFMpeg\FFMpeg` creates media based on URIs. URIs could be either a pointer to a
local filesystem resource, an HTTP resource or any resource supported by FFmpeg.
**Note**: To list all supported resource type of your FFmpeg build, use the
`-protocols` command:
```
ffmpeg -protocols
```
To open a resource, use the `FFMpeg\FFMpeg::open` method.
```php
$ffmpeg->open('video.mpeg');
```
Two types of media can be resolved: `FFMpeg\Media\Audio` and `FFMpeg\Media\Video`.
A third type, `FFMpeg\Media\Frame`, is available through videos.
### Video
`FFMpeg\Media\Video` can be transcoded, ie: change codec, isolate audio or
video. Frames can be extracted.
##### Transcoding
You can transcode videos using the `FFMpeg\Media\Video:save` method. You will
pass a `FFMpeg\Format\FormatInterface` for that.
Please note that audio and video bitrate are set on the format.
```php
$format = new FFMpeg\Format\Video\X264();
$format->on('progress', function ($video, $format, $percentage) {
echo "$percentage % transcoded";
});
$format
->setKiloBitrate(1000)
->setAudioChannels(2)
->setAudioKiloBitrate(256);
$video->save($format, 'video.avi');
```
Transcoding progress can be monitored in realtime, see Format documentation
below for more information.
##### Extracting image
You can extract a frame at any timecode using the `FFMpeg\Media\Video::frame`
method.
This code returns a `FFMpeg\Media\Frame` instance corresponding to the second 42.
You can pass any `FFMpeg\Coordinate\TimeCode` as argument, see dedicated
documentation below for more information.
```php
$frame = $video->frame(FFMpeg\Coordinate\TimeCode::fromSeconds(42));
$frame->save('image.jpg');
```
If you want to extract multiple images from the video, you can use the following filter:
```php
$video
->filters()
->extractMultipleFrames(FFMpeg\Filters\Video\ExtractMultipleFramesFilter::FRAMERATE_EVERY_10SEC, '/path/to/destination/folder/')
->synchronize();
$video
->save(new FFMpeg\Format\Video\X264(), '/path/to/new/file');
```
By default, this will save the frames as `jpg` images.
You are able to override this using `setFrameFileType` to save the frames in another format:
```php
$frameFileType = 'jpg'; // either 'jpg', 'jpeg' or 'png'
$filter = new ExtractMultipleFramesFilter($frameRate, $destinationFolder);
$filter->setFrameFileType($frameFileType);
$video->addFilter($filter);
```
##### Clip
Cuts the video at a desired point. Use input seeking method. It is faster option than use filter clip.
```php
$clip = $video->clip(FFMpeg\Coordinate\TimeCode::fromSeconds(30), FFMpeg\Coordinate\TimeCode::fromSeconds(15));
$clip->save(new FFMpeg\Format\Video\X264(), 'video.avi');
```
The clip filter takes two parameters:
- `$start`, an instance of `FFMpeg\Coordinate\TimeCode`, specifies the start point of the clip
- `$duration`, optional, an instance of `FFMpeg\Coordinate\TimeCode`, specifies the duration of the clip
On clip you can apply same filters as on video. For example resizing filter.
```php
$clip = $video->clip(FFMpeg\Coordinate\TimeCode::fromSeconds(30), FFMpeg\Coordinate\TimeCode::fromSeconds(15));
$clip->filters()->resize(new FFMpeg\Coordinate\Dimension(320, 240), FFMpeg\Filters\Video\ResizeFilter::RESIZEMODE_INSET, true);
$clip->save(new FFMpeg\Format\Video\X264(), 'video.avi');
```
##### Generate a waveform
You can generate a waveform of an audio file using the `FFMpeg\Media\Audio::waveform`
method.
This code returns a `FFMpeg\Media\Waveform` instance.
You can optionally pass dimensions as the first two arguments and an array of hex string colors for ffmpeg to use for the waveform, see dedicated
documentation below for more information.
The output file MUST use the PNG extension.
```php
$waveform = $audio->waveform(640, 120, array('#00FF00'));
$waveform->save('waveform.png');
```
If you want to get a waveform from a video, convert it in an audio file first.
```php
// Open your video file
$video = $ffmpeg->open( 'video.mp4' );
// Set an audio format
$audio_format = new FFMpeg\Format\Audio\Mp3();
// Extract the audio into a new file as mp3
$video->save($audio_format, 'audio.mp3');
// Set the audio file
$audio = $ffmpeg->open( 'audio.mp3' );
// Create the waveform
$waveform = $audio->waveform();
$waveform->save( 'waveform.png' );
```
##### Filters
You can apply filters on `FFMpeg\Media\Video` with the `FFMpeg\Media\Video::addFilter`
method. Video accepts Audio and Video filters.
You can build your own filters and some are bundled in PHP-FFMpeg - they are
accessible through the `FFMpeg\Media\Video::filters` method.
Filters are chainable
```php
$video
->filters()
->resize($dimension, $mode, $useStandards)
->framerate($framerate, $gop)
->synchronize();
```
###### Rotate
Rotates a video to a given angle.
```php
$video->filters()->rotate($angle);
```
The `$angle` parameter must be one of the following constants :
- `FFMpeg\Filters\Video\RotateFilter::ROTATE_90`: 90° clockwise
- `FFMpeg\Filters\Video\RotateFilter::ROTATE_180`: 180°
- `FFMpeg\Filters\Video\RotateFilter::ROTATE_270`: 90° counterclockwise
###### Resize
Resizes a video to a given size.
```php
$video->filters()->resize($dimension, $mode, $useStandards);
```
The resize
没有合适的资源?快使用搜索试试~ 我知道了~
公众号模块 朋友圈广告12.8源码
共2964个文件
php:993个
html:429个
dat:360个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 1 下载量 23 浏览量
2022-03-16
15:27:07
上传
评论 1
收藏 31.99MB ZIP 举报
温馨提示
1、市场现状: 近年来,销售行业纷纷涌向微商大军,所谓微商就是“朋友圈发广告的人”,如果我们能为他们服务,帮他们解决一些难题,势必从这么庞大群体口袋里轻松掏钱。 2、解决方案: 朋友圈广告助手的出现,从根本上解决了微商这个行业推广难、成本高、效果差的问题。朋友圈广告助手是一个微信营销利器,是一个赚钱机器,更是一个资源整合神器。 朋友圈广告助手,是微营销推广必备工具,互联网 自媒体广告,是经济有效的广告模式,可在热门文章中随意植入广告,含文字、图片、链接、电话等,读者不反感,还会转发分享,传播更广泛,精准有价值,省钱又赚钱。 借个头条打广告,把别人高流量的文章加上自己的广告,系统还内置两级分佣,打广告的同时还能赚佣金,何乐而不为。 一键植入广告,零成本打劫朋友圈、公众号,微营销必备工具,轻松宣传产品,让广告没有痕迹!
资源推荐
资源详情
资源评论
收起资源包目录
公众号模块 朋友圈广告12.8源码 (2964个子文件)
sample.3gp 28KB
merge.bat 22B
ReaderWriter.cd 6KB
Architecture.cd 2KB
CHANGELOG 1KB
config 1KB
config 1KB
config 1KB
config 1KB
config 1KB
config 1KB
config 1KB
config 1KB
config 1KB
config 1KB
config 1KB
config 1KB
config 1KB
config 1KB
config 1KB
config 1KB
config 1KB
config 1KB
PHPExcel_Writer_Serialized.cs 2KB
PHPExcel_Reader_Excel5.cs 1KB
PHPExcel_Reader_Serialized.cs 1016B
PHPExcel_IOFactory.cs 894B
PHPExcel.cs 862B
PHPExcel_Writer_Excel2007.cs 562B
PHPExcel_Reader_Excel2007.cs 561B
IWriter.cs 246B
IReader.cs 245B
Worksheet.cs 195B
ClassDiagrams.csproj 3KB
common.min.css 245KB
bui.css 140KB
bootstrap.min.css 118KB
bootstrap.min.css 107KB
aui.css 66KB
edit.css 62KB
layui.css 50KB
editor_ie8.css 48KB
editor_iequirks.css 47KB
editor_ie.css 47KB
editor_gecko.css 46KB
editor.css 46KB
animate.css 45KB
video.css 38KB
font-awesome.css 36KB
weixin.css 35KB
font-awesome.min.css 30KB
base.css 29KB
item.css 28KB
bootstrap-theme.min.css 23KB
console.css 22KB
swiper.min.css 19KB
swiper.css 19KB
swiper-3.4.2.min.css 17KB
item.css 16KB
layim.css 15KB
dialog_ie8.css 15KB
swiper.min.css 14KB
dialog_iequirks.css 14KB
dialog_ie.css 14KB
layer.css 14KB
play.css 13KB
index.css 13KB
index.css 13KB
dialog.css 13KB
item.css 10KB
layui.mobile.css 10KB
card.css 9KB
panel.css 9KB
uploader.css 9KB
actmsginfo.css 9KB
index.css 9KB
index.css 9KB
layim.css 9KB
webcard_one.css 8KB
stylesheet.css 8KB
laydate.css 7KB
index.css 7KB
cash.css 7KB
index.css 7KB
index.css 7KB
zTreeStyle.css 6KB
layer.css 5KB
usermoney.css 5KB
webcard_three.css 5KB
common.css 5KB
webcard_five.css 5KB
add.css 5KB
login.css 4KB
index.css 4KB
webcard_two.css 4KB
user.css 4KB
index.css 4KB
iconfont.css 4KB
main.css 4KB
help.css 4KB
共 2964 条
- 1
- 2
- 3
- 4
- 5
- 6
- 30
资源评论
- bcd15882023-01-11资源不错,内容挺好的,有一定的使用价值,值得借鉴,感谢分享。
智慧浩海
- 粉丝: 1w+
- 资源: 5119
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- #P0015. 全排列 超级简单
- pta题库答案c语言之排序4统计工龄.zip
- pta题库答案c语言之树结构7堆中的路径.zip
- pta题库答案c语言之树结构3TreeTraversalsAgain.zip
- pta题库答案c语言之树结构2ListLeaves.zip
- pta题库答案c语言之树结构1树的同构.zip
- 基于C++实现民航飞行与地图简易管理系统可执行程序+说明+详细注释.zip
- pta题库答案c语言之复杂度1最大子列和问题.zip
- 三维装箱问题(Three-Dimensional Bin Packing Problem,3D-BPP)是一个经典的组合优化问题
- 以下是一些关于Linux线程同步的基本概念和方法.txt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功