char0n/ffmpeg-php
소개
FFmpegPHP는 C로 작성된 ffmpeg-php 라이브러리를 순수한 객체 지향 PHP로 포팅한 것입니다. 동영상 및 오디오 파일에 접근해 정보를 가져오는 사용하기 쉬운 객체 지향 API를 제공합니다. 동영상 파일의 프레임을 이미지로 반환하는 메서드도 있으며, 반환된 이미지는 PHP 이미지 함수로 처리할 수 있습니다. 동영상 썸네일을 자동으로 만드는 데 유용합니다. 또한 오디오 파일(mp3, wma 등)의 재생 시간과 비트레이트를 확인하는 데도 사용할 수 있습니다. ffmpeg가 지원하는 다양한 동영상 형식(mov, avi, mpg, wmv 등)에 접근할 수 있습니다.
디자인 및 미디어측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- -2
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalFFmpegPHP
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: [email protected]
- web: https://www.linkedin.com/in/vladimirgorej/
References
관련 프로젝트 살펴보기
불러오는 중…