Need help using specific FFMPEG-PHP functions or some programming help? Let our experienced technicians help you debug your problem for FREE. Sign up today and post at our online community: FFMPEG-PHP Help Forums
Youâ€™ve probably heard of ffmpeg-php and itâ€™s wide usability mostly in sites that involve with videos such as YouTube or any other similar site. Hereâ€™s a bit of an introduction to it and how to use it.
First thing, youâ€™ve got to check that your web hosting provider actually has ffmpeg & ffmpeg-php extension installed on your account and then you could get started with ffmpeg. You can check if itâ€™s installed by creating a PHP script and executing the following code:
extension_loaded('ffmpeg') or die("ffmpeg extension not loaded");
If you get â€œffmpeg extension not loadedâ€ then your web hosting provider does not have ffmpeg installed, if you get nothing, then youâ€™re one the good track!
ffmpeg-php is very simple to learn, what it is pretty much is an interface that works with the ffmpeg software to make it easier for PHP developers to access.
Like any object in PHP, youâ€™ll have to start with creating a new instance of it. You can do that by using the following line:
$ffmpegInstance = new ffmpeg_movie(â€œ/path/to/movie/â€);
Now that youâ€™ve had that, you can use that instance to use the many features of ffmpeg-php which are from knowing the duration of the movie/audio in seconds to retrieving the bitrate of the movie/audio file.
Once here, itâ€™s pretty much like object oriented programming, ex:
$ffmpegInstance->getDuration(); // Gets the duration in secs.
$ffmpegInstance->getVideoCodec(); // What type of compression/codec used
This can be very helpful when coding anything that has to do with uploading videos because you can know a lot of information about it. Iâ€™ve made a small script that pretty much retrieves all the information that ffmpeg can get right here