1 year agoby Manzar Hussain

Video upload with compress using ffmpeg package

Hii, I am working on video upload using ffmpeg package in laravel. for compressing video i am using queue worker. for this i am using two table jobs, failed-jobs.

public function store(StoreVideoRequest $request)
		$path = str_random(16) . '.' . $request->video->getClientOriginalExtension();
		$request->video->storeAs('public', $path);

		$video = Video::create([
				'disk'          => 'public',
				'original_name' => $request->video->getClientOriginalName(),
				'path'          => $path,
				'title'         => $request->title,


		return redirect('/')
						'Your video will be available shortly after we process it'

namespace App\Jobs;

use FFMpeg; use App\Video; use Carbon\Carbon; use FFMpeg\Coordinate\Dimension; use FFMpeg\Format\Video\X264; use Illuminate\Bus\Queueable; use Illuminate\Queue\SerializesModels; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable;

class ConvertVideoForStreaming implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

public $video;

 * Create a new job instance.
 * @param Video $video
public function __construct(Video $video)
		$this->video = $video;

 * Execute the job.
 * @return void
public function handle()
		// create a video format...
		$lowBitrateFormat = (new X264('libmp3lame', 'libx264'))->setKiloBitrate(500);

		$converted_name = $this->getCleanFileName($this->video->path);

		// open the uploaded video from the right disk...

				// add the 'resize' filter...
				->addFilter(function ($filters) {
						$filters->resize(new Dimension(960, 540));

				// call the 'export' method...

				// tell the MediaExporter to which disk and in which format we want to export...

				// call the 'save' method with a filename...

		// update the database so we know the convertion is done!
				'converted_for_streaming_at' => Carbon::now(),
				'processed' => true,
				'stream_path' => $converted_name

private function getCleanFileName($filename){
		return preg_replace('/\\.[^.\\s]{3,4}$/', '', $filename) . '.mp4';


when i run this command which is mentioned in below php artisan queue:work --tries=3 --timeout=8600 2019-04-15 11:23:55 Processing: App\Jobs\ConvertVideoForStreaming 2019-04-15 11:23:57 Processing: App\Jobs\ConvertVideoForStreaming 2019-04-15 11:23:57 Processing: App\Jobs\ConvertVideoForStreaming 2019-04-15 11:23:57 Failed: App\Jobs\ConvertVideoForStreaming

Please anyone solve my issue


Shailesh Jakhaniya replied 1 year ago



Please remove --timeout or increase value of timeout argument from queue command.


Ask Question
Most Visited