To do that, we are going to use the gem streamio-ffmpeg
to run our FFMPEG commands from a rails library
require 'streamio-ffmpeg'
module ControllerVideoProcessor
def thumbnail path, second
movie = FFMPEG::Movie.new(path)
return movie.screenshot("some/temporal/path/screenshot.jpg", :seek_time => second)
end
end
As we can see, we have a function, which receives the path to the input video, and the second we want to get the thumbnail from. It is as simple as running the “screenshot” command of the streamio library, and that’s it. It will return a FFMPEG object, containing the image and it’s attributes.
Also if you use carrierwave
gem for uploading your files you can use carrierwave plugin gem 'video_thumbnailer'
example
class VideoUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick
include VideoThumbnailer
storage :file
version :thumb do
process generate_thumb:[{quality:5, time_frame: '00:0:01', file_extension: 'jpeg'}]
def full_filename for_file
png_name for_file, version_name, "jpeg"
end
end
def png_name for_file, version_name, format
%Q{#{version_name}_#{for_file.chomp(File.extname(for_file))}.#{format}}
end
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
def extension_white_list
%w( mp4 jpg jpeg gif png )
end
end
Reference and more information about it you can find it here
http://ron-on-rails.tumblr.com/post/33720054493/getting-thumbnails-of-a-video-using-ffmpeg-and
https://github.com/teenacmathew/Video-Thumbnailer