media->id; } /** * Get the middleware the job should pass through. * * @return array */ public function middleware(): array { return [(new WithoutOverlapping("media:video-hls:id-{$this->media->id}"))->shared()->dontRelease()]; } /** * Create a new job instance. */ public function __construct($media) { $this->media = $media; } /** * Execute the job. */ public function handle(): void { $media = $this->media; $bitrate = (new X264)->setKiloBitrate(config('media.hls.bitrate') ?? 1000); $mp4 = $media->media_path; $man = str_replace('.mp4', '.m3u8', $mp4); FFMpeg::fromDisk('local') ->open($mp4) ->exportForHLS() ->setSegmentLength(16) ->setKeyFrameInterval(48) ->addFormat($bitrate) ->save($man); $media->hls_path = $man; $media->hls_transcoded_at = now(); $media->save(); MediaService::del($media->status_id); usleep(50000); StatusService::del($media->status_id); return; } }