NRCHKB / node-red-contrib-homekit-bridged

Node-RED Contribution - HomeKit Bridged : Node-RED nodes to simulate Apple HomeKit devices.
https://nrchkb.github.io
MIT License
412 stars 52 forks source link

[Help needed]: CameraControl ffmpeg issues #447

Closed lurendrejer closed 2 years ago

lurendrejer commented 2 years ago

Your Current NRCHKB Plugin Version

1.4.2

Operating System

Ubuntu 21.04

How can we help?

ffmpeg doesn't even seem to start - I have added -report to the command-line but no 'log-file' gets created. ffmpeg is installed via apt install ffmpeg and works when started manually.

There are no errors in the the NR-console - not even when debugging is turned on (found in another thread how to turn this on for homekit)

The command line in the camera node is 'ffmpeg' - I have tried with /usr/bin/ffmpeg with the same result.

image

ffmpeg is installed

How can I debug this?

Any more details?

If this is specific to some hardware or specific software version, please explain here.

Any code or functions to add?

No response

crxporter commented 2 years ago

Calling @Shaquu our ffmpeg master. I use it but if it doesn't work right then I have no idea.

Best is probably to run with nrchkb debug and find the ffmpeg error - but I can't find the instructions to do that right now...

Shaquu commented 2 years ago

This is the way:

lurendrejer commented 2 years ago

Hi, and thank you.

I already did exactly that - but it doesn't write anything in the console :)

lurendrejer commented 2 years ago

Sorry, it does write a lot but nothing regarding ffmpeg

lurendrejer commented 2 years ago

I also tried setting debug and trace to default logging level in node red, to no avail

lurendrejer commented 2 years ago

Calling @Shaquu our ffmpeg master. I use it but if it doesn't work right then I have no idea.

Best is probably to run with nrchkb debug and find the ffmpeg error - but I can't find the instructions to do that right now...

I already found the instructions in another thread :)

lurendrejer commented 2 years ago

It doesn't even seem to start ffmpeg - at all. I get an error when it generates the thumbnail that ffmpeg returned an empty image. But I still think that it doesn't even start ffmpeg

I already have the same setup on homebridge - so the snapshot-url is correct.

image

Shaquu commented 2 years ago

I guess it would be good to see those logs :)

lurendrejer commented 2 years ago

I'll get on it as soon as I'm home

lurendrejer commented 2 years ago

I think i might have missed something crucial in my debugging....

nrchkb/logger is something extra that i need to install. I just ran 'DEBUG=NRCHKB* node-red' and got the exact same output as always.

I'm looking into how i install right now. I might be completely off... but i'm trying my best here.

//Edit, ok - i'm mixing stuff up - the logs are there in a second

lurendrejer commented 2 years ago

9 Oct 12:38:40 - [error] [atvx-config:Soveværelse AppleTV] Bad token (re-Pairing Apple TV) or Disconnected 9 Oct 12:38:40 - [error] [atvx-config:Stue AppleTV] Bad token (re-Pairing Apple TV) or Disconnected [CamTest1] Snapshot request handler provided empty image buffer! 09 Oct 12:39:15 NRCHKB:ServiceUtils [Stue:8f6d578920e10e29] onCharacteristicGet with status: 0, value: false, reachability is true with context undefined on connection 0c6ff91d-81b3-4cae-a490-a1e5744d5b5b +48s [CamTest1] Snapshot request handler provided empty image buffer!

The last line is what i got when i tried to open the camera from my macbook. I'm i right about it not even trying to launch ffmpeg?

lurendrejer commented 2 years ago

Logs after setting camera-node debug to on and opening the cam again:

