From 7edfea0951edff8ac9cdee73e5ab3a3dbfb1e638 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 23 Oct 2023 02:46:56 -0600 Subject: [PATCH] Update hls pipeline, improve version check --- app/Jobs/VideoPipeline/VideoHlsPipeline.php | 15 +++++++++++++++ config/laravel-ffmpeg.php | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/Jobs/VideoPipeline/VideoHlsPipeline.php b/app/Jobs/VideoPipeline/VideoHlsPipeline.php index eb91ed78..37872341 100644 --- a/app/Jobs/VideoPipeline/VideoHlsPipeline.php +++ b/app/Jobs/VideoPipeline/VideoHlsPipeline.php @@ -66,6 +66,21 @@ class VideoHlsPipeline implements ShouldQueue, ShouldBeUniqueUntilProcessing */ public function handle(): void { + $depCheck = Cache::rememberForever('video-pipeline:hls:depcheck', function() { + $bin = config('laravel-ffmpeg.ffmpeg.binaries'); + $output = shell_exec($bin . ' -version'); + if($output && preg_match('/ffmpeg version ([^\s]+)/', $output, $matches)) { + $version = $matches[1]; + return (version_compare($version, config('laravel-ffmpeg.min_hls_version')) >= 0) ? 'ok' : false; + } else { + return false; + } + }); + + if(!$depCheck || $depCheck !== 'ok') { + return; + } + $media = $this->media; $bitrate = (new X264)->setKiloBitrate(config('media.hls.bitrate') ?? 1000); diff --git a/config/laravel-ffmpeg.php b/config/laravel-ffmpeg.php index 43a86658..3133ca72 100644 --- a/config/laravel-ffmpeg.php +++ b/config/laravel-ffmpeg.php @@ -18,5 +18,5 @@ return [ 'temporary_files_encrypted_hls' => env('FFMPEG_TEMPORARY_ENCRYPTED_HLS', env('FFMPEG_TEMPORARY_FILES_ROOT', sys_get_temp_dir())), - 'min_hls_version' => env('FFMPEG_MIN_HLS_VERSION', '4.4.0'), + 'min_hls_version' => env('FFMPEG_MIN_HLS_VERSION', '4.3.0'), ];