<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>UK Ruby on Rails, Exalead, AWS, Consultancy - Video thumbnails with FFmpeg and Paperclip Comments</title>
  <id>tag:thewebfellas.com,2011:/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip/comments</id>
  <generator version="0.7.3" uri="http://mephistoblog.com">Mephisto Noh-Varr</generator>
  <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip/comments.xml" rel="self" type="application/atom+xml"/>
  <link href="/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
  <updated>2011-05-19T09:18:13Z</updated>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:27093</id>
    <published>2011-05-19T09:17:42Z</published>
    <updated>2011-05-19T09:17:42Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Rob Anderton</title>
<content type="html">&lt;p&gt;It might be worth putting a breakpoint in the &lt;code&gt;rescue&lt;/code&gt; block of the &lt;code&gt;make&lt;/code&gt; method and inspecting the values of the original exception &lt;code&gt;message&lt;/code&gt; and &lt;code&gt;output&lt;/code&gt; attributes (before the exception is re-raised) to be sure that it is the warning that is causing the error and not something else.&lt;/p&gt;

&lt;p&gt;I've had FFmpeg warnings before that haven't stopped Paperclip from doing its thing - so I'd be interested to know why it's breaking your code.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>erwin</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:27091</id>
    <published>2011-05-19T07:34:48Z</published>
    <updated>2011-05-19T07:34:48Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by erwin</title>
<content type="html">&lt;p&gt;thanks for all these info .. it's running so well...
However I got a, issue trying to generate thumbnail for an .m4v video file
the ffmpeg command line on console works well .. ( it generates the thumbnail) but display a warning ...  &lt;/p&gt;

&lt;p&gt;ffmpeg -ss 2  -i clipout12-iPhone.m4v  -y  -vcodec mjpeg  -f image2 -vframes 1  -s 100x74 clipout12-iPhone.jpg
..
Seems stream 1 codec frame rate differs from container frame rate: 2000.00 (2000/1) -&gt; 1000.00 (2000/2)&lt;/p&gt;

&lt;p&gt;running the command line within Paperclip processor raises a  PaperclipCommandLineError and the thumbnail is not generated..
is there anyway to avoid this 'frame rate' checking or should I bypass the error in the rescue ?
...&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Stijn Mathysen</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:24264</id>
    <published>2011-02-23T09:46:06Z</published>
    <updated>2011-02-23T09:46:06Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Stijn Mathysen</title>
<content type="html">&lt;p&gt;Seems like the newer versions of Paperclip changed the way interpolation works. Here is what I did to make it compatible again;&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;Paperclip.interpolates :extension do |attachment, style_name|
  case
    when ((style = attachment.styles[style_name]) &amp;amp;&amp;amp; !style[:format].blank?) then style[:format]
    when attachment.instance.respond_to?(:video?) &amp;amp;&amp;amp; attachment.instance.video? &amp;amp;&amp;amp; style_name.to_s == 'transcoded' then 'flv'
    when attachment.instance.respond_to?(:video?) &amp;amp;&amp;amp; attachment.instance.video? &amp;amp;&amp;amp; style_name.to_s != 'original' then 'jpg'
  else
    File.extname(attachment.original_filename).gsub(/^\.+/, &amp;quot;&amp;quot;)
  end
end&lt;/code&gt;&lt;/pre&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>EH</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:19841</id>
    <published>2010-10-20T22:43:26Z</published>
    <updated>2010-10-20T22:43:26Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by EH</title>
<content type="html">&lt;p&gt;If you didn't already know, this article is being reprinted above you in Google results: http://www.railsfire.com/article/video-thumbnails-ffmpeg-and-paperclip&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Bert Goethals</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:18447</id>
    <published>2010-08-16T09:46:30Z</published>
    <updated>2010-08-16T09:46:30Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Bert Goethals</title>
