Open bbozo opened 9 years ago
It's possible using FFMPEG but no current support in Ruby AV gem.
I have been trying unsuccessfully to create an animated GIF from a video using FFMPEG settings. I have used the following settings so far. Any assistance would be much appreciated!
class CustomGif < ActiveRecord::Base
has_attached_file :gif, styles: {
original: {
format: "gif",
convert_options: {
output: {
t: "00:00:6.000"
}
}
}
}, :processors => [:transcoder]
validates_attachment_content_type :gif, content_type: /\Avideo\/.*\Z/
end
When I run custom_gif = CustomGif.new(gif: params['video']), I receive the following output:
[AV] Running command: ffmpeg -ss 3 -i "/var/folders/7g/9142rygs6bngwl84c7bh4d6c0000gn/T/ac80cf3de4643bff7fec3a00dc9196d620160821-29940-1wvj48r.MOV" -f image2 -vframes 1 -t 00:00:6.000 -y "/var/folders/7g/9142rygs6bngwl84c7bh4d6c0000gn/T/ac80cf3de4643bff7fec3a00dc9196d620160821-29940-1wvj48r20160821-29940-1bfutyd.gif"
[paperclip] [transcoder] Successfully transcoded ac80cf3de4643bff7fec3a00dc9196d620160821-29940-1wvj48r to #<File:0x007f91da570468>
=> #<CustomGif:0x007f91da0e95c0
id: nil,
created_at: nil,
updated_at: nil,
gif_file_name: "capturedvideo.MOV",
gif_content_type: "video/quicktime",
gif_file_size: 15202,
gif_updated_at: Sun, 21 Aug 2016 21:50:55 EDT -04:00>
And, when running custom_gif.save, I receive the following error:
Command :: file -b --mime '/var/folders/7g/9142rygs6bngwl84c7bh4d6c0000gn/T/ac80cf3de4643bff7fec3a00dc9196d620160821-29940-dxocga.MOV'
[paperclip] Content Type Spoof: Filename capturedvideo.MOV (video/quicktime from Headers, ["video/quicktime"] from Extension), content type discovered from file command: image/jpeg. See documentation to allow this combination.
(2.2ms) ROLLBACK
=> false
I'm not sure if this is a feature request or it belongs to SO :) Is it possible to create an animated GIF from videos?