geerlingguy / geerlingguy/pi-dev-playbook

Document video chat/streaming/recording options with the Pi 4

Open
#4 9 comments 0 reactions 0 assignees View on GitHub
planned
Dominant language
No language data
Stars
67
Forks
10
PR merge metrics
No merged PRs in 30d

Description

I have a couple Logitech C920 webcams, and I wanted to see if I could use them while streaming and/or recording clips at 1080p... the problem is "it's complicated", and unlike macOS where there are literally a dozen or so free options with fancy/simple GUIs for the purpose, on Linux/RPi, it's a lot more complex.

The most _reliable_ way to capture video is with `ffmpeg`, but its usage is inscrutable for beginners. And maybe not impossible for me, but it still requires a lot of futzing around.

After reading [this article about streaming 1080p content to YouTube directly](https://www.arrow.com/en/research-and-events/articles/pi-bandwidth-with-video) (without killing your Pi's poor CPU), it was apparent I was in luck that my Logitech C920 has a built-in H.246 encoder that puts out a pre-compressed stream.

Using this incantation gets the video and dumps it into an mp4 file, with minimal CPU usage:

```
ffmpeg -f v4l2 -codec:v h264 -framerate 30 -video_size 1920x1080 -itsoffset 0.5 -i /dev/video0 -copyinkf -codec:v copy -codec:a aac -ab 128k -g 10 -f mp4 test.mp4
```

Using a simpler/more standard example from ffmpeg's documentation, however, results in the Pi's CPU struggling to maintain 5 fps:

```
ffmpeg -f v4l2 -framerate 30 -video_size 1920x1080 -i /dev/video0 output.mkv
```

You might wonder, 'how do you know the webcam is at `/dev/video0`? Well, find it with:

```
$ v4l2-ctl --list-devices
bcm2835-codec-decode (platform:bcm2835-codec):
/dev/video10
/dev/video11
/dev/video12

bcm2835-isp (platform:bcm2835-isp):
/dev/video13
/dev/video14
/dev/video15
/dev/video16

HD Pro Webcam C920 (usb-0000:01:00.0-1.2.3):
/dev/video0
/dev/video1
```

Now, onto finding a way to get my audio interface into the stream...

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.