Using ColdFusion/ffmpeg to create a panning video

I came across an interesting post in the Railo groups about using Railo’s CFVideo plugin to create a panning effect using images.  I quickly threw together a little demo to show how this can be accomplished.  Since the CFVideo tag still has not been released to the core providers, I whipped up a little demo using just ffmpeg.  I know the quality is not all that great here, but this was a proof-of-concept.

First, I went and found a 1024×768 background image.  Since I was reading Ben Nadel’s post about the Conflict of Truth, I was inspired and grabbed a Matrix image (that movie still rocks).  Next step is to crop the images we will eventually use to stitch together our animation.  I realize I am setting my bounds a little small here but, as I said, this was just a PoC.  I decided to let Railo do the heavy lifting for me.

<cfset imgOriginal = ExpandPath(".") & "/3posters-trilogia-matrix.jpg" />
<cfImage name="readImage" action="read" source="#imgOriginal#" />
<cfloop from="1" to="827" index="x"> 
 <cfset workImage = imageRead("#readImage#")/> 
 <cfset imageCrop("workImage", x, 1, 200, 200)/> 
 <cfimage action="write" source="#workImage#" destination="#expandPath(".")#/stock/img#NumberFormat(x-1, "0000")#.jpg" overwrite="true">

There is not a lot going on here.  I preload my original image and then pan from left to right across the image one pixel at a time.  Each time I shift a pixel I save an image into the ./stock/ folder.  I will forewarn you this is very processor intensive so upping the default page timeout is required because 50 seconds will not cut it (on my workstation at any rate).  Now we should have 827 nice images  in our stock folder.  Now it is time to run ffmpeg on this to package it up into a video.

/ffmpeg/bin/ffmpeg -r 10 -b 1800 -i img%04d.jpg test1800.mp4

FFMpeg runs considerably faster stitching together the image into the video and will quickly spit out our end result:


2 thoughts on “Using ColdFusion/ffmpeg to create a panning video

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s