homebridge / HAP-NodeJS

Node.js implementation of the HomeKit Accessory Protocol (HAP)
Apache License 2.0
2.68k stars 630 forks source link

Camera accesory as stream gateway - raspberry #423

Closed kajaba closed 7 years ago

kajaba commented 7 years ago

Is there a way how to forward stream from other servers (f.ex another raspi with camera streaming its camera) via this accessory? As I looked into Camera.js module, there is a ffmpeg command that starts the stream from local camera. I can change the ffmpeg to take the other servers stream and forward it, but I am having issues with that ffmpegCommand in Camera.js. But Iam not able to make the ffmpeg command work even with simple dummy movie streaming.

I installed precompiled ffmpeg deb package on my raspi. When I used that ffmpeg command it immediately stopped. The problem is that srtp link has parameters. Even the srtp link doesnt work f.ex. in vlc.

KhaosT commented 7 years ago

I'm not sure I get it, do you mean using a video feed as the source?

kajaba commented 7 years ago

Edit: you can install avconv on your raspberry (ffmpeg is not included in packages) sudo apt-get install libav-tools

Then in lib/Camera.js in handleStreamRequest, you change ffmpeg to avconv

and you can use command like this: '-re -i http://SOME-STREAM/LALALALA -threads 0 -vcodec libx264 -an -pix_fmt yuv420p -r '+ fps +' -f rawvideo -tune zerolatency -vf scale=320:240 -b:v '+ bitrate +'k -bufsize '+ bitrate +'k -payload_type 99 -ssrc 1 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params '+videoKey.toString('base64')+' srtp://'+targetAddress+':'+targetVideoPort;

in this srtp:// link the parameters made the command fail. so I removed them :D

kajaba commented 7 years ago

Yes exactly, for me it is better to use other streaming hardware as a source, which does not act as a homekit device. Then write a hap accesory and use existing stream. I dont know if I made myself clear :/