# How do I stream a RaspiCam?

## Use Raspicam as video source for live streaming in datarhei Restreamer

Check that the device is installed correctly before the restreamer recognizes the camera module. As soon as the device is available on the host system, it is automatically displayed in the Restreamer.

{% embed url="<https://youtu.be/ahawoTRDLEw>" %}
**YouTube video:** Using Raspicam as video source for live streaming
{% endembed %}

There are several types of camera boards available for the Raspberry Pi. The official Raspberry Pi cameras can take high-resolution photos and Full HD 1080p videos and be fully controlled. After the installation in the "raspi-config" menu, all cameras can be used in the Restreamer for live streaming.

{% hint style="danger" %} <mark style="color:red;">ATTENTION!</mark> Using the GPU with the Raspicam requires increasing the cache memory to 256 MB.  >> [To the guide](https://www.raspberrypi.com/documentation/computers/config_txt.html#gpu_mem) <<
{% endhint %}

{% hint style="warning" %}
If unexpected behavior occurs, rebooting the Raspberry Pi might help.
{% endhint %}

{% hint style="warning" %}
If unexpected behavior occurs, restarting the datarhei Restreamer might help.
{% endhint %}

{% hint style="success" %}
Note the video where we explain encoding over the GPU from the Raspberry Pi to offload the CPU from the Raspberry Pi.
{% endhint %}

## Enabling the Pi Camera

If you have a Pi camera connected to your Raspberry Pi and you want capture a stream from it, you first need to make it available as a "video4linux" device.

#### Raspbian buster or earlier

On the console, type `sudo modprobe bcm2835-v4l2` and restart Restreamer. Then you should be able to select the Pi camera in the wizard or advanced setup.

#### Raspbian bullseye

With the latest Raspbian (bullseye) the tools for the camera are based on `libcamera` which is not necessarly compatible with video4linux and is currently not supported by ffmpeg directly. In order to make the camera available as a video4linux device you have to switch it into legacy mode:

1. Open `/boot/config.txt` in an editor, e.g. `sudo nano /boot/config.txt`
2. Replace the line `camera_auto_detect=1` with `start_x=1`
3. Add `gpu_mem=256` right after the line with `start_x=1`
4. Replace the line with `dtoverlay=vc4-kms-v3d` with `dtoverlay=vc4-fkms-v3d`
5. Save the file and exit the editor
6. Reboot the Pi

After the Pi rebooted you should see the Pi camera option in the UI.

Alternatively, you can run sudo raspi-config and enable the legacy camera support in the `Interface Options` section. This will only allocate 128MB GPU memory and will only allow HD streaming (1280x720). If you want FullHD streaming (1920x1080), then open `/boot/config.txt` in an editor and change the line with `gpu_mem=128` to `gpu_mem=256`.

#### Raspbian bookworm or later

With the release of Raspbian "bookworm", the legacy mode for the camera is not anymore available and the camera can't be accessed anymore directly from ffmpeg. We recommend to install Raspbian "bullseye" and follow the instructions above.

## Learn more

{% content-ref url="" %}
[](https://docs.datarhei.com/restreamer/knowledge-base/user-guides)
{% endcontent-ref %}

{% content-ref url=".." %}
[..](https://docs.datarhei.com/restreamer/knowledge-base)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.datarhei.com/restreamer/knowledge-base/user-guides/how-do-i-stream-a-raspicam.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
