| 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. |
| | 68 | Some 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 | }}} |
| 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. |