I have created a code on Laravel to add watermark to my video with ffmpeg package. This function is working perfectly in when working with controller.
Due to time consuming task I move the code to Laravel queue system and it successfully dispatch to queues table. but when I run php artisan queue:work the code getting error like
Alchemy\BinaryDriver\Exception\ExecutionFailureException: ffmpeg failed to execute command '/usr/bin/ffmpeg' '-y' '-i' '/home/forge/demosite/public/frontend/video/1276841041584344642.mp4' '-threads' '12' '-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' '-pass' '1' '-passlogfile' '/tmp/ffmpeg-passes5e6f2f04cec372bg0z/pass-5e6f2f04cecc2' '/home/forge/demosite/frontend/posts/video/org-post/n-w-post-video-org/17957037231584344836.mp4' in /home/forge/demosite/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessRunner.php:10
In many references I can see that this issue related to permission issue of public folder. so I give 777 permission to public folder and it will not working...
Working Code..
$ffmpeg = FFMpeg\FFMpeg::create([
'ffmpeg.binaries' => '/usr/bin/ffmpeg',
'ffprobe.binaries' => '/usr/bin/ffprobe' ,
'timeout' => 3600, // The timeout for the underlying process
'ffmpeg.threads' => 12, // The number of threads that FFMpeg should use
]);
$video = $ffmpeg->open($this->file);
$random = rand().''.time();
$randomFileName = $random . ".$this->extension";
/*-------------------------------original video----------------------------------------------*/
$format = new FFMpeg\Format\Video\X264('libmp3lame', 'libx264');
$format->setKiloBitrate(1000)->setAudioChannels(2)->setAudioKiloBitrate(256);
// $saveLocation = getcwd() . '/frontend/video/uploads/n_w_org_vd/' . $randomFileName;
$saveLocation = getcwd() . '/frontend/posts/video/org-post/n-w-post-video-org/' . $randomFileName;
$video->save($format, $saveLocation);
$filepath = 'frontend/posts/video/org-post/n-w-post-video-org/' . $randomFileName;
Storage::put($filepath, file_get_contents($saveLocation),'public');