FFmpeg Camera - no video (Codec problems?) (USB)

Cheers guys. Over the last days, i’ve been trying to set up a USB webcam via FFmpeg. I’m quite green when it comes to this kinda stuff so apologies if I talk any nonsense.

So the first issue was, that the test recording command ( the one from the official home assistant page about FFmpeg ) :

$ ffmpeg -i /dev/video0 -codec:v libx264 -qp 0 lossless.mp4

would only record a black video without sound that would skip right to the end when played in a media player. I believe to have figured out that that’s caused by the fact that my webcam (Logitech c922) seems to have some kind of hardware encoding included. I managed to fix this by adding the -f video4linux2 line before -i and changed the output format from .mp4 to .mpeg. Also, I had to remove the -codec:v libx264 for it to finally record some viewable video footage. So the complete command that I managed to get working on a test recording is:

$ ffmpeg -f video4linux2 -i /dev/video0 lossless.mpeg

Now back to what I’m actually trying: Implementing this into my Home Assistant Interface via the FFmpeg Camera Component.

First of all, let’s see what I’ve already got entered in my config:

For the FFmpeg component:

  ffmpeg_bin: /usr/bin/ffmpeg

And for the Camera component:

  - platform: ffmpeg
      input: -i /dev/video0
      extra_arguments: -f video4linux2 

So far so good, I’m not getting any errors from the config… BUT sadly the Camera panel in the frontend still shows “FFmpeg (Image not available)”. I’ve tried adding different extra_arguments but nothing changed. So now I’m out of ideas and need some help adjusting this. I have a few suspicions like for example that that’s caused by the same thing that won’t let me record .mp4 videos, forcing me to record in .mpeg format but then again I have not a single clue what I’m talking about.

Any and all help is greatly appreciated!

Hi friend, were you able to make it work? Any updates on the configuration?


Sadly i wasn’t, i went through a bunch of more parameters to add but i couldn’t make it work. Any help would be appreciated!

Hey, I just got my camera to work but mine is IP (not usb as I guess from your configuration).

This is my config:



  • platform: ffmpeg
    input: rtsp://

Only difference I can tell is that I let the default ffmpeg bin (running on macOS).

Interestingly I can’t make onvif platform to work, but ffmpeg is a start. Now to being able to ptz it.

Ip works fine on my System as well. The problem lies within the camera itself and the hardware x264 encoder thats built in, might have to consider another camera unless someone knows a fix since i find running an additional ip cam server too resource consuming

Edit: Ive managed to get FFmpeg to record mp4 as well by adding the -pix_fmt yuv420p tag. Sadly, adding the tag to extra_arguments still doesn’t get the video feed to run.

I had the same issue. The problem was that the homeassistant user was not part of the video group. (which my pi user were and that’s why the recording worked)

1 Like