Reputation: 443
The video uploaded does not maintain aspect ratio. In the readme (paperclip av-transcoder) it says, " '!' - Keep the same aspect of the image/video, but with the passed dimension." I have also tried the other options(<>#!) and none of them effect the size of the video.
My goal is to be able to be able to have the video returned in a square (while maintaining the aspect ratio). Cropping from the center would be ideal, as well.
Any help would be greatly appreciated. I included my code below.
class Video < Post
Paperclip.interpolates :id do |attachment, style|
attachment.instance.id
end
#basename/extension is paperclip interpolation from attachment, can write own interpolations as needed
# have to link /usr/local/bin to the linuxbrew version of ffmpeg
has_attached_file :video, path: "/posts/videos/:id/:style.:extension",
:styles => {
:square => {:geometry => "500x500!", :format => 'mp4', :streaming => true }
},
:processors => [:transcoder]
validates_attachment :video, :presence => true,
:content_type => { content_type: ["video/mp4", "video/mov", "video/mpeg","video/mpeg4", "video/quicktime"] }
def video_url
video = self.video
if video.present?
return video.url(:square)
end
end
end
Upvotes: 1
Views: 242
Reputation: 7311
It seems to be an open issue, the gem does not forward parameters to av
https://github.com/ruby-av/paperclip-av-transcoder/issues/31
you can use the old deprecated ffmpeg transcoder paperclip-ffmpeg,
it's ugly but it's the only thing that works for now, I asked if there's a workaround https://github.com/ruby-av/paperclip-av-transcoder/issues/32, so we'll see...
Upvotes: 1