9 Oct 12:43:31 - [info] Stopping modified nodes 9 Oct 12:43:31 - [info] Stopped modified nodes 9 Oct 12:43:31 - [info] Starting modified nodes 9 Oct 12:43:31 - [info] Started modified nodes 09 Oct 12:43:31 NRCHKB:HAPServiceNode [CamTest1:811bae60829f0280] Starting Parent Service +0ms 09 Oct 12:43:31 NRCHKB:AccessoryUtils [CamTest1:811bae60829f0280] Looking for accessory with service subtype 3ca36974-c267-4bcd-b5f8-785070f2c516 ... +0ms 09 Oct 12:43:31 NRCHKB:AccessoryUtils [CamTest1:811bae60829f0280] ... found it! Updating it. +1ms 09 Oct 12:43:31 NRCHKB:AccessoryUtils [CamTest1:811bae60829f0280] Bridge now has 2 accessories. +1ms 09 Oct 12:43:31 NRCHKB:ServiceUtils [CamTest1:811bae60829f0280] Looking for service with UUID 3ca36974-c267-4bcd-b5f8-785070f2c516 ... +0ms 09 Oct 12:43:31 NRCHKB:ServiceUtils [CamTest1:811bae60829f0280] ... found it! Updating it. +0ms 09 Oct 12:43:31 NRCHKB:ServiceUtils [CamTest1:811bae60829f0280] onCharacteristicSet with status: 0, value: CamTest1, reachability is true NRCHKB:ServiceUtils with context undefined on connection undefined +5m 09 Oct 12:43:31 NRCHKB:ServiceUtils [CamTest1:811bae60829f0280] onCharacteristicChange with reason: write, oldValue: CamTest1, newValue: CamTest1, reachability is true NRCHKB:ServiceUtils with context undefined on connection undefined +1ms 09 Oct 12:43:31 NRCHKB:ServiceUtils [CamTest1:811bae60829f0280] CamTest1 received Name : CamTest1 +1ms 09 Oct 12:43:31 NRCHKB-Trace:CharacteristicUtils [CamTest1:811bae60829f0280] Evaluating value: +0ms 09 Oct 12:43:31 NRCHKB-Trace:CharacteristicUtils [CamTest1:811bae60829f0280] {} +1ms 09 Oct 12:43:31 NRCHKB-Trace:CharacteristicUtils [CamTest1:811bae60829f0280] Evaluated as: +0ms 09 Oct 12:43:31 NRCHKB-Trace:CharacteristicUtils [CamTest1:811bae60829f0280] {} +1ms [CamTest1] Snapshot request handler provided empty image buffer!

Shaquu commented 2 years ago

Are you sure that you are using Debug flag? image

Can you share your flow?

lurendrejer commented 2 years ago

110% image

Shaquu commented 2 years ago

@lurendrejer sorry, my mistake. You need to start nodered with DEBUG=NRCHKB*,CameraSource*

Wiki fix on the way NRCHKB/NRCHKB.github.io#60

lurendrejer commented 2 years ago

That did show me a lot more, going through it now - thank you. And - it confirmed something odd: I get the first snapshot after er restart just fine - the following snapshots are empty.

