Help on FFmpeg Binary Sensor

It seems like this sensor introduced in version 0.27 is something I am looking for. If I understand correctly, this sensor will analyze the video stream from my IP cams to detect motion.

However, I have no idea on how to start this.

My HASS is installed in RPi 3 and I have few Hikvision cameras.

In the sensor page, it says…

You need a ffmpeg binary in your system path. On Debain 8 you can install it from backports. If you want Hardware support on a Raspberry Pi you need to build it from sourceby ourself. Windows binary are avilable on FFmpeg homepage.

So I assume by default, Raspbian doesn’t come with ffmpeg binary and I need to install it.

Can anyone guide me on how to install this on my Pi? Thanks.

I was looking into this too when it was first announced but I couldn’t find much info on it. Not that I could understand anyway.

Hopefully someone here is already using it and can give us both a pointer.

I’m also interested in adding an FFmpeg camera to my HA. I’m running it on a raspberry pi. Hope someone who’s managed to install it can help us out :slight_smile:

I have a cheap Vstarcam Eye4 Camera that works surprisingly well despite how cheap it is.

I manage to make some progress. After searching through the net, I managed to install ffmpeg binary in my Pi. This is what I did…

Build and install x264

git clone --depth 1 git://git.videolan.org/x264
cd x264
./configure --host=arm-unknown-linux-gnueabi --enable-static --disable-opencl
make -j4
sudo make install

Build and make ffmpeg

cd
git clone --depth=1 git://source.ffmpeg.org/ffmpeg.git
cd ffmpeg
./configure --arch=armel --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree
make -j4
sudo make install

To test, simply run the command ffmpeg. If you don’t get any errors, you’re all good.

The binary path is at /usr/local/bin/ffmpeg

The camera works as per instruction at FFmpeg Camera.

However, I cannot find any relevant binary_sensor in Developer Tools > States after I add tool: motion into the camera configuration as per instruction at FFmpeg Binary Sensor.

I have no idea what went wrong. Please help.

2 Likes

Hello!

I’m also having trouble. Managed to install FFmpeg (thanks @masterkenobi!) but now I’ve encountered the following issue:

[rtsp @ 0x357a1d0] Could not find codec parameters for stream 0 (Video: h264, none): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Guessed Channel Layout for Input Stream #0.1 : mono
Input #0, rtsp, from 'rtsp://username:[email protected]:10554/tcp/av0_0':
  Metadata:
    title           : streamed by the VSTARCAM RTSP server
  Duration: N/A, bitrate: 64 kb/s
    Stream #0:0: Video: h264, none, 90k tbr, 90k tbn, 180k tbc
    Stream #0:1: Audio: pcm_alaw, 8000 Hz, 1 channels, s16, 64 kb/s
Output #0, null, to 'pipe:':
Output file #0 does not contain any stream

Can anyone help us out? :slight_smile:

I think there is a mistake in the documentation. I believe it should be defined separately as a binary_sensor instead of in the camera domain.

binary_sensor:
  platform: ffmpeg
  tool: motion
  input: rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0
  name: FFmpeg Motion
  ffmpeg_bin: /home/hass/bin/ffmpeg
  extra_arguments: -q:v 2
  changes: 4
  reset: 20
  repeat: 0
  repeat_time: 0

I am still looking at it, but I now see the sensor in HASS and it has triggered several times. Hope this helps. Let me know if you have any further luck with it.

Todd

6 Likes

thanks. it works like a charm.

@fabaff please update the documentation. thanks.

1 Like

Documentation is fixed. Thanks for the report.

2 Likes

I’ve found a much better way to get ffmpeg working.
You need to:

$ sudo apt-get install libav-tools

Then add the following to your configuration

 ffmpeg:
   ffmpeg_bin: /usr/bin/avconv
 ```
I've submitted a pull request to update the documentation.
1 Like

thanks. i have tried it but it is not working.

@masterkenobi @matt2005 @toddeye

I’ve a rpi 3 with raspbian and I install it from backborts: https://packages.debian.org/jessie-backports/ffmpeg that is very easy and fast to install but have no Hardware support for rpi. This binary from backports have a lot of external lib support include x264.

I don’t like avconv.

How to you get backports to raspberry: https://backports.debian.org/Instructions/

Thanks. But what do you mean by this one? Do you need any hardware install on the rpi?

https://trac.ffmpeg.org/wiki/HWAccelIntro

No it’s only if you want to use GPO for some stuff.

Thank you, this helped so much!

Hi all,

Could someone share what kind of denoise filters you use for ffmpeg motion sensor?
I’ve been struggling to find the right extra arguments and other settings to make the sensor react on movements.
Here is my configuration:

 - platform: ffmpeg
     tool: motion
     name: Motion
     input: -rtsp_transport tcp -i rtsp://ip
     change: 0.001
     repeat: 0
     repeat_time: 0
     reset: 60
     extra_arguments: -threads 1 -filter:v "crop=in_w:in_h-65:x=0:y=1215,atadenoise=0a=0.3:0b=5:1a=0.3:1b=5:2a=0.3:2b=5:s=7,eq=contrast=-0.5"

I played with repeat: 2 and repeat_time: 2 values to reduce false positive triggering, however, it didn’t trigger the sensor at all.

Hi @pvizeli,

I know that you are developer of haffmpeg library.
Maybe, when you’ll have time, you could advise regarding my question above what kind of denoise filters you would recomend for ffmpeg motion sensor?

Thanks for that. I remember seeing this a while back and thinking i really do need to set it up. Just followed your example and BOOOM. Am going to experiment but can confirm it toggles from Off to On with motion.

Very handy indeed. Thanks

EDIT: I think I spoke I spoke too soon. Sure it’s working but not very well. Does @pvizeli have this working properly? If so what settings are you using?

Do you know where I can find the documentation detailing all the additional options that you have added? My stream is only updating every 10 seconds and I would like to see if its possible to change this

Here’s a link to the docs.

https://ffmpeg.org/ffmpeg.html

Thanks - I was afraid of that :slight_smile:

I did an “avconv -h full” and about passed out. Looks like its time to become an expert on avconv

1 Like