Sha256: a6cf9b404bde9ee04770fbed2bf40eac2ba8081f128042656d715386227da9ba
Contents?: true
Size: 623 Bytes
Versions: 1
Compression:
Stored size: 623 Bytes
Contents
class RademadeAdmin::VideoService def initialize(file_path) @file_path = file_path end def take_random_screenshot(thumb_path) duration = duration_in_seconds screenshot_time = 1 + (duration.nil? ? 0 : Random.rand(duration - 1)) `ffmpeg -ss #{screenshot_time} -i #{@file_path} -f image2 -vframes 1 #{thumb_path}` end def duration_in_seconds output = `ffmpeg -i #{@file_path} 2>&1 | grep 'Duration' | cut -d ' ' -f 4 | sed s/,//` if output =~ /([\d][\d]):([\d][\d]):([\d][\d]).([\d]+)/ (($1.to_i * 60 + $2.to_i) * 60 + $3.to_i) + ($4.to_i / 100) else nil end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rademade_admin-0.0.1 | app/services/video_service.rb |