1 回答
TA贡献1828条经验 获得超4个赞
$descriptors = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
2 => array("file", "C:/path/error-output.txt", "a")
);
$command = 'ffmpeg -i INPUT.mp4 -ss 00:00:10 -t 120 -c:v png -f image2pipe -compression_level 0 -';
$ffmpeg = proc_open($command, $descriptors, $pipes);
if (!is_resource($ffmpeg))
{
die('Could not run ffmpeg');
}
$k = 0;
$buff = '';
$blend = 0;
while (!feof($pipes[1]))
{
$buff .= fread($pipes[1], 50000);
$pos = strpos($buff, chr(137).'PNG', 1);
if ($pos !== false)
{
$frame = substr($buff, 0, $pos);
$buff = substr($buff, $pos);
handleFrame($frame, $k);
$k++;
}
}
handleFrame($buff, $k);
fclose($pipes[0]);
fclose($pipes[1]);
function handleFrame(&$str, $num)
{
$im = imagecreatefromstring($str);
...
}
- 1 回答
- 0 关注
- 79 浏览
添加回答
举报