<content type="html">&lt;p&gt;Recently i posted a git about how we handle videos with (and without) paperclip. The original solution was based on this post, so i thought it would be nice to share it here.&lt;/p&gt;

&lt;p&gt;It has some cool things like&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Thumbnails, but only once from video&lt;/li&gt;
&lt;li&gt;Geometry for video (2px rule included)&lt;/li&gt;
&lt;li&gt;conversion to flash&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hope it helps: http://gist.github.com/507804&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:18445</id>
    <published>2010-08-16T08:55:51Z</published>
    <updated>2010-08-16T08:55:51Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Rob Anderton</title>
<content type="html">&lt;p&gt;We've not had a problem, although the site is over a year old and is running on Paperclip 2.2.4 (patched to allow Procs for processors) so maybe the problems you're seeing have been added more recently?&lt;/p&gt;

&lt;p&gt;When I get chance I'll take a look at how it works with the current Paperclip version and see if there are any patches I can contribute.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Thomas Glasgow</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:18434</id>
    <published>2010-08-15T16:32:49Z</published>
    <updated>2010-08-15T16:32:49Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Thomas Glasgow</title>
<content type="html">&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;Rob thanks for your message. Does the lambda which defines dynamic processors work for you? Because it does not for styles. Moreover if one defines styles using a hash, eg: :small =&gt; {:geometry =&gt; &quot;64x64&quot;, :format =&gt; &quot;png&quot;}, then the geometry gets deleted by paperclip and results in a failure which is being discussed in the mailing-list.&lt;/p&gt;

&lt;p&gt;Paperclip has a few bugs that make it unsuitable for production unless people double-check everything as prod/dev environments result in different behaviors.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:18222</id>
    <published>2010-08-03T11:17:16Z</published>
    <updated>2010-08-03T11:17:16Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Rob Anderton</title>
<content type="html">&lt;p&gt;I'd agree Paperclip is not best suited to this kind of thing, it's just not flexible enough which is why the video thumbnailer and transcoder processors I've written aren't particularly nice pieces of code. I haven't tried anything too advanced yet, but I'm hoping &lt;a href=&quot;http://github.com/jnicklas/carrierwave&quot; title=&quot;Take a look at CarrierWave&quot;&gt;CarrierWave&lt;/a&gt; will be better at this kind of thing.&lt;/p&gt;

&lt;p&gt;My video transcoding is done in a Paperclip processor that looks almost exactly like the thumbnailer, the main difference being the ffmpeg command line which looks like this:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;cmd = %Q[-i &quot;#{File.expand_path(file.path)}&quot; -y -f flv -vcodec flv -b 200000 -r 30 -acodec libfaac -ac 2 -ab 32000 -ar 22050 ]&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;My Paperclip definition defines a special 'transcoded' style which I handle in the &lt;code&gt;content_type_extension&lt;/code&gt; interpolation with this extra condition:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;when attachment.instance.video? &amp;amp;&amp;amp; style_name.to_s == 'transcoded' then 'flv'&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Our transcoding is dealt with offline using a queue, as it could be lengthy process, part of which involves forcing the file for the transcoded style to be set to the processed video:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;original_file = asset.to_file
asset.queued_for_write[:transcoded] = Paperclip.processor(:video_transcode).make(original_file, { :whiny =&gt; true, :geometry =&gt; '480x360' }, asset)
asset.save&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This probably doesn't make too much sense, but that only highlights it's messiness! It's the main reason I've not been able to do a proper post on it yet as it's not very easy to explain. Hopefully I've given you some ideas to get you going though :)&lt;br /&gt;Rob&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Thomas</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:17550</id>
    <published>2010-07-31T08:42:02Z</published>
    <updated>2010-07-31T08:42:02Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Thomas</title>
