I'm tring to feed FFMpeg whith an image sequence through PHP in order to get a video out of it. I'm using this shell command to read from a text file the image filenames:
cat $(cat " . $image-list-file . ") | ffmpeg -f image2pipe ...
I would like to output to the pipe prom php, maybe after modifying the images through imagemagik or gd.
How can I do this in PHP?
Edit:
SOLUTION
Using a combination of proc_open and buffer did the job. Here's a working test script using some GD generated pictures.
<?php
set_time_limit(0);
$descriptors = array(
0 => array("pipe", "r")
);
$command = "ffmpeg -f image2pipe -pix_fmt rgb24 -r 30 -c:v png -i - ".
"-r 30 -vcodec libx264 -pix_fmt yuv420p ".
"-y test.mp4";
$ffmpeg = proc_open($command, $descriptors, $pipes);
if (is_resource($ffmpeg)){
for ($i = 0; $i < 180; $i++) {
$im = @imagecreate(300, 300) or die("GD error");
$background_color = imagecolorallocate($im, 0, 0, 0);
$line_color = imagecolorallocate($im, 233, 14, 91);
$x = rand(0, 300);
imageline ($im, $x, 0, $x, 300, $line_color);
ob_start();
imagepng($im);
fwrite($pipes[0], ob_get_clean());
imagedestroy($im);
}
fclose($pipes[0]);
}