• Stars
    star
    490
  • Rank 89,811 (Top 2 %)
  • Language
    PHP
  • License
    BSD 3-Clause "New...
  • Created almost 15 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

FFmpegPHP is a pure OO 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's 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...)

Build Status

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

References

More Repositories

1

ramda-adjunct

Ramda Adjunct is the most popular and most comprehensive set of functional utilities for use with Ramda, providing a variety of useful, well tested functions with excellent documentation.
JavaScript
679
star
2

django-profiler

django-profiler is util for profiling python code mainly in django projects but can be used also on ordinary python code. It counts sql queries a measures time of code execution. It logs its output via standard python logging library and uses logger profiling. If your profiler name doesn't contain any empty spaces e.g. Profiler('Profiler1') django-profiler will log all the output to the profiling.Profiler logger.
Python
57
star
3

swagger-editor-validate

This GitHub Actions validates OpenAPI (OAS) definition file using Swagger Editor.
JavaScript
32
star
4

http-request-in-editor

Reference implementation of HTTP Request in Editor Specification https://github.com/JetBrains/http-request-in-editor-spec
JavaScript
31
star
5

json-api-merge

JSON:API specific algorithm for merging included resources into original data.
JavaScript
22
star
6

lerna-monorepo-taming

This monorepo implements current practices and conventions used while building monorepos using Lerna
JavaScript
20
star
7

pybrowscap

Detection of browser capabilities (css, applets, javascript, ...) and features based on browscap file
Python
15
star
8

react-reusable-features

POC of creating reusable features in React + Redux ecosystem
JavaScript
13
star
9

monad-t

Transformers for monadic algebraic structures bridging types from various monadic libraries (Fluture, monet)
JavaScript
12
star
10

django-brevisurl

Django app for shortening urls
Python
9
star
11

swagger-adjust

Pluggable framework for creating extendable React+Redux applications
JavaScript
8
star
12

page-objects

Demonstration source code of "e2e (End-To-End) testing done properly series" article
JavaScript
8
star
13

django-pybrowscap

pybrowscap middlware for django
Python
4
star
14

openapi-runtime-expression

OpenAPI Runtime Expressions parser and validator.
JavaScript
4
star
15

i18next-test

POC of using i18next + react binding + extracting tool
JavaScript
3
star
16

angular-toastr-flash

Flashing support for https://github.com/Foxandxss/angular-toastr
3
star
17

log4django

logging platform for django projects
JavaScript
3
star
18

django-gearman-proxy

Proxy backends/workers for asynchronous email and sms sending using gearman as message queue.
Python
3
star
19

postgresql-czech-fulltext

PostgreSQL Docker image with Czech language fulltext search support
Shell
3
star
20

qencode

Full featured video transcoding using the Qencode API that can be easily modified for your website or application.
Elixir
3
star
21

json-parsers

Monorepo containing research for various json-parsers
JavaScript
2
star
22

vladimirgorej.com

Personal Website of Vladimír Gorej
HTML
2
star
23

log4php-Gearman

log4php-Gearman is log4php appender to Gearman job server.
PHP
2
star
24

char0n

Living and self-updating GitHub profile
JavaScript
2
star
25

morcom

Volkov Commander like file manager written in QBasic almost 20 years ago
Visual Basic
2
star
26

jmdb

jmdb is a real time parser for retrieving information from imdb.com.
Java
1
star
27

apidom-validate

This GitHub Action validates OpenAPI 3.x.y / AsyncAPI 2.x definition file using ApiDOM Language Service.
JavaScript
1
star
28

mx-scanner

Scanner for domains mx records
1
star
29

asyncapi-runtime-expression

AsyncAPI Runtime Expressions parser and validator.
JavaScript
1
star
30

swagger-ui-dist-vite

This repo serves as POC of integrating SwaggerUI dist fragments with vite + vue.js.
Vue
1
star
31

rifas

Rapid Internet File Allocation Service
Java
1
star