<content type="html">&lt;p&gt;Although paperclip looked promising at first sight, once we start digging further it quickly reaches its design limits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;it's not well suited for &quot;polymorphic&quot; attachments like attaching a video, audio or video.&lt;/li&gt;
&lt;li&gt;background re-encoding is not possible within processors&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'm still keeping it, but I have to bypass the processors and handle the transcoding myself within the model.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Thomas Glasgow</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:17215</id>
    <published>2010-07-29T19:59:23Z</published>
    <updated>2010-07-29T19:59:23Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Thomas Glasgow</title>
<content type="html">&lt;p&gt;Hi Rob it's me again :),&lt;/p&gt;

&lt;p&gt;In your comment #14 you talk about an additional processor that converts the video to flv. How would you add that?&lt;/p&gt;

&lt;p&gt;Because the way paperclip is made, is that if you upload let's say an mp4 file it's tricky to get .jpg and .flv files.&lt;/p&gt;

&lt;p&gt;I didn't manage to tie the processor chooser to a specific style using the lambda. At runtime paperclip wants to inject the processors definition but the lambda doesn't get execute and it fails.&lt;/p&gt;

&lt;p&gt;Thanks for your insight.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Thomas Glasgow</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:17181</id>
    <published>2010-07-29T17:16:48Z</published>
    <updated>2010-07-29T17:16:48Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Thomas Glasgow</title>
<content type="html">&lt;p&gt;Ok I got it, it's the content&lt;em&gt;type&lt;/em&gt;extension interpolation that does the magic. Their documentation on processors is awful!&lt;/p&gt;

&lt;p&gt;PS again: what's that stupid comment filtering system you have? I couldn't post a second comment after my previous one. Take it off, it's pain.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Thomas Glasgow</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:17174</id>
    <published>2010-07-29T16:35:05Z</published>
    <updated>2010-07-29T16:35:05Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Thomas Glasgow</title>
<content type="html">&lt;p&gt;I am getting closer. So ffmpeg gets fired, the thumbnail is certainly generated, but Paperclip doesn't seem to get it and won't save it along with the original video.&lt;/p&gt;

&lt;p&gt;Any reason for that?&lt;/p&gt;

&lt;p&gt;PS: By the way I had issues running: Paperclip.run('ffmpeg', cmd), for some reason paperclip surrounds cmd with additional quotes which makes ffmpeg fail.&lt;/p&gt;

