The Raspberry Pi camera is great for creating timelapse videos so you can see slow things move quickly such as clouds passing by and plants growing but now with the latest software update you can film fast movement at 90 frames per second and play it back in slow motion at about a third of the speed of the action. So now you can create slower motion videos of wildlife as seen in nature programmes or analyse your golf swing or just generally break things and watch them shatter in to pieces.
The Raspberry Pi camera module has always been capable of capturing video at 90 fps but up until now the software has not been able to use this capability. The developers of the Raspistill and Raspivid camera utilities have managed to update the software to take advantage of the cameras capabilities in the latest update of Raspivid v1.3, which also requires an update to the Raspberry Pi firmware.
Standard video plays at either 24, 25 or 30 frames per second depending on the format so to get video to record at 90 fps there is a trade off in quality as more data has to be saved in the same amount of time. So the image looks a bit blocky and is limited to a resolution of 640 x 480 as opposed to high definition at 1920 x 1080.
How to Take Hi-speed Video
Firstly you will need the latest version of Raspbian with the latest firmware.
To update your firmware open LXterminal and enter
once the update is complete then entersudo apt-get upgrade
this will also update Raspistill and Raspivid to the latest versions.
now set up the camera and enter the command
raspivid -h 640 -w 480 -fps 90 -t 10000 -o video.h264
(-t = length of video. 1000 = 1 second)
this will record 10 seconds of video at 90 frames per second in the raw video h264 format. This will need to be converted to MP4 format before it is usable by most video players.
Note: you will want to capture video to a USB memory stick rather than the Raspberry Pi's SD card. This will usually be /media/[usbstick name here]
If you don't know the name of your memory stick enter the command
look for the entry under /dev/sda1 you will want the path to the right /media/usbname. This information will also show you how much space you have left on your memory stick.
so at the end of the Raspivid command enter-o /media/usbname/video.h264
Different frame rates are available at different image sizes, the larger the image size the slower the video speed will be. These are the frame rates and image sizes available:
2592 x1944 up to 15 frames per second
1920 x 1080 up to 30 frames per second
1296 x 972 up to 42 frames per second
1296 x 730 up to 49 frames per second
640 x 480 up to 90 frames per second
Converting the video to MP4 for slowmotion playback
Once you have captured your video you will need to convert it so that it plays back in slow motion at 30fps or even 15fps. A program called Mp4Box will simply convert the video to the widely used MP4 format.
You will probably need to install MP4Box first. in LXterminal use the commandsudo apt-get install gpac
to convert the video saved in the current folder use the commandMP4Box -fps 30 -add video.h264 video.mp4
you can now watch your video in slow motion.
Python PiCamera library
With the firmware update and the latest version of the PiCamera python library you can also use the 90 fps video modes in your python programs with the simple command frame rate = 90
#Run the Pi Camera at 90 frames per second for 10 seconds
with picamera.PiCamera() as camera:
camera.resolution = (640,480)
camera.framerate = 90
camera.wait_recording(10) #length of video in seconds
print("Video Recording at 90FPS finished")
get more details about the python picamera here