Im using a customs processor to run ffmpeg on a video to create a thumbnail. So far so good. Except when I do: cmd = "-i #{@file.path} -f flv -s 320x240 ~/Downloads/foobar/q.flv" success = Paperclip.run(''ffmpeg'', cmd) Console is reporting: ffmpeg ''-i /var/folders/uL/uL0bYOOZEZaJH5E+BmDJVE+++TI/-Tmp-/stream, 16824,1.mpeg -f flv -s 320x240 ~/Downloads/foobar/q.flv'' 2>/dev/null I believe the problem is because Paperclip inserts single quotes when executing ffmpeg. It works if I manually type in console (ie. without single quotes): ffmpeg -i /var/folders/uL/uL0bYOOZEZaJH5E+BmDJVE+++TI/-Tmp-/stream, 16824,1.mpeg -f flv -s 320x240 ~/Downloads/foobar/q.flv How can this be fixed? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Fri, Oct 1, 2010 at 9:38 AM, Christian Fazzini < christian.fazzini-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Im using a customs processor to run ffmpeg on a video to create a > thumbnail. >this here is how i do it def create_thumbnail jpg = File.join(File.dirname(vidfile.path), "#{id}.jpg") File.open(jpg, ''w'') command = <<-end_command ffmpeg -itsoffset -4 -i #{ vidfile.path } -y -vcodec mjpeg -vframes 1 -an -f rawvideo -s 160x120 #{ jpg } end_command command.gsub!(/\s+/, " ") end you have to manually delete the file on destroy since paperclip is only aware of the file i uploaded which it the video file and will not delete the jpg file. File.delete(@vidfile.path.gsub(/flv/,"jpg")) also you have to delete the original, and update the db entry def set_new_filename File.delete(vidfile.path) update_attribute(:vidfile_file_name, "#{id}.flv") update_attribute(:vidfile_thumb, "#{id}.jpg") end i also set everything in an starling worker ConvertWorker.async_convert_video(:file_path => vidfile.path) -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Radhames, do you mind showing what you have for the processor at / lib/paperclip_processors/your_processor_lib.rb ? On Oct 1, 10:13 pm, radhames brito <rbri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Fri, Oct 1, 2010 at 9:38 AM, Christian Fazzini < > > christian.fazz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Im using a customs processor to run ffmpeg on a video to create a > > thumbnail. > > this here is how i do it > > def create_thumbnail > jpg = File.join(File.dirname(vidfile.path), "#{id}.jpg") > File.open(jpg, ''w'') > command = <<-end_command > ffmpeg -itsoffset -4 -i #{ vidfile.path } -y -vcodec mjpeg -vframes 1 > -an -f rawvideo -s 160x120 #{ jpg } > end_command > command.gsub!(/\s+/, " ") > end > > you have to manually delete the file on destroy since paperclip is only > aware of the file i uploaded which it the video file and will not delete the > jpg file. > > File.delete(@vidfile.path.gsub(/flv/,"jpg")) > > also you have to delete the original, and update the db entry > > def set_new_filename > File.delete(vidfile.path) > update_attribute(:vidfile_file_name, "#{id}.flv") > update_attribute(:vidfile_thumb, "#{id}.jpg") > end > > i also set everything in an starling worker > > ConvertWorker.async_convert_video(:file_path => vidfile.path)-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
I tried: module Paperclip class VideoThumbnail < Processor attr_accessor :time_offset, :geometry, :whiny def initialize(file, options = {}, attachment = nil) super @time_offset = options[:time_offset] || ''-4'' 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 puts ''wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww'' puts @file.path cmd = <<-end_command ffmpeg -i #{@file.path} -f flv -s 320x240 ~/Downloads/foobar/ q.flv end_command cmd.gsub!(/\s+/, " ") begin success = Paperclip.run(''ffmpeg'', cmd) rescue PaperclipCommandLineError raise PaperclipError, "There was an error processing the thumbnail for #{@basename}" if whiny end dst end end end console reports: [paperclip] ffmpeg '' ffmpeg -i /var/folders/uL/uL0bYOOZEZaJH5E+BmDJVE++ +TI/-Tmp-/stream,1547,1.mpeg -f flv -s 320x240 ~/Downloads/foobar/ q.flv '' 2>/dev/null On Oct 1, 10:13 pm, radhames brito <rbri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Fri, Oct 1, 2010 at 9:38 AM, Christian Fazzini < > > christian.fazz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Im using a customs processor to run ffmpeg on a video to create a > > thumbnail. > > this here is how i do it > > def create_thumbnail > jpg = File.join(File.dirname(vidfile.path), "#{id}.jpg") > File.open(jpg, ''w'') > command = <<-end_command > ffmpeg -itsoffset -4 -i #{ vidfile.path } -y -vcodec mjpeg -vframes 1 > -an -f rawvideo -s 160x120 #{ jpg } > end_command > command.gsub!(/\s+/, " ") > end > > you have to manually delete the file on destroy since paperclip is only > aware of the file i uploaded which it the video file and will not delete the > jpg file. > > File.delete(@vidfile.path.gsub(/flv/,"jpg")) > > also you have to delete the original, and update the db entry > > def set_new_filename > File.delete(vidfile.path) > update_attribute(:vidfile_file_name, "#{id}.flv") > update_attribute(:vidfile_thumb, "#{id}.jpg") > end > > i also set everything in an starling worker > > ConvertWorker.async_convert_video(:file_path => vidfile.path)-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Check that your Rails app knows the real path to ffmpeg. In at least one of my apps, I have needed to provide a root-relative path to ffmpeg in order to have any conversion work. Walter On Oct 1, 2010, at 1:00 PM, Christian Fazzini wrote:> I tried: > > module Paperclip > class VideoThumbnail < Processor > > attr_accessor :time_offset, :geometry, :whiny > > def initialize(file, options = {}, attachment = nil) > super > @time_offset = options[:time_offset] || ''-4'' > 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 > > puts ''wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww'' > puts @file.path > > cmd = <<-end_command > ffmpeg -i #{@file.path} -f flv -s 320x240 ~/Downloads/foobar/ > q.flv > end_command > cmd.gsub!(/\s+/, " ") > > begin > success = Paperclip.run(''ffmpeg'', cmd) > rescue PaperclipCommandLineError > raise PaperclipError, "There was an error processing the > thumbnail for #{@basename}" if whiny > end > dst > end > end > end > > console reports: > > [paperclip] ffmpeg '' ffmpeg -i /var/folders/uL/uL0bYOOZEZaJH5E+BmDJVE > ++ > +TI/-Tmp-/stream,1547,1.mpeg -f flv -s 320x240 ~/Downloads/foobar/ > q.flv '' 2>/dev/null > > > On Oct 1, 10:13 pm, radhames brito <rbri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> On Fri, Oct 1, 2010 at 9:38 AM, Christian Fazzini < >> >> christian.fazz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> Im using a customs processor to run ffmpeg on a video to create a >>> thumbnail. >> >> this here is how i do it >> >> def create_thumbnail >> jpg = File.join(File.dirname(vidfile.path), "#{id}.jpg") >> File.open(jpg, ''w'') >> command = <<-end_command >> ffmpeg -itsoffset -4 -i #{ vidfile.path } -y -vcodec mjpeg - >> vframes 1 >> -an -f rawvideo -s 160x120 #{ jpg } >> end_command >> command.gsub!(/\s+/, " ") >> end >> >> you have to manually delete the file on destroy since paperclip is >> only >> aware of the file i uploaded which it the video file and will not >> delete the >> jpg file. >> >> File.delete(@vidfile.path.gsub(/flv/,"jpg")) >> >> also you have to delete the original, and update the db entry >> >> def set_new_filename >> File.delete(vidfile.path) >> update_attribute(:vidfile_file_name, "#{id}.flv") >> update_attribute(:vidfile_thumb, "#{id}.jpg") >> end >> >> i also set everything in an starling worker >> >> ConvertWorker.async_convert_video(:file_path => vidfile.path) > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > . > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en > . >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Fri, Oct 1, 2010 at 12:49 PM, Christian Fazzini < christian.fazzini-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Radhames, do you mind showing what you have for the processor at / > lib/paperclip_processors/your_processor_lib.rb ? >Well all this is a simple call in my model, and i call the convert function, you can at it as a after_save -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Most of the tutorials I''ve read suggest that the logic for the processing be placed in /lib/paperclip_processors/your_processor_lib.rb For example: http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip Is the after_save approach in the model a better way? On Oct 2, 1:12 am, radhames brito <rbri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Fri, Oct 1, 2010 at 12:49 PM, Christian Fazzini < > > christian.fazz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi Radhames, do you mind showing what you have for the processor at / > > lib/paperclip_processors/your_processor_lib.rb ? > > Well all this is a simple call in my model, and i call the convert function, > you can at it as a after_save-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Been on this for hours, and still getting the same error... Would be great if someone can post a code snippet from a working copy On Oct 2, 1:23 am, Christian Fazzini <christian.fazz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Most of the tutorials I''ve read suggest that the logic for the > processing be placed in > > /lib/paperclip_processors/your_processor_lib.rb > > For example:http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-a... > > Is the after_save approach in the model a better way? > > On Oct 2, 1:12 am, radhames brito <rbri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > On Fri, Oct 1, 2010 at 12:49 PM, Christian Fazzini < > > > christian.fazz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi Radhames, do you mind showing what you have for the processor at / > > > lib/paperclip_processors/your_processor_lib.rb ? > > > Well all this is a simple call in my model, and i call the convert function, > > you can at it as a after_save > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
> > Most of the tutorials I''ve read suggest that the logic for the > processing be placed in >ill tell you what i do and why. i use workling and create a worker process to the convertion , and call the working from an after save callback in the model. I do that because i convert the video from whatever format to flv along with the thumbnail and that takes time , if i do that in the main thread it will cause my app to freeze for each conversion, that is why i moved to a worker process. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Fri, Oct 1, 2010 at 1:36 PM, Christian Fazzini < christian.fazzini-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Been on this for hours, and still getting the same error... Would be > great if someone can post a code snippet from a working copy > >If you give me 2 hours all make an example app and upload it to github for you to pull, is that ok? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
radhames, that sounds good. would appreciate that. One other way, I''ve gotten it to work is in my model: before_save :process_thumbnail private def process_thumbnail system("ffmpeg -i #{self.media.to_file.path} -f flv -s 320x240 ~/ Downloads/foobar/q.flv") end But I dont know if this is a clean way of doing it. Is it? Will I have problems with the app hanging as you mentioned? On Oct 2, 1:40 am, radhames brito <rbri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Fri, Oct 1, 2010 at 1:36 PM, Christian Fazzini < > > christian.fazz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Been on this for hours, and still getting the same error... Would be > > great if someone can post a code snippet from a working copy > > If you give me 2 hours all make an example app and upload it to github for > you to pull, is that ok?-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
> > before_save :process_thumbnail > > private > def process_thumbnail > system("ffmpeg -i #{self.media.to_file.path} -f flv -s 320x240 ~/ > Downloads/foobar/q.flv") > end >yes it will hang as long as this is in your model, and it will hang for a few seconds. Oh and use a after_save callback not a before_save. ok im going to start working on it , meanwhile watch this railscast http://railscasts.com/episodes/128-starling-and-workling -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Even putting the logic/code in /lib/paperclip_processors/ your_processor_lib.rb as described at http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip will make the application hang whenever a user uploads a video? On Oct 2, 2:02 am, radhames brito <rbri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > before_save :process_thumbnail > > > private > > def process_thumbnail > > system("ffmpeg -i #{self.media.to_file.path} -f flv -s 320x240 ~/ > > Downloads/foobar/q.flv") > > end > > yes it will hang as long as this is in your model, and it will hang for a > few seconds. Oh and use a after_save callback not a before_save. > > ok im going to start working on it , meanwhile watch this railscast > > http://railscasts.com/episodes/128-starling-and-workling-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
On Fri, Oct 1, 2010 at 2:14 PM, Christian Fazzini < christian.fazzini-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Even putting the logic/code in /lib/paperclip_processors/ > your_processor_lib.rb as described at > > http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip > will make the application hang whenever a user uploads a video? > > On Oct 2, 2:02 am, radhames brito <rbri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > before_save :process_thumbnail > > > > > private > > > def process_thumbnail > > > system("ffmpeg -i #{self.media.to_file.path} -f flv -s 320x240 ~/ > > > Downloads/foobar/q.flv") > > > end > > > > yes it will hang as long as this is in your model, and it will hang for a > > few seconds. Oh and use a after_save callback not a before_save. > > > > ok im going to start working on it , meanwhile watch this railscast > > > > http://railscasts.com/episodes/128-starling-and-workling > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >I will read and answer after lunch -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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/22/video-thumbnails-with-ffmpeg-and-paperclip&usg=AFQjCNHbJbsr5cjILbhrgpvOot5qJhUPsw 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? On Oct 2, 2:25 am, radhames brito <rbri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Fri, Oct 1, 2010 at 2:14 PM, Christian Fazzini < > > > > christian.fazz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Even putting the logic/code in /lib/paperclip_processors/ > > your_processor_lib.rb as described at > > >http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-a... > > will make the application hang whenever a user uploads a video? > > > On Oct 2, 2:02 am, radhames brito <rbri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > before_save :process_thumbnail > > > > > private > > > > def process_thumbnail > > > > system("ffmpeg -i #{self.media.to_file.path} -f flv -s 320x240 ~/ > > > > Downloads/foobar/q.flv") > > > > end > > > > yes it will hang as long as this is in your model, and it will hang for a > > > few seconds. Oh and use a after_save callback not a before_save. > > > > ok im going to start working on it , meanwhile watch this railscast > > > >http://railscasts.com/episodes/128-starling-and-workling > > > -- > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > . > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en. > > I will read and answer after lunch-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
On Fri, Oct 1, 2010 at 5:29 PM, Christian Fazzini < christian.fazzini-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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/22/video-thumbnails-with-ffmpeg-and-paperclip&usg=AFQjCNHbJbsr5cjILbhrgpvOot5qJhUPsw > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Fri, Oct 1, 2010 at 5:29 PM, Christian Fazzini < > > christian.fazz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > On Fri, Oct 1, 2010 at 5:29 PM, Christian Fazzini < > > > christian.fazz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > 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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > On Fri, Oct 1, 2010 at 5:29 PM, Christian Fazzini < > > > > christian.fazz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
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.fazzini-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> 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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > 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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >> 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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> > > On Fri, Oct 1, 2010 at 5:29 PM, Christian Fazzini < >> >> > > christian.fazz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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 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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > > > > 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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > 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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > >> 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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >> > > On Fri, Oct 1, 2010 at 5:29 PM, Christian Fazzini < > > >> > > christian.fazz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.