Currently getting the following error whilst trying to add a watermark to videos
PHP Fatal error: Uncaught Alchemy\BinaryDriver\Exception\ExecutionFailureException: ffmpeg failed to execute command '/usr/bin/ffmpeg' '-y' '-i' 'test.mp4' '-vcodec' 'libx264' '-acodec' 'libmp3lame' '-b:v' '1000k' '-refs' '6' '-coder' '1' '-sc_threshold' '40' '-flags' '+loop' '-me_range' '16' '-subq' '7' '-i_qfactor' '0.71' '-qcomp' '0.6' '-qdiff' '4' '-trellis' '1' '-b:a' '256k' '-ac' '2' '-vf' 'movie=watermark.png [watermark];[in][watermark] overlay=main_w - 50 - overlay_w:25 [out]' '-pass' '1' '-passlogfile' '/tmp/ffmpeg-passes5e4aa564641efqx15l/pass-5e4aa564642e3' '1276404247.mp4'
when doing the following:
if (file_exists('test.mp4')) {
$videoSource = 'test.mp4';
$reqExtension = 'mp4';
$watermark = "watermark.png";
$ffmpeg = FFMpeg\FFMpeg::create();
$video = $ffmpeg->open($videoSource);
$format = new FFMpeg\Format\Video\X264('libmp3lame', 'libx264');
if (!empty($watermark))
{
$video ->filters()
->watermark($watermark, array(
'position' => 'relative',
'top' => 25,
'right' => 50,
));
}
$format
-> setKiloBitrate(1000)
-> setAudioChannels(2)
-> setAudioKiloBitrate(256);
$randomFileName = rand().".$reqExtension";
$saveLocation = getcwd(). '/'.$randomFileName;
$video->save($format, $saveLocation);
}
Have no idea why it's failing though, must be finding the video to even start the process?
EDIT:
Tried to make it simpler and just generate a capture of the video...
$ffmpeg = FFMpeg\FFMpeg::create();
$video = $ffmpeg->open($videoSource);
$frame = $video->frame(FFMpeg\Coordinate\TimeCode::fromSeconds(1));
$frame->save('image.jpg');
Throws this error:
PHP Fatal error: Uncaught Alchemy\BinaryDriver\Exception\ExecutionFailureException: ffmpeg failed to execute command '/usr/bin/ffmpeg' '-y' '-ss' '00:00:01.00' '-i' 'test.mp4' '-vframes' '1' '-f' 'image2' 'image.jpg'
In the console it works and generates the screenshot without error.