Skip to content

Instantly share code, notes, and snippets.

View rrrodrigo's full-sized avatar

Marcin Bajer rrrodrigo

View GitHub Profile
These are some snips to help you converting video to flash and thumbnails using ruby and paperclip.
Needed: ffmpeg & flvtool, RVideo gem, paperclip
Converting the video is done using outside of paperclip, as this could take quite a while. Paperclip by default does it's conversions during the request, and the last thing you want is a request hanging for 10minutes while ffmpeg does it's thing. It is advised to do this conversion somewhere in the background using Resque or DelayedJob. (make sure not to run to many conversions at one time on your machine)
Most video thumbnailing solutions out there will create all thumbnails from the video. This solution (on paperclip 2.3.0) however will create one large "temp_thumbnail" once and all consequent thumbnails can use this temporary version.
VideoGeometry will make sure that the target dimensions for ffmpeg are always a multiple of 2 and as close as possible to the desired dimensions without breaking the aspect ratio of the original video.