Class: SmartVideoPosterExtractionWorker
- Inherits:
-
Object
- Object
- SmartVideoPosterExtractionWorker
- Includes:
- Sidekiq::Job, Workers::StatusBroadcastable
- Defined in:
- app/workers/smart_video_poster_extraction_worker.rb
Overview
Sidekiq worker: smart video poster extraction.
Instance Attribute Summary
Attributes included from Workers::StatusBroadcastable
Instance Method Summary collapse
Methods included from Workers::StatusBroadcastable::Overrides
Instance Method Details
#perform(video_id, options = {}, redirect_to = nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/workers/smart_video_poster_extraction_worker.rb', line 13 def perform(video_id, = {}, redirect_to = nil) video = Video.find(video_id) min_start = (['min_start'] || 5.0).to_f threshold = (['threshold'] || 0.40).to_f fallback = (['fallback'] || 10.0).to_f total(100) at(0, "Starting smart poster detection for #{video.title}") store redirect_to: redirect_to if redirect_to.present? at(25, 'Detecting representative timestamp...') svc = SmartVideoPosterExtractionService.new( video, min_start_seconds: min_start, scene_threshold: threshold, fallback_seconds: fallback ) svc.extract_poster at(100, 'Smart poster extraction completed successfully!') rescue VideoPosterExtractionService::ExtractionError => e store error_message: e. raise end |