Browse Source

Update hls pipeline, improve version check

Daniel Supernault 1 year ago
parent
commit
7edfea0951
2 changed files with 16 additions and 1 deletions
  1. 15 0
      app/Jobs/VideoPipeline/VideoHlsPipeline.php
  2. 1 1
      config/laravel-ffmpeg.php

+ 15 - 0
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);

+ 1 - 1
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'),
 ];