Ffmpeg Camera help/question

Hi,

I’ve set up 2 ffmpeg cameras in my configuration.yaml file, which point to 2 traffic camera streams in my area. It works perfectly, however I notice after some time, resources will peg, which shouldn’t be happening (I’m running in a VM with plenty of RAM/CPU, not in Pi). When I look in the OS, I see this:

mike@ubuntu:~$ ps -ef | grep ffm
mike     126791 126706  2 12:43 ?        00:00:13 ffmpeg -i http://8.15.251.102:1935/rtplive/R4_104/playlist.m3u8 -an -c:v mjpeg -q:v 2 -f mpjpeg -
mike     126899 126706  2 12:45 ?        00:00:09 ffmpeg -i http://8.15.251.102:1935/rtplive/R4_104/playlist.m3u8 -an -c:v mjpeg -q:v 2 -f mpjpeg -
mike     126910 126706  2 12:46 ?        00:00:11 ffmpeg -i http://8.15.251.102:1935/rtplive/R4_105/playlist.m3u8 -an -c:v mjpeg -q:v 2 -f mpjpeg -
mike     126939 126706  2 12:46 ?        00:00:10 ffmpeg -i http://8.15.251.102:1935/rtplive/R4_105/playlist.m3u8 -an -c:v mjpeg -q:v 2 -f mpjpeg -

The two streams are doubled up, even though I have no browsers actively viewing it, nor do these processes ever terminate after 10 minutes, for example. Is this by design? Should I add some sort of additional parameter to ffmpeg that only captures 60 seconds of footage as a workaround?

Thanks for any info!

EDIT: Right after posting, 3 of the 4 processes died off without any intervention on my part. Perhaps I need to just be more patient…

mike@ubuntu:~$ ps -ef | grep ffm
mike     126791 126706  2 12:44 ?        00:00:22 ffmpeg -i http://8.15.251.102:1935/rtplive/R4_104/playlist.m3u8 -an -c:v mjpeg -q:v 2 -f mpjpeg -

I also suspect I had doubled up processes since I viewed both feeds from my phone and my desktop?

EDIT 2:

After all ffmpeg processes died out, I simply viewed a camera feed twice from my phone, and now I see 4 processes on same source:

mike@ubuntu:~$ ps -ef | grep ffm
mike     127153 126706  5 13:01 ?        00:00:00 ffmpeg -i http://8.15.251.102:1935/rtplive/R4_104/playlist.m3u8 -an -c:v mjpeg -q:v 2 -f mpjpeg -
mike     127157 126706  5 13:01 ?        00:00:00 ffmpeg -i http://8.15.251.102:1935/rtplive/R4_104/playlist.m3u8 -an -c:v mjpeg -q:v 2 -f mpjpeg -
mike     127158 126706  5 13:01 ?        00:00:00 ffmpeg -i http://8.15.251.102:1935/rtplive/R4_104/playlist.m3u8 -an -c:v mjpeg -q:v 2 -f mpjpeg -
mike     127162 126706  7 13:02 ?        00:00:00 ffmpeg -i http://8.15.251.102:1935/rtplive/R4_104/playlist.m3u8 -an -c:v mjpeg -q:v 2 -f mpjpeg -

So yes, I am still confused what I’m doing wrong :slight_smile:

Here’s my YAML btw:

camera: 
  - platform: ffmpeg
    name: I-240 Poplar
    extra_arguments: -q:v 2
    input: http://8.15.251.102:1935/rtplive/R4_104/playlist.m3u8
  - platform: ffmpeg
    name: I-240 Walnut Grove
    extra_arguments: -q:v 2
    input: http://8.15.251.102:1935/rtplive/R4_105/playlist.m3u8

I see one process when nothing is loaded but I do see two procs when I view a camera. They are not as identical as yours though; in my case one of them seems to be the stream and the other is doing the still frame thumbnail.

The only difference between your YAML and mine is that I am not using any extra arguments - just an observation, not meant to explain. Well that and me running it on a Pi. :relaxed:

Yeah, I see occasional processes that are doing the image grabs but they disappear quickly but these other pids stay around for a long time. For now, I’m adding a a -t 00:00:10 parameter which from my understanding will cut the ffmpeg feed after 10 seconds as a silly workaround.

1 Like