Created
November 19, 2012 23:08
-
-
Save phillipoertel/4114704 to your computer and use it in GitHub Desktop.
Dragonfly FTW
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'transcoder/base' | |
require 'transcoder/video' | |
class Content < ActiveRecord::Base | |
image_accessor :cover_image do | |
after_assign :make_preview_video | |
end | |
image_accessor :preview_video | |
attr_accessible :name, :content, :cover_image | |
def thumbnail | |
cover_image.thumb("100x100").jpg | |
end | |
def preview | |
cover_image.thumb("555x>").jpg | |
end | |
def mobile_preview | |
cover_image.thumb("600x").jpg | |
end | |
def make_preview_video | |
return unless cover_image.ext == "mov" | |
out_file = File.new("/tmp/#{rand}.mp4", "a") | |
Transcoder::Video.new.transcode(cover_image.path, out_file.path) | |
self.preview_video = out_file | |
self.save! | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment