Reverse Video Playback

Get Adobe Flash player

If you’re at all familiar with video within flash you’ll know that there is no built in functionality to play a video in reverse. The reason for this is quite simple. When a video is encoded regardless of the codec or the wrapper format some frames are keyframes (iFrames) and other are in-between frames (pFrames or bFrames). Basically the in-between frames need data from other frames, which are usually sequentially before them, so if the video is played in reverse each time an in-between frame is encountered data will potentially be missing.

You could make every frame a key-frame to get around this, however this would result in huge file size.

Another approach that can work in some cases is to take a bitmapdata capture of each frame as the video plays, save them to a Vector and then once this process has been completed you can jump to any frame within the Vector regardless of if the original frame was a key-frame or not, or even play through the Vector in reverse.

The movie above demonstrate this method, source files can be download from here.

The downside to this approach is that each frame that is placed in the Vector has to be saved into memory, so if the video is really long in length, or has large dimensions this may slow performance significantly, so keep this in mind. The other downside is that you have to play through the video to capture each frame before you can play it in reverse, I guess it really depends on your project as to if this is going to be an issue.

The above example is lacking buffer checking, so if the video starts buffering half way through playback the reverse sequence will capture this. This could be fixed pretty easily by putting in an “if buffering don’t capture” statement, but I don’t really need it for what I’m doing. For a more solid solution you’d also probably want to use a timer rather than enter frame.

1 Comment

  1. Awesome wor Pete. Thanks for Sharing it with others.

Submit a Comment

Your email address will not be published. Required fields are marked *