char0n/ffmpeg-php
Composer 安装命令:
composer require char0n/ffmpeg-php
包简介
PHP wrapper for FFmpeg application
README 文档
README
FFmpegPHP
FFmpegPHP is a pure OO PSR-4 compatible PHP port of ffmpeg-php library (that was written in C). It adds an easy to use, object-oriented API for accessing and retrieving information from video and audio files. It has methods for returning frames from movie files as images that can be manipulated using PHP image functions. This works well for automatically creating thumbnail images from movies. FFmpegPHP is also useful for reporting the duration and bitrate of audio files (mp3, wma...). FFmpegPHP can access many of the video formats supported by ffmpeg (mov, avi, mpg, wmv...)
Drop-in replacement for ffmpeg-php
FFmpegPHP can be used as a drop in replacement for ffmpeg-php library.
Documentation
FFmpegPHP API documentation can be found here http://char0n.github.io/ffmpeg-php/.
Requirements
- PHP >=7
- PHP extensions: gd, mbstring, xml
- ffmpeg or ffprobe
Installation
Source code
Grab the source code located in src/ directory and use it as you seem appropriate.
Composer installation
Grab the composer.phar which can install packages published on packagist.
$ wget https://raw.githubusercontent.com/composer/getcomposer.org/1b137f8bf6db3e79a38a5bc45324414a6b1f9df2/web/installer -O - -q | php
This command will create file called composer.phar.
Create a file called composer.json and paste the following JSON into it:
{
"require": {
"char0n/ffmpeg-php": "^3.0.0"
}
}
Install the FFmpegPHP by running the following command:
$ php composer.phar install
After this command is successfully executed, the new directory called vendor/ is created.
File structure of your current working directory should now look like this:
- composer.json
- composer.phar
- vendor/
To verify that everything works as expected create new file called test.php inside your current working
directory with the following content.
<?php require_once './vendor/autoload.php'; use Char0n\FFMpegPHP\Movie; $movie = new Movie('./test.mp4'); var_dump($movie->getDuration());
Before you run the script you need to also download the testing movie file:
$ wget https://github.com/char0n/ffmpeg-php/raw/master/tests/data/test.mp4
Now run it.
$ php test.php
The output should be something similar to the following:
float(32.14)
Note
Notice the first line (require './vendor/autoload.php';) in the above script. This line is
necessary because it configures how the FFmpegPHP will be included into your scripts and it
auto-magically knows where to look for FFmpegPHP.
Using FFmpegPHP
Object Oriented interface
FFmpegPHP is build using PSR-4 standard and it's interface is purely Object Oriented. We're using standar OOP patterns to create our API.
use Char0n\FFMpegPHP\Movie; $movie = new Movie('/path/to/media.mpeg'); $movie->getDuration(); // => 24
Compatibility layer
On top of our OO interface, there is an additional one that provides full compatibility with original ffmpeg-php library.
use Char0n\FFMpegPHP\Adapters\FFMpegMovie as ffmpeg_movie; $movie = new ffmpeg_movie('/path/to/media.mpeg'); $movie->getDuration(); // => 24
Partnership with GoDaddy
GoDaddy started to use FFmpegPHP as part of it's services from November 2018. If you need a server with ffmpeg and FFmpegPHP installed on it contact GoDaddy and they'll do it for you as part of its "Expert Service". As author of FFmpegPHP I agreed to provide support for users coming from GoDaddy asking about FFmpegPHP. All incoming GoDaddy customers, please use GitHub issues as a support channel.
Author
- char0n (Vladimír Gorej)
- email: vladimir.gorej@gmail.com
- web: https://www.linkedin.com/in/vladimirgorej/
References
char0n/ffmpeg-php 适用场景与选型建议
char0n/ffmpeg-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 237.93k 次下载、GitHub Stars 达 494, 最近一次更新时间为 2017 年 02 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「audio」 「video」 「ffmpeg」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 char0n/ffmpeg-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 char0n/ffmpeg-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 char0n/ffmpeg-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Easy to use SDK with grabber for multiple platforms at once like YouTube, Dailymotion, Facebook and more.
Thumbnails for videos
Library for manipulating audio files (validating, transcoding, and tagging)
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
A simple but effective command-line tool for generating thumbnails of a video, and corresponding VTT file, for use within JW Player to allow for toolbar video preview.
统计信息
- 总下载量: 237.93k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 495
- 点击次数: 13
- 依赖项目数: 1
- 推荐数: 3
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2017-02-03