No worries. Hope you get better soon :-)
Redhames, you seem pretty experienced with Paperclip. Could you have a
look at this: http://groups.google.com/group/paperclip-plugin/browse_thread/thread/49806e3ca43b91de
I think the solution is easy, but I just can't wrap my head around it
On Oct 3, 12:52 am, radhames brito <rbri...@gmail.com> wrote:
> Sorry that i havent worked the example but i have been feeling a bit
> sick, i will upload it as soon as i feel better.
>
> 2010/10/2, Christian Fazzini <christian.fazz...@gmail.com>:
>
>
>
> > Ok I've gotten it to work. For everyone that is interested or devs who
> > stumble across:
>
> > Model class:
> > has_attached_file :media,
> > :styles => { :small => '94x58#',
> > :medium => '188x116#',
> > :large => '376x232#' },
> > :url => '/assets/artists/:artist_id/
> > videos/:id/:style.:extension',
> > :path => ':rails_root/public/assets/
> > artists/:artist_id/videos/:id/:style.:extension',
> > :processors => [:video_thumbnail]
>
> > ------------------
> > /lib/paperclip_processors/video_thumbnail.rb:
>
> > module Paperclip
> > class VideoThumbnail < Processor
>
> > attr_accessor :geometry, :whiny
>
> > def initialize(file, options = {}, attachment = nil)
> > super
> > @file = file
>
> > unless options[:geometry].nil? || (@geometry =
> > Geometry.parse(options[:geometry])).nil?
> > @geometry.width = (@geometry.width / 2.0).floor * 2.0
> > @geometry.height = (@geometry.height / 2.0).floor * 2.0
> > @geometry.modifier = ''
> > end
> > @whiny = options[:whiny].nil? ? true : options[:whiny]
> > @basename = File.basename(file.path, File.extname(file.path))
> > end
>
> > def make
>
> > dst = Tempfile.new([ @basename, 'jpg' ].compact.join("."))
> > dst.binmode
>
> > cmd = "ffmpeg -itsoffset -4 -i #...@file.path} -y -vcodec mjpeg -
> > vframes 1 -an -f rawvideo -s #{geometry.to_s}
> > #{File.expand_path(dst.path)}"
>
> > begin
> > success = Paperclip.run(cmd)
> > rescue PaperclipCommandLineError
> > raise PaperclipError, "There was an error processing the
> > thumbnail for #{@basename}" if whiny
> > end
> > dst
> > end
> > end
> > end
>
> > ------------------
> > /config/initializers/paperclip.rb
>
> > Paperclip.interpolates :artist_id do |attachment, style|
> > attachment.instance.artist.id
> > end
>
> > # Ensures that files have the proper extensions. i.e. thumbnails with
> > jpgs
> > Paperclip.interpolates :extension do |attachment, style_name|
> > case attachment.instance.class.to_s
> > when "Video"
> > if style_name.to_s == 'original'
> > 'flv'
> > else
> > 'jpg'
> > end
> > when "Audio"
> > if style_name.to_s == 'original'
> > 'mp3'
> > end
> > else
> > File.extname(attachment.original_filename).gsub(/^\.+/, "")
> > end
> > end
>
> > # Path to ffmpeg
> > Paperclip.options[:command_path] = "/opt/local/bin"
>
> > --------------------
>
> > Hope this helps somebody
>
> > On Oct 2, 4:44 pm, Christian Fazzini <christian.fazz...@gmail.com>
> > wrote:
> >> I guess what I am asking is. If my app allows users to upload content,
> >> which uses ffmpeg, and takes a while decode audio/video, will this
> >> trigger the workers at heroku automatically? Therefore, I don't need
> >> to use a workling/startling?
>
> >> Or do I still need to implement a startling/workling for this to
> >> prevent the app from 'hanging'?
>
> >> On Oct 2, 4:22 pm, Christian Fazzini <christian.fazz...@gmail.com>
> >> wrote:
>
> >> > Hi Radhames, ok, then I will definitely need to use a workling and a
> >> > startling for this. Since my users are the ones uploading. By the way,
> >> > in Heroku hosting (http://heroku.com/pricing), a workling would be a
> >> > worker right? So whenever I implement a workling in my app, it would
> >> > trigger the workling in Heroku? Am I understanding this right?
>
> >> > Let me know when you get your example up. Am very eager to have a look
> >> > at it
>
> >> > On Oct 2, 6:05 am, radhames brito <rbri...@gmail.com> wrote:
>
> >> > > On Fri, Oct 1, 2010 at 5:29 PM, Christian Fazzini <
>
> >> > > christian.fazz...@gmail.com> wrote:
> >> > > > Radhames, what do you think? I am guessing the article at
>
> >> > > >http://www.google.com/url?sa=D&q=http://thewebfellas.com/blog/2009/2/...
> >> > > > assumes that the uploader would be the admin, so there is no need
> >> > > > for
> >> > > > startling or a workling?
>
> >> > > > But if the app allows users to upload, then a startling/workling
> >> > > > approach is needed since ffmpeg takes a while to process uploaded
> >> > > > files?
>
> >> > > Yes that is right, if only the admin will upload files there is no
> >> > > need for
> >> > > starling/working.
>
> >> > > I dont see anything wrong in doing things with a method in the model
> >> > > like i
> >> > > told you the first time.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Ruby on Rails: Talk" group.
> > To post to this group, send email to rubyonrails-talk@googlegroups.com.
> > To unsubscribe from this group, send email to
> > rubyonrails-talk+unsubscribe@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/rubyonrails-talk?hl=en.
>
> --
> Enviado desde mi dispositivo móvil
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment