Ch8…Example: Creating a stop frame animation

This project is using “Chapter 8 – Creating Projects with the Raspberry Pi Camera Module” of my Raspberry Pi Cookbook for Python Programmers book, which has a recipe called “Creating a stop frame animation”.

The recipe in the book is intended as introduction to using the Camera Module for animation, however  it was enough to try the idea out and the book provides all the detail needed to expand and customise it to suit your own requirements.


Ever since I wrote the section in the book about using the Raspberry Pi Camera module for stop-frame animations, I’ve been keen to let my daughter have a go with it.

Overall it makes an excellent project to do with kids since it fires up their imagination, gets them to use technology in new ways and most importantly allows them to make choices and decisions on what they want to achieve.

Younger kids will enjoy the play and storytelling aspect, without needing to follow a prescribed list of steps or instructions, which they often find difficult to keep focused on.

While older kids (or adults) will probably find the planning and construction side more interesting, with the additional challenge of expanding the application’s features and adding additional hardware to their setup.  Often it is this tinkering with software/hardware which can provide the best learning experience, requiring problem solving, design and creativity skills to achieve their goals.

Chapter 8 – Creating Projects with the Raspberry Pi Camera Module – Recipe – “Creating a stop frame animation”


Raspberry Pi Setup


The setup includes a standard Raspberry Pi, Camera Module, SD Card and Wifi Dongle.

The Stop Frame Animation setup needs a Raspberry Pi (Model A or Model B), with a normal (not the NoIR version) Camera Module.

For my setup, I used a laptop connected via SSH, using the Wifi dongle to provide a network connection.  We can connect using a laptop for display and control (via X-Forwarding), allowing the Raspberry Pi more mobile without needing to be wired up to a screen / keyboard.  I also had the home directory of the Raspberry Pi shared on the network, making it easy to access the files used.  This setup is also detailed in “Chapter 1 -Getting Started with a Raspberry Pi Computer” of the book.

Extra Thoughts:
The screen on top of unit is a 2.8″ TFT + Touch Shield Board – I didn’t use it this time, but potentially it would work well as viewfinder and controller in a future project.  Add to that the D-Pad Controller module (available here) and we could add some hardware controls for shutter, settings and reviewing of images, we’d have quite a useful animation machine!


The small post-it notes are some story plans/cast directions written by the “director”…she had lots of ideas of what she wanted to do, even before we got started!  This shows the magic of being a child, so full of ideas, as a boring grown up I was struggling to think of something interesting to animate. There were also a few “extras” milling around the set, hoping to get their chance of fame.

Setting the Stage

We begin by building our set, a quick stage created by cutting two sides off a box and wall-papering using coloured paper for the grass and sky (if you look closely the set designer also added some extra details prior to the filming!).

Our stage took shape very quickly and the cast were eager to get started.

Our stage took shape very quickly and the cast were eager to get started.

The cast were carefully selected through several rounds of auditions (and a few trips to the toy box):


The cast were excited and ready for the filming to take place

All that remained was to the fire up the camera and line up the initial shot (by using the Camera app to view the scene from the perspective of the Raspberry Pi):

First positions people!

First positions people!

Lights! Camera! Action!

This was the most difficult stage of the process (for me), letting the “director” make her movie. With lots of instructions from me: “move them just a small bit” and “don’t move them too far”, I was soon sounding like Nick Park (the creator of Wallace and Gromit) did when he enthusiastically explained animation on TV many years ago (and made me want my own Cine 8 camera for animation when I was little).

It wasn’t long before the director was snapping away, adjusting the scene and taking shot after shot – needless to say she was loving every bit!


Thankfully, the “director” did let me animate a few things, but she was very clear what she wanted and what was going to happen.  Sharing our ideas we also used post-it notes to add a little dialogue to the film too – silent movie style!

Everyone enjoys a Royal Wedding!

Everyone enjoys a Royal Wedding!

