Has anyone had good success with the ffmpeg motion sensor

I have a camera where the motion sensor does not work. I’m not interested in installing mqqt/motion eye at the moment, its more than I need. I came across this yesterday

and I thought, nice, this is just what I need. I already have my camera’s doing an ffmpeg stream. I set it up, and sure enough, it seemed to work. Motion sensor showed up, and triggered fine. Then after a while it stopped working. I followed the recommendations in the documentation and ran " ffmpeg.restart" on the sensor and it started working again. Went to bed, and woke up to the sensor in an “unknown” state. restarted again, and it’s working. Obviously having to restart all the time is not optimal.

I guess I want to know before I go down this rabbit hole. Is this sensor stable for others? Any tips or settings that might be useful? I’m running this on ubuntu venv, on a i5 processor with 4gb ram, so I dont think it an issue with resources.

Hello, I am just starting to try to use the ffmepg motion as well. Any chance you could post your config for the binary…
I’m using a webcam for testing… Have tried Motion and am not that happy with it…
Thanks

here’s what I was using. After 2-3 days, I’ve already stopped.

 - platform: ffmpeg_motion
   input: !secret camera_url_1
   name: Front Door Camera Motion
   extra_arguments: -pred 1 -q:v 2
   changes: 10
   reset: 30

Might just be the camera I’m using, but after a few hours it dies, and I had to do a ffmpeg.restart. Also, it took 25-30% of my CPU all the time, just for the single sensor.

Any update on this?
I just created an ffmpeg binary sensor and am having the same issue.

Could this have something to do with the sever sleeping the inactive ffmpeg?
I have a camera setup with ffmpeg that has no issue, so my thought is maybe something the server is killing due to inactivity?

Hmm, interesting though. Honestly I gave up, too much CPU and it kept failing, ended up going another route and just adding an old zwave motion sensor I had laying around.

Success! Ok here is what I did:

  1. First, I put this at the very top of my configuration.yaml:
binary_sensor:
  - platform: ffmpeg_motion
    input: !secret nvr3_password
    extra_arguments: -q:v 2
    changes: 1
    reset: 5
    repeat: 2
    repeat_time: 3
  1. Then further down in my config I have the following info:
# Begin Cameras ##########################################################################################################

camera 1:
- platform: ffmpeg
  input: !secret nvr3_password
  name: front_door
  
#End Cameras 
=#########################################################################################################

Hope this helps someone.

PS: That “!secret nvr3_password” part points to a separate secrets file which contains the following rstp connection info:

nvr3_password: rtsp://usename:password@ipaddress:port/H264/ch3/main/av_stream
4 Likes

Worked for me as well! Thanks for sharing @error420

1 Like

Can someone explain me what this extra argumens mean? It worked by the way, so thanks.
Also, does anybody know what are the units of the configuration params? repeat_time, are seconds? minutes? same for reset.

1 Like

I’m not 100% sure but I think the “-q:v 2” is to set the quality for the incoming video to a variable bitrate of 2 frames per second

check out this website:https://www.ffmpeg.org/ffmpeg-codecs.html#jpeg2000

repeat_time is seconds but others might be frames or changes. More info below.

Thanks for your answer.

I already read the entire documentation of the ffmpeg motion and it does not specify what unit of time it is used, it just says “time”.

By the way, does this keep working for anyone? For me it dies after a couple of hours and only starts working again if I reset home-assistant

Mine does not die. What are the specs of the host it is running on?

1 Like

It is a VM with 4gb of ram and two cores running on an intel nuc.
It is not dying now, but it is not consistent either. I have some events that are detected by the wyze-cam, and the wyze app sends them to me and I don’t get any from the ffmpeg integration, then I get some other events when there is almost no diff on the image, which is what I configured it for, but I don’t understand how it is missing clear motion events like cars or people moving around while the wyze app is able to detect them no problem.

I’m sorry to resurrect this old topic but I’m struggling with the same subject, ffmpeg is working, the process seems to be watching for image modifications (I can see the process with the rights parameters running), but nothing really seems to happen. Here’s the configuration I’m using:

binary_sensor:
  - platform: ffmpeg_motion
    input: !secret dlink_p6000lh
    changes: 2
    repeat: 2
    repeat_time: 3

camera:
  - platform: ffmpeg
    name: D-Link P6000LH
    input: !secret dlink_p6000lh

where dlink_p6000lh is "-rtsp_transport tcp -i rtsp://user:[email protected]/live/profile.0"

have you the possiblité to start or stop ffmpeg_motion entity detection ?