PHP Classes
elePHPant
Icontem

FFmpeg PHP: Manipulate video files using the ffmpeg program

Recommend this page to a friend!

  Author Author  
Name: Vladimir Gorej <contact>
Classes: 1 package by
Country: Slovak Republic Slovak Republic
Age: ???
All time rank: 7832 in Slovak Republic Slovak Republic
Week rank: 123 Up1 in Slovak Republic Slovak Republic Up


  Detailed description   Download Download .zip .tar.gz   Install with Composer Install with Composer  
This package can be used to manipulate videos files in PHP using the ffmpeg program.

It provides classes for retrieving information from video and audio files like the duration, frame and sample rate, frame size, etc..

It can also extract individual frames from the videos and create GD image resources.

It supports the all the video formats supported by ffmpeg like MOV, AVI, MPEG, WMV, and the audio formats MP3 and WMA.

Details

CircleCI

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

  • https://packagist.org/packages/char0n/ffmpeg-php
  • http://github.com/char0n/ffmpeg-php
  • http://ffmpeg-php.sourceforge.net/
  • http://www.phpclasses.org/package/5977-PHP-Manipulate-video-files-using-the-ffmpeg-program.html
  • http://freshmeat.net/projects/ffmpegphp

  Classes of Vladimir Gorej  >  FFmpeg PHP  >  Download Download .zip .tar.gz  >  Support forum Support forum (3)  >  Blog Blog  >  RSS 1.0 feed RSS 2.0 feed Latest changes  

 

Name: FFmpeg PHP
Base name: ffmpeg-php
Description: Manipulate video files using the ffmpeg program
Version: 3.0.4
PHP version: 7.1
License: BSD License
All time users: 3916 users
All time rank: 801
Week users: 3 users
Week rank: 114 Up
 
  Groups   Rate classes User ratings   Trackback  
  Applications   Related pages   Files Files  

  Groups  
Group folder image PHP 5 Classes using PHP 5 specific features View top rated classes
Group folder image Audio Voice and music data generation and manipulation View top rated classes
Group folder image Video Movies and video data generation and manipulation View top rated classes


  Recommendations  

API or class for detecting video meta data
I need to get meta data for a video like frame-rate, length etc


  User ratings  
RatingsUtility Consistency Documentation Examples Tests Videos Overall Rank
All time: Good (96%) Good (96%) Good (89%) - - - Sufficient (66%) 670
Month: Not yet rated by the users

  Pages that reference this package  
Extracting frames from videos using PHP (Polish)
Thanks to Vladimir and his script are burning FFmpeg PHP published on phpclasses.org made it possible.

Latest pages that reference packages Latest pages that reference packages


  Applications that use this package  
Coiton project
Video sharing system
VideoDroid converter
free online service allowing you to convert and download Videos to MP3 with ease

Add link image If you know an application of this package, send a message to the author to add a link here.


  Related pages  
FFmpegPHP git repository
FFmpegPHP git repository
FFmpegPHP Homepage
FFmpegPHP Homepage
PEAR channel
FFmpegPHP PEAR installer channel

  Files folder image Files  
File Role Description
Files folder imagetest (1 directory)
Files folder image.circleci (1 file)
Files folder imagescripts (1 file)
Files folder imagesrc (3 files, 2 directories)
Files folder imagetests (5 files, 3 directories)
Accessible without login Plain text file .editorconfig Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE.md Lic. License text
Accessible without login Plain text file package.xml Data Auxiliary data
Accessible without login Plain text file phpcs.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  test  
File Role Description
Files folder imagedata (2 files)

  Files folder image Files  /  test  /  data  
File Role Description
  Accessible without login Plain text file test.mp4 Data testing video file
  Accessible without login Plain text file test.wav Data testing audio file

  Files folder image Files  /  .circleci  
File Role Description
  Accessible without login Plain text file config.yml Data Auxiliary data

  Files folder image Files  /  scripts  
File Role Description
  Accessible without login Plain text file rimraf.php Aux. Auxiliary script

  Files folder image Files  /  src  
File Role Description
Files folder imageAdapters (3 files)
Files folder imageOutputProviders (5 files)
  Plain text file AnimatedGif.php Class Class source
  Plain text file Frame.php Class Class source
  Plain text file Movie.php Class Class source

  Files folder image Files  /  src  /  Adapters  
File Role Description
  Plain text file FFMpegAnimatedGif.php Class Class source
  Plain text file FFMpegFrame.php Class Class source
  Plain text file FFMpegMovie.php Class Class source

  Files folder image Files  /  src  /  OutputProviders  
File Role Description
  Plain text file AbstractProvider.php Class Class source
  Plain text file FFMpegProvider.php Class Class source
  Plain text file FFProbeProvider.php Class Class source
  Plain text file OutputProvider.php Class Class source
  Plain text file StringProvider.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imageAdapters (3 files)
Files folder imagedata (1 file)
Files folder imageOutputProviders (2 files)
  Plain text file AnimatedGifTest.php Class Class source
  Accessible without login Plain text file bootstrap.php Aux. Auxiliary script
  Plain text file FrameTest.php Class Class source
  Plain text file MovieTest.php Class Class source
  Accessible without login Plain text file phpunit.xml Data Auxiliary data

  Files folder image Files  /  tests  /  Adapters  
File Role Description
  Plain text file FFMpegAnimatedGifTest.php Class Class source
  Plain text file FFMpegFrameTest.php Class Class source
  Plain text file FFMpegMovieTest.php Class Class source

  Files folder image Files  /  tests  /  data  
File Role Description
  Accessible without login Plain text file test1.txt Doc. Documentation

  Files folder image Files  /  tests  /  OutputProviders  
File Role Description
  Plain text file FFMpegProviderTest.php Class Class source
  Plain text file FFProbeProviderTest.php Class Class source

Install with Composer Install with Composer - Download Download all files: ffmpeg-php.tar.gz ffmpeg-php.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.