I have checked the questions asked before but did not find the solution I need. Here is the question list, Laravel & Laravel Forge returns “MaxAttemptsExceededException:” even when tries are set at 1, Asynchronous Laravel Jobs, Laravel job overwriting other jobs?
What I'm trying is to convert all the videos(Maybe in MBs or GBs) with the help of FFMPEG using the Laravel jobs on the button click event.
Without using the Job, the code is working properly.
Here is the code Sample of Controller,
public function uploadSelected(Request $request)
{
$input = $request->all();
$ids = explode(',', $input['ids']);
$this->dispatch(new FTPConverting($ids, 0));
return redirect()->to('videos/ftp-videos');
}
And in the job, the handle is like this
public function handle()
{
foreach ($this->videos as $id) {
if (file_exists(storage_path('app/public/temp_videos/' . $id))) {
copy(storage_path('app/public/temp_videos/' . $id), storage_path('app/public/temp_videos/uploaded/' . $id));
$video = TempVideo::create([
'original_name' => $id,
'disk' => 'public',
'video_path' => 'temp_videos/uploaded/' . $id
]);
$this->video_without_watermark($video->video_path, $video->id, $video->disk);
$this->streaming_without_watermark($video->video_path, $video->id, $video->disk);
if ($video->upload_status == 'Converted') {
unlink(storage_path('app/public/temp_videos/' . $id));
unlink(storage_path('app/public/temp_videos/uploaded/' . $id));
}
}
}
}
In the functions, video_without_watermark
and streaming_without_watermark
, there is the logic to convert files with the help of FFMPEG.
Please let me know what I'm doing wrong or possible solution to this.
Edit The log of the failed job table
Illuminate\Queue\MaxAttemptsExceededException: App\Jobs\FTPConverting has been attempted too many times or run too long. The job may have previously timed out. in /var/www/html/screwbox/vendor/laravel/framework/src/Illuminate/Queue/Worker.php:401