&lt;p&gt;If I do: cmd = &quot;ffmpeg -i input.avi ...&quot; and Paperclip.run(cmd) ffmpeg can now do its job (but still paperclip won't sve the thumbnail).&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:16100</id>
    <published>2010-06-21T21:16:23Z</published>
    <updated>2010-06-21T21:16:23Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Rob Anderton</title>
<content type="html">&lt;p&gt;Hi Thomas,&lt;br /&gt;When you attach a new file the thumbnails should be regenerated. You can access a thumbnail file using the &lt;code&gt;to_file&lt;/code&gt; method, for example:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;attachment.to_file(:thumbnail)&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And you could then assign this to a different attachment if you wanted to preserve the old thumbnail for some reason.&lt;/p&gt;

&lt;p&gt;Rob&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Thomas Glasgow</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:16086</id>
    <published>2010-06-20T20:15:57Z</published>
    <updated>2010-06-20T20:15:57Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Thomas Glasgow</title>
<content type="html">&lt;p&gt;Hi Rob,&lt;/p&gt;

&lt;p&gt;So I'm back in the processor business.&lt;/p&gt;

&lt;p&gt;When the processor is done, is there a way to programmatically access the generated file? Like assign it to has_attached_file :thumbnail?&lt;/p&gt;

&lt;p&gt;My concern is what happens when I upload and attach a new and different file to the object? Does the old thumbnail get destroyed? I'm not sure about that.&lt;/p&gt;

&lt;p&gt;Cheers,&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Teresa</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:15994</id>
    <published>2010-06-15T16:28:31Z</published>
    <updated>2010-06-15T16:28:31Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Teresa</title>
<content type="html">&lt;p&gt;I cannot thank you enough for posting this article: I wanted to do precisely this (use the same model for both video and other graphic attachments), but thought I might need to make a separate model to distinguish between content types. After a 5 minute implementation (copy and paste), your code worked flawlessly.&lt;/p&gt;

&lt;p&gt;Really, I couldn't be more appreciative. Thanks so much.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:15645</id>
    <published>2010-05-27T23:10:30Z</published>
    <updated>2010-05-27T23:10:30Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Rob Anderton</title>
<content type="html">&lt;p&gt;Just tried the same code and it worked without error. It looks like you need to make sure the user that you're running your Rails server as has write permissions to the temp directory where upload files are being stored prior to processing.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Chris</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:15620</id>
    <published>2010-05-26T20:14:43Z</published>
    <updated>2010-05-26T20:14:43Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Chris</title>
<content type="html">&lt;p&gt;ok... gotta correct my last post. Sorry for causing confusion. I forgot that i fixed it by setting the callback to :after&lt;em&gt;save. Here is my method called on :before&lt;/em&gt;save, where 'audio' is my model attribute&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;def set_mp3_tags
    Mp3Info.open(audio.to_file.path) do |mp3|
      mp3.tag.title = 'foo'
    end if audio?
  rescue Mp3InfoError =&amp;gt; e
    errors.add(:audio, &amp;quot;unable to process file (#{e.message})&amp;quot;)
  end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Causes:
Permission denied - C:/[..]/Temp/stream.1440.0&lt;/p&gt;

&lt;p&gt;Greetings,
Chris&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Chris</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:15616</id>
    <published>2010-05-26T18:16:19Z</published>
    <updated>2010-05-26T18:16:19Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Chris</title>
<content type="html">&lt;p&gt;The error must have been on my side, as a server restart fixed it... &lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:15607</id>
    <published>2010-05-26T10:55:30Z</published>
    <updated>2010-05-26T10:55:30Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Rob Anderton</title>
<content type="html">&lt;p&gt;Hi Chris, what does your code look like at the moment?&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Chris</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:15602</id>
    <published>2010-05-26T06:28:29Z</published>
    <updated>2010-05-26T06:28:29Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Chris</title>
<content type="html">&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;I tried to modify mp3-tags with mp3info in a before_save callback. Which gives me a 'access denied' exception. Any ideas how to handle this?&lt;/p&gt;

&lt;p&gt;Greetings,
Chris&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:11133</id>
    <published>2009-11-27T10:38:18Z</published>
    <updated>2009-11-27T10:38:18Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Rob Anderton</title>
<content type="html">&lt;p&gt;Hi Glenn,&lt;br /&gt;
I've not posted it yet but it is my plan to (although it's been my plan to for about 6 months now). I'll see if I can put it together for next week as I'm long overdue a new blog post (as certain other WebFellas keep reminding me) :)&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Glenn</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:10953</id>
    <published>2009-11-21T16:09:50Z</published>
    <updated>2009-11-21T16:09:50Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Glenn</title>
<content type="html">&lt;p&gt;Rob,
very useful tutorial.  You mention in the comments that you have another processor to handle the FLV transcoding.  I've been been piecing my own such process together from various other blogs, but I was wondering if you have already posted, or will in the near future post, another tutorial detailing your transcoder processing.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:10856</id>
    <published>2009-11-19T10:28:54Z</published>
    <updated>2009-11-19T10:28:54Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Rob Anderton</title>
<content type="html">&lt;p&gt;In one of our projects I added a &lt;code&gt;VideoGeometry&lt;/code&gt; class (as a subclass of Paperclip's own &lt;code&gt;Geometry&lt;/code&gt; class). To get the dimensions of the video it uses ffmpeg with just the &lt;samp&gt;-i&lt;/samp&gt; input file argument and captures the output via &lt;samp&gt;stderr&lt;/samp&gt;.&lt;/p&gt;

&lt;p&gt;It then uses a simple regular expression to look for the video stream information from the captured output and matches the wxh dimensions it contains.&lt;/p&gt;

&lt;p&gt;You could also look at the &lt;a href=&quot;http://rvideo.rubyforge.org/&quot; title=&quot;Go to the RVideo project&quot;&gt;RVideo gem&lt;/a&gt;, it has an &lt;code&gt;Inspector&lt;/code&gt; class that does a similar thing: I didn't use it as my needs were simple, but if you want to get even more information about your videos it's probably the way to go.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Bert Goethals</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:10836</id>
    <published>2009-11-18T15:13:26Z</published>
    <updated>2009-11-18T15:13:26Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Bert Goethals</title>
<content type="html">&lt;p&gt;Great plugin, however this solution will always create squared thumbnails.&lt;/p&gt;

&lt;p&gt;This is not always desired. FFMPEG only supports wxh format, including a &gt;, &amp;lt; or # modifier will break the command.&lt;/p&gt;

&lt;p&gt;Ideally the Recalculation of the Geometry should know about the original dimensions, but how should those be obtained? 
I know of the -vstats argument, but that writes to files, and that just doesn't seems the way to go?&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Leandro Pedroni</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:8999</id>
    <published>2009-10-01T10:03:57Z</published>
    <updated>2009-10-01T10:03:57Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Leandro Pedroni</title>
<content type="html">&lt;p&gt;Cool! I saw a bit of the &lt;strong&gt;Building a Video Portal in Rails - or How the Teenage Mutant Ninja Turtles Started Streaming&lt;/strong&gt; presentation and they suggested flixcloud. It could be very interesting to do a writeup for a processor that uses the flixcloud API (there's a ruby gem) which by the way plays well with S3.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Marc Lainez</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:8871</id>
    <published>2009-09-25T12:21:05Z</published>
    <updated>2009-09-25T12:21:05Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Marc Lainez</title>
<content type="html">&lt;p&gt;Hello guys,&lt;/p&gt;

&lt;p&gt;Great article, it helped me a lot. I didn't really understand what was the custom interpolation :content&lt;em&gt;type&lt;/em&gt;extension for. If you just want the generated files extensions to be handled has jpg, adding a :jpg next to my styles formats did the trick...&lt;/p&gt;

&lt;p&gt;:styles =&gt; { :big    =&gt; ['540x406&gt;', :jpg], :thumb  =&gt; ['270x203&gt;', :jpg]}&lt;/p&gt;

&lt;p&gt;That way the original file has its original extension, and the two generated files have a jpg extension.&lt;/p&gt;

&lt;p&gt;But maybe I'm missing the point behind this :content&lt;em&gt;type&lt;/em&gt;extension thing...&lt;/p&gt;

&lt;p&gt;Cheers&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>kadoudal</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:7776</id>
    <published>2009-07-21T10:55:23Z</published>
    <updated>2009-07-21T10:55:23Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by kadoudal</title>
<content type="html">&lt;p&gt;thanks very helpful.. 
note : I am not sure that the itoffset parameters works fine ...&lt;/p&gt;

&lt;p&gt;I tried 2 commands  with ffmpeg (last version may, 2009)&lt;/p&gt;

&lt;p&gt;ffmpeg -i #{vpath} -itsoffset -3  -s 150x100 -vframes 1 -f image2 -an #{tpath}
and
ffmpeg -i #{vpath} -ss 00:00:03  -s 150x100 -vframes 1 -f image2 -an #{tpath}&lt;/p&gt;

&lt;p&gt;only the 2nd one gives me a shot at 3sec after initial frame ...&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:4856</id>
    <published>2009-05-12T07:19:19Z</published>
    <updated>2009-05-12T07:19:19Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Rob Anderton</title>
<content type="html">&lt;p&gt;Yes it runs the processor in-process, so it'll block until it is done. We've found thumbnailing video with ffmpeg to be as quick as thumbnailing images with ImageMagick. We also have a Paperclip processor that uses FFmpeg to transcode the video to FLV format: this is a much longer process and for that we use a queue to handle it out-of-process.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Thomas Glasgow</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:4837</id>
    <published>2009-05-11T20:30:43Z</published>
    <updated>2009-05-11T20:30:43Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Thomas Glasgow</title>
<content type="html">&lt;p&gt;Using Paperclip.run, does it block the process will converting the video? Shouldn't we use backgroundrb for that purpose?&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Thomas Glasgow</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:4250</id>
    <published>2009-04-22T11:04:41Z</published>
    <updated>2009-04-22T11:04:41Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Thomas Glasgow</title>
<content type="html">&lt;p&gt;Hi Rob,&lt;/p&gt;

&lt;p&gt;Mplayer tries to play the video instead of extract a frame from it. From what I found, mplayer thinks that the file is corrupted and tries to play it and skip bad frames but it makes things even worse and kills the cpu. That behavior only happened with a particular file when the passed file came from Paperclip, so I preferred to simply drop the processor and use a callback that works on the real file and not from Tempfile just to be safer in the future.&lt;/p&gt;

&lt;p&gt;For the processor, it's strange, because if I return the thumbnail, then Paperclip would save the original video as a 0Kb file on disk. If I return the video file then it gets saved properly.&lt;/p&gt;

&lt;p&gt;Thanks for your reply.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:4243</id>
    <published>2009-04-21T22:06:14Z</published>
    <updated>2009-04-21T22:06:14Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Rob Anderton</title>
<content type="html">&lt;p&gt;Hi Thomas,&lt;br /&gt;
Yes the processor is in use on the site that it was originally written for, happily thumbnailing videos 24/7 :)&lt;/p&gt;

&lt;p&gt;As you can see from the &lt;a href=&quot;http://github.com/thoughtbot/paperclip/blob/ea5f6ac0204e0020a856eaaa4d3cc5cee2e0b3ab/lib/paperclip/processor.rb&quot; title=&quot;View the processor base class&quot;&gt;Paperclip source&lt;/a&gt; the &lt;code&gt;make&lt;/code&gt; method of a processor should “return an instance of File (Tempfile is acceptable) which contains the results of the processing”. This is also what Paperclip’s own &lt;a href=&quot;http://github.com/thoughtbot/paperclip/blob/ea5f6ac0204e0020a856eaaa4d3cc5cee2e0b3ab/lib/paperclip/thumbnail.rb&quot; title=&quot;View the Paperclip thumbnailer&quot;&gt;thumbnail processor&lt;/a&gt; does and it was the basis for this video thumbnailer.&lt;/p&gt;

&lt;p&gt;The final piece of the puzzle is the &lt;code&gt;post_process_styles&lt;/code&gt; method in the &lt;a href=&quot;http://github.com/thoughtbot/paperclip/blob/ea5f6ac0204e0020a856eaaa4d3cc5cee2e0b3ab/lib/paperclip/attachment.rb&quot; title=&quot;See the attachment class source code&quot;&gt;&lt;code&gt;Attachment&lt;/code&gt; class&lt;/a&gt;: it iterates over each processor and injects the returned (temp)file returned by the processor in the &lt;code&gt;queued_for_write&lt;/code&gt; array which is then flushed to disk (or written to S3 depending on the storage method being used) when the attachment is saved.&lt;/p&gt;

&lt;p&gt;Hope this helps clear things up. As for your mplayer problem, what exactly does “goes wack” mean?!&lt;br /&gt;Rob&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Thomas Glasgow</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:4242</id>
    <published>2009-04-21T21:56:22Z</published>
    <updated>2009-04-21T21:56:22Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Thomas Glasgow</title>
<content type="html">&lt;p&gt;Wow! I run into a pretty nasty bug. I am using mplayer to extract the frames, and on one video which mplayer goes wack maybe because of the TempFile! Rewriting the processor into a model callback that works on the real file on disk works without any problem.&lt;/p&gt;

&lt;p&gt;Did anyone run into such problem?&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Thomas Glasgow</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:4240</id>
    <published>2009-04-21T20:13:18Z</published>
    <updated>2009-04-21T20:13:18Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Thomas Glasgow</title>
<content type="html">&lt;p&gt;Hi Rob,&lt;/p&gt;

&lt;p&gt;Are you actually using this processor? Because from what I see, your make method returns a Tempfile instance that points to the generated thumbnail, but that's not what Paperclip expects.&lt;/p&gt;

&lt;p&gt;In the case of a thumbnail generator, Paperclip is expecting the original video to be returned, otherwise it wouldn't save it. Don't you have your video saved as a 0Kb file?&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>nap</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:3159</id>
    <published>2009-02-28T02:30:03Z</published>
    <updated>2009-02-28T02:30:03Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by nap</title>
<content type="html">&lt;p&gt;Great tutorial guys. A very useful processor.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:3151</id>
    <published>2009-02-26T17:31:14Z</published>
    <updated>2009-02-26T17:31:14Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Rob Anderton</title>
<content type="html">&lt;p&gt;You should be able to get the original file name and content type from the attachment instance that's passed to the processor: in my code above I'd do this in the initialize method of the processor using &lt;code&gt;attachment.original_filename&lt;/code&gt; and &lt;code&gt;attachment.instance_read(:content_type)&lt;/code&gt;. The downside of this approach is that if multiple processors are chained together then the content_type of the file passed to the processor might not be the same as that of the original file.&lt;/p&gt;
&lt;p&gt;Another option would be to see if &lt;code&gt;@file.respond_to?(:content_type)&lt;/code&gt; and if so use &lt;code&gt;@file.content_type&lt;/code&gt; to read it, but again this might not work if multiple processors are used.&lt;/p&gt;
&lt;p&gt;A final option would be to use something like the &lt;a href=&quot;http://github.com/zencoder/rvideo/tree/master&quot; title=&quot;Find out about RVideo&quot;&gt;RVideo&lt;/a&gt; &lt;code&gt;Inspector&lt;/code&gt; class on the file which uses ffmpeg to analyse the content of the file and tell you what it contains: this would work even with chained processors but does of course add a bit of processing overhead.&lt;/p&gt;
&lt;p&gt;Hope that helps,&lt;br /&gt;Rob&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Moodang</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:3149</id>
    <published>2009-02-26T15:33:30Z</published>
    <updated>2009-02-26T15:33:30Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Moodang</title>
<content type="html">&lt;p&gt;Let me try again. My @file looks like this:&lt;/p&gt;

&lt;p&gt;File:/var/folders/4q/4qf80RBVH40ijDl9aQomck+++TI/-Tmp-/CGI2146-9&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Moodang</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:3148</id>
    <published>2009-02-26T15:31:54Z</published>
    <updated>2009-02-26T15:31:54Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Moodang</title>
<content type="html">&lt;p&gt;I really like your example. I am in fact extending it to transcode videos into various formats. However, I run into some odd problems.&lt;/p&gt;

&lt;p&gt;I am trying to do this&lt;/p&gt;

&lt;p&gt;@current_format   = File.extname(@file.path)&lt;/p&gt;

&lt;p&gt;in my processor code, but it's not working.&lt;/p&gt;

&lt;p&gt;Currently my @file has the form:&lt;/p&gt;

&lt;h1&gt;&amp;lt;file: /&gt;&lt;/h1&gt;

&lt;p&gt;Which essentially has no extensions.&lt;/p&gt;

&lt;p&gt;The original file names are not accessible from within the processor.&lt;/p&gt;

&lt;p&gt;Is there a way I can properly access @current_format from within the processor?&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Jon Yurek</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:3131</id>
    <published>2009-02-23T15:07:59Z</published>
    <updated>2009-02-23T15:07:59Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Jon Yurek</title>
<content type="html">&lt;p&gt;Nice work, Rob! I love seeing new and interesting Processors getting made!&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:3128</id>
    <published>2009-02-23T08:44:41Z</published>
    <updated>2009-02-23T08:44:41Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Rob Anderton</title>
<content type="html">&lt;p&gt;Hey Mike,&lt;/p&gt;

&lt;p&gt;If you're running on the newest Paperclip then your processor gets passed the attachment as the third parameter to the constructor like this: &lt;code&gt;def initialize(file, options = {}, attachment = nil)&lt;/code&gt;, so in the constructor code you could replace &lt;code&gt;@instance = options[:instance]&lt;/code&gt; with &lt;code&gt;@instance = attachment.instance&lt;/code&gt; and wouldn't need to patch.&lt;/p&gt;

&lt;p&gt;I like the idea of the liquidize and compress processors, I hadn't even thought of doing something clever like that! I guess a virus checker would be another idea along the same lines.&lt;/p&gt;

&lt;p&gt;And thanks for the links, glad you like the blog :D&lt;br /&gt;Rob&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Michael Deering</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:3123</id>
    <published>2009-02-23T01:53:07Z</published>
    <updated>2009-02-23T01:53:07Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Michael Deering</title>
<content type="html">&lt;p&gt;I shared my processors over here in a blog post to better put my comment into context.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://mdeering.com/posts/018-paperclip-processors-doing-so-much-more-with-your-attachment&quot; title=&quot;Paperclip Processor Examples&quot;&gt;Paperclip Processors: Doing so much more with your attachments&lt;/a&gt;&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Michael Deering</name>
    </author>
    <id>tag:thewebfellas.com,2009-02-22:3120:3122</id>
    <published>2009-02-23T00:27:27Z</published>
    <updated>2009-02-23T00:27:27Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Video thumbnails with FFmpeg and Paperclip' by Michael Deering</title>
<content type="html">&lt;p&gt;Paperclip rocks!  I was not going to go cargo-cult to it away from attachment_fu until I came across your original paperclip post over here.  &lt;/p&gt;

&lt;p&gt;I was also creating processors this week.  One wall I hit was getting access to the ActiveRecord instance inside of the processors.&lt;/p&gt;

&lt;p&gt;I patched paperclip crudely like this.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# config/initilizers/paperclip_patch.rb
module Paperclip
  class Attachment

    # I need access to the AR instance in order to scope thing by the site the attachment belongs to.
    def post_process_styles
      log(&amp;quot;Post-processing #{name}&amp;quot;)
      @styles.each do |name, args|
        begin
          raise RuntimeError.new(&amp;quot;Style #{name} has no processors defined.&amp;quot;) if args[:processors].blank?
          @queued_for_write[name] = args[:processors].inject(@queued_for_write[:original]) do |file, processor|
            log(&amp;quot;Processing #{name} #{file} in the #{processor} processor.&amp;quot;)
            Paperclip.processor(processor).make(file, args.merge(:instance =&amp;gt; @instance))
          end
        rescue PaperclipError =&amp;gt; e
          log(&amp;quot;An error was received while processing: #{e.inspect}&amp;quot;)
          (@errors[:processing] ||= []) &amp;lt;&amp;lt; e.message if @whiny
        end
      end
    end    

  end
end&lt;/code&gt;&lt;/pre&gt; 

&lt;p&gt;This gave me access to the ActiveRecord instance through options[:instance] inside of the processor.&lt;/p&gt;

&lt;p&gt;You had to do this yet?  Have a better recommendation on the approach to access the AR instances?  I have been in the docs and code, did I miss the obvious?&lt;/p&gt;

&lt;p&gt;Keep up the quality posts.&lt;/p&gt;

&lt;p&gt;Cheers,
Mike D.&lt;/p&gt;</content>  </entry>
</feed>

