kopia lustrzana https://github.com/pixelfed/pixelfed
				
				
				
			Update VideoThumbnail job, dispatch HLS job when applicable
							rodzic
							
								
									3f292459ff
								
							
						
					
					
						commit
						f0ba2dfc69
					
				|  | @ -16,13 +16,46 @@ use App\Jobs\MediaPipeline\MediaStoragePipeline; | ||||||
| use App\Util\Media\Blurhash; | use App\Util\Media\Blurhash; | ||||||
| use App\Services\MediaService; | use App\Services\MediaService; | ||||||
| use App\Services\StatusService; | use App\Services\StatusService; | ||||||
|  | use Illuminate\Queue\Middleware\WithoutOverlapping; | ||||||
|  | use Illuminate\Contracts\Queue\ShouldBeUniqueUntilProcessing; | ||||||
| 
 | 
 | ||||||
| class VideoThumbnail implements ShouldQueue | class VideoThumbnail implements ShouldQueue, ShouldBeUniqueUntilProcessing | ||||||
| { | { | ||||||
|     use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; |     use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; | ||||||
| 
 | 
 | ||||||
|     protected $media; |     protected $media; | ||||||
| 
 | 
 | ||||||
|  |     public $timeout = 900; | ||||||
|  |     public $tries = 3; | ||||||
|  |     public $maxExceptions = 1; | ||||||
|  |     public $failOnTimeout = true; | ||||||
|  |     public $deleteWhenMissingModels = true; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * The number of seconds after which the job's unique lock will be released. | ||||||
|  |      * | ||||||
|  |      * @var int | ||||||
|  |      */ | ||||||
|  |     public $uniqueFor = 3600; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Get the unique ID for the job. | ||||||
|  |      */ | ||||||
|  |     public function uniqueId(): string | ||||||
|  |     { | ||||||
|  |         return 'media:video-thumb:id-' . $this->media->id; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Get the middleware the job should pass through. | ||||||
|  |      * | ||||||
|  |      * @return array<int, object> | ||||||
|  |      */ | ||||||
|  |     public function middleware(): array | ||||||
|  |     { | ||||||
|  |         return [(new WithoutOverlapping("media:video-thumb:id-{$this->media->id}"))->shared()->dontRelease()]; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     /** |     /** | ||||||
|      * Create a new job instance. |      * Create a new job instance. | ||||||
|      * |      * | ||||||
|  | @ -54,7 +87,7 @@ class VideoThumbnail implements ShouldQueue | ||||||
|             $path[$i] = $t; |             $path[$i] = $t; | ||||||
|             $save = implode('/', $path); |             $save = implode('/', $path); | ||||||
|             $video = FFMpeg::open($base) |             $video = FFMpeg::open($base) | ||||||
|             ->getFrameFromSeconds(0) |             ->getFrameFromSeconds(1) | ||||||
|             ->export() |             ->export() | ||||||
|             ->toDisk('local') |             ->toDisk('local') | ||||||
|             ->save($save); |             ->save($save); | ||||||
|  | @ -68,6 +101,9 @@ class VideoThumbnail implements ShouldQueue | ||||||
|                 $media->save(); |                 $media->save(); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|  |             if(config('media.hls.enabled')) { | ||||||
|  |                 VideoHlsPipeline::dispatch($media)->onQueue('mmo'); | ||||||
|  |             } | ||||||
|         } catch (Exception $e) { |         } catch (Exception $e) { | ||||||
|              |              | ||||||
|         } |         } | ||||||
|  |  | ||||||
		Ładowanie…
	
		Reference in New Issue
	
	 Daniel Supernault
						Daniel Supernault