Changes between Version 6 and Version 7 of PHP


Ignore:
Timestamp:
Aug 12, 2014, 10:28:35 AM (3 years ago)
Author:
slhck
Comment:

reduce info about outdated ffmpeg-php, promote PHP-FFMpeg

Legend:

Unmodified
Added
Removed
Modified
  • PHP

    v6 v7  
    6464The [http://ffmpeg.org/ffmpeg.html#Main-options "-y" option] is used to auto-overwrite the output file (output.avi) without asking for yes/no confirmation. If you need the opposite scenario, to auto-cancel the entire process if the output file already exists, then use "-n" option instead. 
    6565 
    66 = Conclusion = 
     66= Wrapper Libraries = 
    6767 
    68 Running ffmpeg command-line tool in the background is easy when you know all these little things, mentioned above. Many people have decided to use a PHP's extension named [http://ffmpeg-php.sourceforge.net/ ffmpeg-php] that "adds an easy to use, object-oriented API for accessing and retrieving information from video and audio files" (quoted from their web site). The fact that this extension is not developed since 2007 (and requires "ffmpeg-0.4.9_pre1 or higher") means that you are restricted to use a very old version of ffmpeg, without possibility to update it to the latest version. Since a lot of changes/improvements are being made, inside ffmpeg's code, every day, it makes ffmpeg-php incompatible with the latest ffmpeg. 
     68Some PHP libraries allow wrapping ffmpeg calls into PHP objects, and give you a nice syntax to work with if you don't like to use the command line. One of these is the actively maintained [https://github.com/PHP-FFMpeg/PHP-FFMpeg/ PHP-FFMpeg]. It only requires you to [http://ffmpeg.org/download.html download] a recent `ffmpeg` and `ffprobe` build apart from installing the PHP components. Then you can run PHP code like this: 
     69{{{ 
     70$ffmpeg = FFMpeg\FFMpeg::create(); 
     71$video = $ffmpeg->open('video.mpg'); 
     72$video 
     73    ->filters() 
     74    ->resize(new FFMpeg\Coordinate\Dimension(320, 240)) 
     75    ->synchronize(); 
     76$video 
     77    ->save(new FFMpeg\Format\Video\X264(), 'export-x264.mp4') 
     78}}} 
    6979 
    70 The thing is, most of the people don't really need this kind of API to accomplish usual tasks like generating a thumbnail, resizing a video, converting videos to another formats, etc. All of that can also be achieved using FFmpeg's command-line tools (ffmpeg and ffprobe mostly). Also, using ffmpeg-php implies that you need some kind of real-time processing of your audio/video media, which is an overkill for web scripts in terms of execution time and bored people, waiting for the web page to complete the loading. 
     80Of course you need to take care of running such a task in the background. Libraries such as [http://php.net/manual/de/gearmanclient.addtaskbackground.php GearmanClient] facilitate this. 
    7181 
    72 In the end, the choice is yours. If you really need to use ffmpeg-php, you'll be restricted to the old version of ffmpeg which doesn't have a lot of cool things and bug fixes implemented lately. Not to mention you will have a hard time getting the support for it. And if you decide to change your web application model a little bit and introduce all the changes mentioned in this article, you'll be able to run any version of ffmpeg command-line tool, from within your web scripts, with minor modifications of command-line options, depending on which version of ffmpeg you are using. Of course, using the latest (and greatest) version of ffmpeg provides you with all the benefits of new features and bug fixes. 
     82'''Note:''' [http://ffmpeg-php.sourceforge.net/ ffmpeg-php] is an extension that is not developed since 2007 (and requires "ffmpeg-0.4.9_pre1 or higher"), which means that you are restricted to use a very old version of ffmpeg, without possibility to update it to the latest version. Since a lot of changes/improvements are being made, inside ffmpeg's code, every day, it makes ffmpeg-php incompatible with the latest ffmpeg.