Class: Pruview::VideoImage
- Inherits:
-
Object
- Object
- Pruview::VideoImage
- Defined in:
- lib/pruview/video_image.rb
Class Method Summary collapse
-
.to_jpg(source, target_dir, name) ⇒ Object
this class assumes you have ‘ffmpeg’ installed and in your path.
Class Method Details
.to_jpg(source, target_dir, name) ⇒ Object
this class assumes you have ‘ffmpeg’ installed and in your path
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/pruview/video_image.rb', line 6 def self.to_jpg(source, target_dir, name) raise Pruview::Exceptions::InvalidError, "Invalid source file:: #{source.to_s}" if !File.file?(source) raise Pruview::Exceptions::InvalidError, "Invalid target directory: #{target_dir.to_s}" if !File.directory?(target_dir) raise Pruview::Exceptions::InvalidError, "Video not supported - file extension: " + file_extension(source) if !format_supported?(source) target = File.join(target_dir, name.to_s + '.jpg') video = Video.new(source, target_dir) duration = video.info['duration'] || 10 run(build_command(source, "-ss 00:00:#{duration * 0.1}", 'mjpeg', target), "Unable to get preview image for #{target}") # TODO: analyze image - create better return target end |