So, after a lot of debugging, I have an understanding of what’s happening. Basically, the ffmpeg command is only used to capture still images every 10 seconds. When you click on a picture card in the UI, it starts a stream object, not the ffmpeg command that you’ve set up in configuration.
Debugging Details:
- Enable
ffmpeg, add your ffmpeg camera withextra_arguments
ffmpeg:
ffmpeg_bin: /usr/bin/ffmpeg
camera:
- platform: ffmpeg
name: ffmpeg_front_door
input: '-rtsp_transport tcp -i rtsp://user:pass@camFrontDoor:554/h264Preview_01_main'
extra_arguments: -s 640x480
- Enable debug verbosity for haffmpeg and stream components
logger:
default: info
logs:
stream: debug
haffmpeg: debug
-
Add a picture entity card to the UI and set the camera view to auto
-
Restart and refresh your web-browser. These messages should show up in the log every 10 seconds. Note that the
extra_argumentsare preserved and only 1 frame of video is captured from the input stream to create the still image in the UI
2020-08-18 21:23:27 DEBUG (MainThread) [haffmpeg.core] Start FFmpeg with ['/usr/bin/ffmpeg', '-rtsp_transport', 'tcp', '-i', 'rtsp://user:pass@camFrontDoor:554/h264Preview_01_main', '-an', '-frames:v', '1', '-c:v', 'mjpeg', '-s', '640x480', '-f', 'image2pipe', '-' -
click on the image and you should get a
streammessage. Theextra_argumentsare ignored.
2020-08-18 21:30:09 INFO (MainThread) [homeassistant.components.stream] Started stream: rtsp://user:pass@camFrontDoor:554/h264Preview_01_main
Workaround
@salle found that a proxy camera can be used to start ffmpeg with the extra_arguments instead of the stream object.
However, I found the ffmpeg process did not shut itself down reliably and end up with multiple encoders running at the same time
Conclusion
I wanted to use the ffmpeg_camera to re-encode a stream that could be consumed by my google home hub, however there are some pretty big limitations to using ffmpeg within home assistant
- stream objects are used instead of the ffmpeg comand that is configured for the camera
- The
haffmpegcomponent is hard coded to use mjpeg encoding only. - The workaround using a proxy camera is not reliable.
- Proxy cameras cannot be recorded or streamed to other devices.