The_Official_Raspberry_Pi_-_Beginner’s_Book_Vol1,_2018 (1)

(singke) #1

208 THE OFFICIAL RASPBERRY PI BEGINNER'S GUIDE


avconv -r 1 -i frame%03d.jpg -r 10 animation.h264

This uses a program called avconv to take the still images in the folder and convert them
into a video called animation.h264. Depending on how many stills you took, this process can
take a few minutes; you’ll know it’s finished when you see the Terminal prompt reappear.
To play the video, find the file animation.h264 in your animation folder and double-click it to
open it. Alternatively, you can play it back from the Terminal by typing the following:

omxplayer animation.h264

Once the video has loaded, you’ll see your stop-motion animation come to life.
Congratulations: you’ve turned your Raspberry Pi into a powerful animation studio!
If your animation is moving too quickly or too slowly, change the -r 10 part of the avconv
command to a lower or higher number: this is the frame rate, or how many still images there are
in one second of video. A lower number will make your animation run more slowly, but look less
smooth; a higher number looks smoother, but will make the animation run more quickly.
If you want to save your video, be sure to drag and drop it from the desktop to your Videos
folder; otherwise, next time you run your program, you’ll end up overwriting the file!

Advanced camera settings
If you need more control over the Raspberry Pi Camera Module, you can use the Python
picamera library to access various settings. These settings, along with their default values, are
detailed below for inclusion in your own programs.

camera.awb_mode = 'auto'
This sets the automatic white balance mode of the camera, and can be set to any one of
the following modes: off, auto, sunlight, cloudy, shade, tungsten, fluorescent,
incandescent, flash, or horizon. If you find your pictures and videos look a little blue or
yellow, try a different mode.

camera.brightness = 50
This sets the brightness of the camera image, from darkest at 0 to brightest at 100.

camera.color_effects = None
This changes the colour effect currently in use by the camera. Normally, this setting should
be left alone, but if you provide a pair of numbers you can alter the way the camera records
colour: try (128, 128) to create a black and white image.
Free download pdf