09 Oct 14:52:31 NRCHKB:HAPHostNode [node-red1:5ce20625ff476b77] Publishing Bridge with pin code 111-11-111 and 2 accessories +5s Preparing Advertiser for 'node-red1 2589' using bonjour-hap backend! 09 Oct 14:52:31 NRCHKB:BridgeUtils [CamTest1:811bae60829f0280] Bridge published +0ms Starting to advertise 'node-red1 2589' using bonjour-hap backend! 09 Oct 14:52:32 NRCHKB:ServiceUtils [CamTest1:811bae60829f0280] onCharacteristicGet with status: 0, value: CamTest1, reachability is true with context undefined on connection c3503a7c-5483-4d2c-88ec-91e19055b4f9 +0ms 09 Oct 14:52:32 NRCHKB:ServiceUtils [CamTest1:811bae60829f0280] onCharacteristicGet with status: 0, value: false, reachability is true with context undefined on connection c3503a7c-5483-4d2c-88ec-91e19055b4f9 +1ms 09 Oct 14:52:32 NRCHKB:ServiceUtils [Stue:8f6d578920e10e29] onCharacteristicGet with status: 0, value: Stue, reachability is true with context undefined on connection c3503a7c-5483-4d2c-88ec-91e19055b4f9 +0ms 09 Oct 14:52:32 NRCHKB:ServiceUtils [Stue:8f6d578920e10e29] onCharacteristicGet with status: 0, value: false, reachability is true with context undefined on connection c3503a7c-5483-4d2c-88ec-91e19055b4f9 +0ms CameraSource Snapshot from CamTest1 at 320x240 +18s CameraSource ffmpeg -i http://admin:******@10.0.0.82/Streaming/channels/1/picture -t 1 -s 320x240 -f image2 - +1ms CameraSource Sending camera snapshot buffer to output...{"payload":{"cameraSnapshot":{"type":"Buffer","data":[]}},"name":"CamTest1"} +96ms [CamTest1] Snapshot request handler provided empty image buffer! 09 Oct 14:52:44 NRCHKB:ServiceUtils [Stue:8f6d578920e10e29] onCharacteristicGet with status: 0, value: false, reachability is true with context undefined on connection d6394419-caa6-4d20-a93c-93d0bf885c2b +12s CameraSource Snapshot from CamTest1 at 320x240 +656ms CameraSource ffmpeg -i http://admin:******@10.0.0.82/Streaming/channels/1/picture -t 1 -s 320x240 -f image2 - +0ms CameraSource Sending camera snapshot buffer to output...{"payload":{"cameraSnapshot":{"type":"Buffer","data":[]}},"name":"CamTest1"} +101ms [CamTest1] Snapshot request handler provided empty image buffer! CameraSource Snapshot from CamTest1 at 320x240 +261ms CameraSource ffmpeg -i http://admin:******@10.0.0.82/Streaming/channels/1/picture -t 1 -s 320x240 -f image2 - +0ms 9 Oct 14:52:45 - [error] [atvx-config:Soveværelse AppleTV] Bad token (re-Pairing Apple TV) or Disconnected 9 Oct 14:52:45 - [error] [atvx-config:Stue AppleTV] Bad token (re-Pairing Apple TV) or Disconnected CameraSource Sending camera snapshot buffer to output...{"payload":{"cameraSnapshot":{"type":"Buffer","data":[255,216,255,224,0,16,74,70,73,70,0,1,2,0,0,126,0,95,0,0,255,254,0,16,76,97,118,99,53,56,46,57,49,46,49,48,48,0,255,219,0,67,0,8,8,8,9,8,9,11,11,11,11,11,11,13,12,13,13,13,13,13,13,13,13,13,13,13,14,1//Snipped to avoid uploading an image of my house //71,58,16,182,202,23,68,186,114,209,104,184,49,233,153,243,156,107,9,234,40,185,106,234,109,58,162,196,249,61,89,100,31,142,177,181,23,214,236,245,104,86,21,238,182,229,254,221,254,26,195,231,173,246,213,44,238,41,190,73,169,243,206,116,140,207,255,217]}},"name":"CamTest1"} +915ms CameraSource Snapshot from CamTest1 at 320x240 +1m CameraSource ffmpeg -i http://admin:******@10.0.0.82/Streaming/channels/1/picture -t 1 -s 320x240 -f image2 - +8ms CameraSource Sending camera snapshot buffer to output...{"payload":{"cameraSnapshot":{"type":"Buffer","data":[]}},"name":"CamTest1"} +89ms [CamTest1] Snapshot request handler provided empty image buffer! CameraSource Snapshot from CamTest1 at 320x240 +31s CameraSource ffmpeg -i http://admin:******@10.0.0.82/Streaming/channels/1/picture -t 1 -s 320x240 -f image2 - +1ms CameraSource Sending camera snapshot buffer to output...{"payload":{"cameraSnapshot":{"type":"Buffer","data":[]}},"name":"CamTest1"} +89ms [CamTest1] Snapshot request handler provided empty image buffer!

lurendrejer commented 2 years ago

It still doesn't even try to start the video - as far as i can see

lurendrejer commented 2 years ago

I just ran the snap-shot ffmpeg command three times in succession in the terminal - everything were fine :-/ Homebridge still also manages to get the snapshot every time.

Looking further: It does seem to get the snapshot each time (more or less) - it just doesn't show up in the 'home-app'.

Video doesn't even try to start.

Shaquu commented 2 years ago

I would suggest to find what is exactly executed by homebridge. Ffmpeg command may differ even if fields has the same values.

lurendrejer commented 2 years ago

Ok. I don't think it is directly translatable - since homebridge uses a different ffmpeg build, specially made for this thing. (ffmpeg-for-homebridge, i think)

lurendrejer commented 2 years ago

and/but - the videos capture-ffmpeg doesn't even get called if i'm reading the debug info correctly. Am I wrong here?

Shaquu commented 2 years ago

Have you tried opening stream on iPhone?

lurendrejer commented 2 years ago

On an iPad and appletv only. I'm on Android.

Shaquu commented 2 years ago

Okay. Can you open stream in Home.app and share logs which are displayed? By open I mean video and not snapshot view.

lurendrejer commented 2 years ago

Hi. In the already attached log i opened the app, opened the cameras video feed (which failed) and force closed the app three times. :)

Shaquu commented 2 years ago

Hi, I know that it sounds boring but can you make a test again but this time share full log since node-red startup?

lurendrejer commented 2 years ago

Sorry, I completely removed the homekit-nodes - I'll be going with my current solution instead, for now. I think the above log was everything - right from the startup of node-red.

Shaquu commented 2 years ago

Sure, tag me when required.