yuefeiluo
(yufeiluo)
August 24, 2023, 4:02am
1
I have a usb camera,It can capture video with ffmpeg
output="/tmp/sample.flv"
va="-y -f alsa -i default -acodec aac "
ffmpeg -i /dev/video0 $va -pix_fmt yuv420p $output
I installed motion
sudo apt install motion
Set password in /etc/motion/motion.conf:
stream_auth_method 1
stream_authentication admin:123456
Start the motion:
sudo motion
I get an integration with Generic Camera for the use camera.
It works fine in overview,now i want to add a motion detect in configuration.yaml:
binary_sensor:
- platform: ffmpeg_motion
input: http://127.0.0.1:8081/
name: motion detect
Restart homeassistant,the binary sensor is always unavailable!
koying
(Chris B)
August 24, 2023, 9:35am
2
127.0.0.1
is unlikely to be the proper IP, unless you are using a HA Core (pure python) installation.
Try with the actual IP of the host.
yuefeiluo
(yufeiluo)
August 24, 2023, 11:26am
3
1.I am using HA Core
2.replace 127.0.0.1 with the actual IP
The motion detection function still canât take effect.
Should i add user and passwd in ffmpeg_motion,how?I added it when to make an integration with Generic Camera!
koying
(Chris B)
August 24, 2023, 12:06pm
4
Can you tell if http://127.0.0.1:8081/
is working out of HA?
yuefeiluo
(yufeiluo)
August 24, 2023, 12:20pm
5
I fill username and password,it can sign in.
koying
(Chris B)
August 24, 2023, 12:25pm
6
Great, but ffmpeg_motion
is expecting an actual video feed. Itâs the integration that does the detection.
Is this what you are using: https://motion-project.github.io ? Then youâre mistaken.
2 options:
yuefeiluo
(yufeiluo)
August 24, 2023, 11:56pm
7
I downloaded a apk named âIP Camera Viewer_7.4.7_Apkpure.apkâ,installed on my old android phone,to turn my old smartphone into a webcamera,and make integration in homeassistantâs ffmpeg_motion:
binary_sensor:
- platform: ffmpeg_motion
name: "android smartphone camera motion"
input: rtsp://admin:[email protected] :8554/live
All the motion can be detected.With same way,i canât make integration for my usb camera!Why?
koying
(Chris B)
August 25, 2023, 5:55am
8
Mmmm⌠Did you understand what I said?
yuefeiluo
(yufeiluo)
August 26, 2023, 2:39am
9
2 options:
* Pass the usb cam directly to `ffmpeg_mtion`
* Use a dedicated integration;
How can pass my usb cam directly to ffmpeg_motion?
It canât work!
- platform: ffmpeg_motion
input: /dev/video0
name: motion_directly
koying
(Chris B)
August 26, 2023, 7:23am
10
Donât DM me
Look at the doc, itâs literary there
yuefeiluo:
input: /dev/video0
I guess this should work, IF you are on HA Core or have mapped the device to the HA container.
Unlikely to work in HAOS
yuefeiluo
(yufeiluo)
August 26, 2023, 3:31am
11
In my os:
lsusb | grep -i camera
Bus 001 Device 004: ID 2bdf:0284 SN0002 HIK 1080P CAMERA
ls /dev/video*
/dev/video0 /dev/video1
I want to pass the HIK 1080P CAMERA directly to ffmpeg_motion,googled a tutorial âintegrate USB local camera to home assistantâ
https://www.kincony.com/forum/showthread.php?tid=1841
The main points are as below:
connect with your USB camera.
Enable home assistant âAdvanced Modeâ.
âAdd-ons, Backups & Supervisorâ â âsystemâ â âHostâ â âHardwareâ , search videox
Configuration edit yaml
camera:
platform: ffmpeg
name: cam
input: /dev/input/video0
Home assistant restart
Add camera to dashboard by âpicture entityâ card
In the youtube,
For the step3 ,i canât find hardware to search video!
My hass info:
Version
core-2023.7.3
Installation Type
Home Assistant Core
Development
false
Supervisor
false
Docker
false
User
homeassistant
Virtual Environment
true
Python Version
3.11.0rc2
Operating System Family
Linux
Operating System Version
5.10.0-23-amd64
CPU Architecture
x86_64
Timezone
Asia/Hong_Kong
Configuration Directory
/home/homeassistant/.homeassistant
Home Assistant Community Store
MANAGE
GitHub API
ok
GitHub Content
ok
GitHub Web
timeout â more info
GitHub API Calls Remaining
4962
Installed Version
1.32.1
Stage
running
Available Repositories
1267
Downloaded Repositories
2
Home Assistant Cloud
MANAGE
Logged In
false
Reach Certificate Server
ok
Reach Authentication Server
ok
Reach Home Assistant Cloud
ok
Dashboards
MANAGE
Dashboards
1
Resources
0
Views
1
Mode
storage
Recorder
Oldest Run Start Time
17 August 2023 at 05:17
Current Run Start Time
26 August 2023 at 10:55
Estimated Database Size (MiB)
9.51 MiB
Database Engine
sqlite
Database Version
3.34.1
There are only processors and memory !I canât search device /dev/video0 or /dev/video1,so canât add it.
I have enabled Advanced Mode.
francisp
(Francis)
August 26, 2023, 6:04am
12
Did you try video0 or video1 ?
yuefeiluo
(yufeiluo)
August 26, 2023, 6:25am
13
In the youtubeâs video,the auther can find a place to search.
âAdd-ons, Backups & Supervisorâ â âsystemâ â âHostâ â âHardwareâ , search videox
In my homeassistant ,there is no place i can type video to search!I can search nothing!
How about in your latest version homeassistant?
francisp
(Francis)
August 26, 2023, 6:47am
14
I can, but I donât run HA Core, but HA Supervised. Could be a function of Supervisor.
yuefeiluo
(yufeiluo)
August 26, 2023, 6:56am
15
camera:
- platform: ffmpeg
name: usb camera1
input: /dev/video0
- platform: ffmpeg
name: usb camera2
input: /dev/input/video0
None of them can work!
koying
(Chris B)
August 26, 2023, 7:56am
16
yuefeiluo:
ls /dev/video*
Do a ls -l /dev/video*
to check permissions
yuefeiluo
(yufeiluo)
August 26, 2023, 9:04am
17
ls -al /dev/video0
crw-rw----+ 1 root video 81, 0 Aug 26 16:53 /dev/video0
ls -al /dev/video0
crw-rw----+ 1 root video 81, 0 Aug 26 16:53 /dev/video0
debian@debian:~$ sudo chmod 777 /dev/video0
debian@debian:~$ sudo chmod 777 /dev/video1
debian@debian:~$ sudo systemctl restart hass
It is no use,sitll canât work!
francisp
(Francis)
August 26, 2023, 9:17am
18
add your hass user to the video group
https://wiki.debian.org/SystemGroups