Get image and video from raspberry pi

Getting Image and Video from Raspberry Pi Camera

One of the interesting feature on Raspberry pi is the camera interface. But it dosen’t work out of box to view the camera feed. There are several ways to do it.

There are few ways to get image or video feed from Raspberry Pi camera. Let’s explore through the options available.

Requried items:
1. Raspberry Pi
2. Pi Camera ( Camera Module V2 or Pi NOIR Camera V2)
* Older versions are usable as well

Check out following articles to get started before proceesing to next section
Getting Started with Raspberry Pi
How to Flash Rapian into SD Card

Before we begin, make sure the Pi Camera is connected as per below

Pi Camera

Please refer to this page for more detailed instructions. (By Raspberry Pi Foundation)

Option 1 – Using raspistill or raspivid

Simply type following command to obtain an image

raspistill -o cam.jpg

This command obtains image at full device resolution.
Get list of extensions usable for raspistill here

As for to obtain video, key in command as below

raspivid -0 video.h264 -t 10000

It take video for 10seconds and stores at Home folder
Get list of extensions usable for raspivid here

Option 2 – Using PiCamera

PiCamera is included by default in Raspian
In any case, if require installation, just key in commands as below;

sudo apt-get update
sudo apt-get install python-picamera python3-picamera

To obtain an image, create a file and insert the codes below

from time import sleep 
from picamera import PiCamera

camera = PiCamera()
camera.resolution = (1024, 768)
# Camera warm-up time

Save the file. Run using terminal with command below. (Assuming file at home directory)


A sample test.jpg image will be stored at home folder. For more information click here.

For video recording, create new python file with code below and run in. You will obtain a test.h264 video at home folder.

import picamera 
camera = picamera.PiCamera()
camera.resolution = (640, 480)

Above method applicable to get images or video from Raspberry Pi camera module. In the next post we will cover on how to stream this camera feed.

Share this:

Leave a Reply

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

This site uses cookies to offer you a better browsing experience. By browsing this website, you agree to our use of cookies.