| SPXL.TVblog | contactgallery | videoflash | processingmyspace | facebook

Processing: virtual playhead and motion blur demo 29 January, 2009 at 2:32 pm

Processing sample: spxlPlayheadDemo_1_1


View sketch page for source code. Please note that the sketch itself appears to freeze after only a second or two of runtime. Please try building the program yourself in the Processing IDE – you cannot save files from the applet in any case (this is a video frame generator).

Virtual Playhead and Motion Blur Demo

“Perfectly Synching Hamster Gyro”

Code remix by subpxiel

Version 0.2, 2009-01-29

Idea started with Hamster Gyro Music Video Generator by Johan Larsby


Virtual Playhead

  • Output-frame-accurate controls
  • Variable output framerate, independent of actual sketch framerate
  • When the target framerate is adjusted, the frame number is recalculated
    to maintain the play position as closely as possible
  • A “running time” is kept independently from the strict frame time, but
    various operations cause the frame time or running time to be
    determined by each other, eg if stepping frames, the running time is
    set to match the frame time.
  • “Realtime” playback honours output frame rate
  • “Realtime” playback controls to pause, fast-forward, play in slow-motion,
    reverse, jump back/forward, rewind, frame stepping
  • Save frame with accurate frame number, independent of frameCount variable

Temporal Anti-aliasing (motion blur)

  • Frames containing movement (translation, rotation) are multisampled then recombined into a single image
  • The number of sub-frames rendered is governed by the fastest estimated motion for that frame, as well as a maximum limit determined by the user
  • Low-quality (or no) temporal anti-aliasing is put into effect for “realtime” playback to maintain a decent frame rate, with full-quality implemented whenever the movie is paused

I saw Johan’s video generator program and was interested to find out what made it tick. I really should have written something like this last year when I had a need for supplying lyrics for music at parties… I’d had a bit of an experiment in another direction, using custom HLSL pixel shaders in the Neon v2 VJ software I use, but that proved to be painful and not especially useful!

Anyhow, when I looked inside the hamstergyro, aside from the world of pain of setting up those hundred or so timed lyrics entries, I saw that the method use to calculate the animation was a bit confusing and awkward. My first thought was to post a comment recommending Johan check out the lerp() and lerpColor() functions for future projects, and started typing some example code in the comments box to show how nice it might look in comparison.

I then realised the code probably would not be formatted properly in the comment, and I also didn’t want to leave a suggestion to use code that I’d not actually tried out, sp downloaded the zip file and started hacking away to make sure it _would_ work the way I was suggesting. I may just have a use for this myself, so it seemed a worthwhile project to keep things tidy and make it easier to expend on in future! :o)

Of course, just testing out a couple of lerp() calls wasn’t going far enough, and what I’ve ended up with is something I reckon is pretty cool. A kind of video transport system with a virtual playhead that can be controlled independently of Processing’s current frame number and/or frame rate. I also had this brilliant idea to try out rendering in-between frames and blending them together for a nice motion blur effect. That part in particular I’m sure can be improved upon, but it is a nice start. :o)

In all, I’m pretty pleased with the result so far, and I’d like to thank Johan for the inspiration – seeing something done is sometimes all the motivation you need to go out and try it yourself.


Leave a Reply