ffmpeg-php, manipulate videos and sounds with PHP

So far, I had only dabbled in image manipulation with PHP. Using videos with this language seemed infeasible to me. And yet ...

 
ffmpeg-php is a PHP extension that allows you to add an API dedicated to video and sound manipulation and control. This high-level API provides access to simple and understandable functions to extract information from files.

These methods make it possible to recover in particular “frames” such as images. these in turn can be manipulated using the GD library.
ffmpeg-php is just perfect for create thumbnails from video, or to automate the extraction of metadata (duration, bitrate,…).
It is even possible to create Animated gifs by extracting several frames.

$ ffmpeg = 'encoderffmpeg'; // put the relative path to the ffmpeg.exe file $ second = 15; // specify the time to get the screen shot at (can easily be randomly generated) $ image = 'thumbnails / sample.jpg'; // define the output file // finally assemble the command and execute it $ command = "$ ffmpeg -itsoffset - $ second -i $ video -vcodec mjpeg -vframes 1 -an -f rawvideo -s 150 × 84 $ image"; exec ($ command);

Here are some examples of methods:

getDuration (). "getFrameCount:". $ ffmpegInstance-> getFrameCount (). "getFrameRate:". $ ffmpegInstance-> getFrameRate (). "getFilename:". $ ffmpegInstance-> getFilename (). "getComment:". $ ffmpegInstance-> getComment (). "getTitle:". $ ffmpegInstance-> getTitle (). "getAuthor:". $ ffmpegInstance-> getAuthor (). "getCopyright:". $ ffmpegInstance-> getCopyright (). "getArtist:". $ ffmpegInstance-> getArtist (). "getGenre:". $ ffmpegInstance-> getGenre (). "getTrackNumber:". $ ffmpegInstance-> getTrackNumber (). "getYear:". $ ffmpegInstance-> getYear (). "getFrameHeight:". $ ffmpegInstance-> getFrameHeight (). "getFrameWidth:". $ ffmpegInstance-> getFrameWidth (). "getPixelFormat:". $ ffmpegInstance-> getPixelFormat (). "getBitRate:". $ ffmpegInstance-> getBitRate (). "getVideoBitRate:". $ ffmpegInstance-> getVideoBitRate (). "getAudioBitRate:". $ ffmpegInstance-> getAudioBitRate (). "getAudioSampleRate:". $ ffmpegInstance-> getAudioSampleRate (). "getVideoCodec:". $ ffmpegInstance-> getVideoCodec (). "getAudioCodec:". $ ffmpegInstance-> getAudioCodec (). "getAudioChannels:". $ ffmpegInstance-> getAudioChannels (). "hasAudio:". $ ffmpegInstance-> hasAudio (); ?> 

ffmpeg-php supports a large number of formats (mpeg, avi, wmv, mov, mp3, wma,…).

As an example, Vimeo.com uses ffmpeg-php to create its thumbnails. we can therefore think that this API is solid.

Download ffmpeg-php

Also read