Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video Skewed (does not maintain aspect ratio) #31

Open
zreitano opened this issue Aug 26, 2015 · 4 comments
Open

Video Skewed (does not maintain aspect ratio) #31

zreitano opened this issue Aug 26, 2015 · 4 comments

Comments

@zreitano
Copy link

The video uploaded does not maintain aspect ratio. In the readme it says, " '!' - Keep the same aspect of the image/video, but with the passed dimesion."

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.

Here is a link to a skewed 500x500! video of my puppy:
http://s3.amazonaws.com/pivotdevelopment/posts/videos/102/square.mp4?1440617576

Here is the non-skewed version for comparison:
http://s3.amazonaws.com/pivotdevelopment/posts/videos/103/square.mp4?1440617933

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
@attenzione
Copy link
Contributor

Currently it's not possible to crop video at all. You can pad video with #, but not crop.
I have the same problem 2 years ago, so forked paperclip-ffmpeg and made a crop instead of pad. You can try https://github.com/attenzione/paperclip-ffmpeg for now.
But i think this behaviour should be implemented in this gem, too.

@zreitano
Copy link
Author

Thank you! And agreed. But even # doesn't pad the video for me. And it returns the exact same video as 500x500 (without the hashtag).

Any ideas?

 has_attached_file :video,  path: "/posts/videos/:id/:style.:extension",
  :styles => {
    :square => {:geometry => "500x500#", :format => 'mp4', :streaming => true }
  },
  :processors => [:transcoder]

@attenzione
Copy link
Contributor

possibly this gem is not finished yet, for padding.

@wingrunr21
Copy link

The geometry options are actually totally ignored in this version of the gem. You can see here that the various options are extracted but they are never passed to the output. The only thing the output sees is a sanitized geometry setting which causes the backend to resize to the requested height/width.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants