I want to upload files and convert them to thumbnails.
My code is:
require 'streamio-ffmpeg' module CarrierWave module FFMPEG module ClassMethods def resample(bitrate) process :resample => bitrate end def gen_video_thumb(width, height) process :gen_video_thumb => [width, height] end end
My bootloader has
version :thumb do process :resize_to_fill => [100, 70], :if=> :image? process :gen_video_thumb => [100, 70], :if=> :video? do process :convert => 'png' end end
and functions.
protected def image?(new_file) ::FFMPEG::Movie.new(new_file.file.path).frame_rate == nil end def video?(new_file) ::FFMPEG::Movie.new(new_file.file.path).frame_rate != nil end
But the problem is that the video is uploaded, thubmail video is generated very well. But it does not have the png extension. If I download the mp4 file, its thumbnail also has the mp4 extension. but this image can be viewed in a browser.
How to fix the extension problem? Can anyone point out a problem in the code?
source share