Class: SmartVideoPosterExtractionWorker
- Inherits:
-
Object
- Object
- SmartVideoPosterExtractionWorker
show all
- Includes:
- Sidekiq::Worker, Workers::StatusBroadcastable
- Defined in:
- app/workers/smart_video_poster_extraction_worker.rb
Instance Attribute Summary
#broadcast_status_updates
Instance Method Summary
collapse
#at, #store, #total
Instance Method Details
12
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
|
# File 'app/workers/smart_video_poster_extraction_worker.rb', line 12
def perform(video_id, options = {}, redirect_to = nil)
video = Video.find(video_id)
min_start = (options['min_start'] || 5.0).to_f
threshold = (options['threshold'] || 0.40).to_f
fallback = (options['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.
at(100, 'Smart poster extraction completed successfully!')
rescue VideoPosterExtractionService::ExtractionError => e
store error_message: e.message
raise
end
|