Php processing video (ffmpeg)

php conversion processing video or video, need to install ffmpeg. (Local video, remote video url address can handle)

macbook install ffmpeg using brew install install (very slow)

Use apt install ubuntu installation (soon)

php project with composer install ffmpeg package

composer install php-ffmpeg/php-ffmpeg

Then you can write code:

<?php
//phpinfo();die;
require 'vendor/autoload.php';
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2020/3/29
 * Time: 12:10
 */
$config = array(
   'ffmpeg.binaries' => '/usr/local/bin/ffmpeg',
   'ffprobe.binaries' => '/usr/local/bin/ffprobe', //这里是电脑或服务器上所安装的位置
);
$ffmpeg = FFMpeg\FFMpeg::create($config);
$video = $ffmpeg->open('https://stream7.iqilu.com/10339/upload_transcode/202002/18/20200218114723HDu3hhxqIT.mp4');
$video
   ->filters()
   ->resize(new FFMpeg\Coordinate\Dimension(320, 240))
   ->synchronize();
$video
   ->frame(FFMpeg\Coordinate\TimeCode::fromSeconds(10))
   ->save('frame.jpg');

May be error on the server, note the directory permissions

 

Published 29 original articles · won praise 5 · Views 7975

Guess you like

Origin blog.csdn.net/qq_25194685/article/details/105197265