She even wanted to add lighting effects to make it night and morning again (alas the automatic settings of the Camera Module adjusted for the lighting conditions so this was not possible).

Extra Thoughts:  A new feature I now need to add to the software to provide director control of lighting…
The cameraGUI3animate application.

The cameraGUI3animate application.

We even used the preview “Animate” feature of the application to que up the images we’d taken and review the footage so far (and experiment with the frame rate).

The final film

Initially the film was produced using the application, however since it rendered at a default of 24 frames per second it was way too fast (the mind of a 7 year old can only be slowed down so far, and making things move slowly is asking a lot!).  Therefore I re-rendered the images at a more realistic frame-rate of 1 frame per second (I just needed a small adjustment to the rendering command-line).

Extra Thoughts: Again, this will need to be another control I add to the application (originally had I thought you’d want a fixed frame rate for the final video, and the variable frame rate would only be useful for reviewing things – it wouldn’t take much allow the selected frame rate to be used for the rendered video if desired).  


It wasn’t all plain-sailing, I setup the Raspberry Pi on a fairly new SD Card image and I did run into a few problems. It is important to remember that the drivers for the Raspberry Pi camera module are adapted from drivers for mobile phones, so in several cases we are using the device in a different way to how it was originally intended/tested, hence why sometimes things don’t quite work as expected.  The drivers are still evolving and changing, so you may find things that worked before might get broken and old problems get resolved when you update. The best tip here is to get it set up and tested before you invite your director to start work!

Camera Freeze: mmal … 0x4f525245

When I first tried the camera module on this setup I received the following error:

mmal: Received unexpected camera control callback event, 0x4f525245

The 0x4f525245 part of the message is “ERRO”, and simply indicates that something wasn’t right and an error occured. Once I had performed a full upgrade using apt-get, this error went away:

sudo apt-get update
sudo apt-get upgrade

This appeared to resolve the problem for the animation session. However, I’ve since had the error return and then go away again, suggesting my issue may be hardware/power/cable related too (it is something I will monitor and update this section if I manage to work out what is happening).

Black Preview Images

This issue appears to be linked with a long running issue with the Camera Preview/Auto-exposure in the camera driver itself. The auto-exposure algorithm doesn’t always activate when the camera preview isn’t running first (perhaps an issue with requiring an active image to seed the algorithm).  Although there has been some fixes for this put in place in recent updates, for generating the JPEG output (as used for our normal images), this effect can often be seen on the first image you take with the camera if you are not using the preview feature (or if the preview period is short). The problem in the application is that it appears that the GIF format may still suffer from this issue (it may be dependent on the firmware/software versions, the camera module and perhaps even power supply – it may even just be my camera module).  This didn’t seem to happen as often in the earlier versions of the camera driver I used for my testing. For the application, the live preview feature of the camera was avoided, since it just overlays over the top of any application it becomes a problem if the application is move etc. (the preview would need to be continuously adjusted to match).  Therefore we allow the application to take a small preview image and display the result in the Tkinter window instead. Originally it was found that converting and displaying the JPEG images was a little slow so the GIFs format was used to provide a faster update.  However the CameraPi module appears to be faster than raspistill so we can use a JPEG file and still have a fairly fast preview. The simplest fix if you experience this issue is to switch our preview image to use JPEG images rather than the GIF format. Change the following line in


To the following:


This will change the preview image to use “PREVIEW.jpg” instead of “PREVIEW.gif”. Due to the modular approach we use in Chapter 8, this single line will change the preview format for all of the examples, fixing it for all cases.  This shows how useful it is to do things in this way.

  1. Jose Hernandez says:

    Ese error se debe a que la cámara pi esta mala, me paso lo mismo y con cambiar la cámara se corrigió el fallo

    • Translation: “That error is because the pi camera is bad, I spend the same and change the camera with the fault is corrected”
      I think you are probably correct, the issue is only recent.

      When I get chance to confirm with another camera I will update this post.

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 )

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.