Created
March 29, 2011 23:52
-
-
Save audiodude/893593 to your computer and use it in GitHub Desktop.
This file contains 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
module Paperclip | |
# Handles thumbnailing videos that are uploaded. | |
class FlvConvert < Processor | |
def initialize file, options = {}, attachment = nil | |
super | |
@file = file | |
@current_format = File.extname(@file.path) | |
@basename = File.basename(@file.path, @current_format) | |
@make_flv = options[:make_flv] | |
end | |
def make | |
return @file unless @make_flv | |
src = @file | |
dst = Tempfile.new([@basename, '.flv']) | |
dst.binmode | |
begin | |
src = File.expand_path(src.path) | |
dest = File.expand_path(dst.path) | |
cmd = "ffmpeg -y -i #{src} -vcodec flv #{dest}" | |
Paperclip.log(cmd) | |
`#{cmd}` | |
rescue PaperclipCommandLineError => e | |
raise PaperclipError, "There was an error converting to flv: #{@basename}" if @whiny | |
end | |
dst | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment