-
-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to enable two way audio? #174
Comments
+1 |
Unfortunately this does not seem to work. I bought a new camera to test this. Via the app of the manufacturer its working, not via homebridge. I found something interesting here: https://github.com/thoukydides/homebridge-skybell/issues/9 |
How do you managed to instruct the homebridge client that camera has a speaker and then start stream to the camera? |
If you mean try it yourself and use it for your camera:
If you mean from a programming perspective: For "Camera has a microphone and speaker": |
Thanks Daniel now I have audio input active, do you mean that I have to use your version to try to send audio to webcam also? I see that the speaker service is created only in your version. |
That is correct. If you use my version the icon will show up, but it will not work. That is exactly what we are discussing here.. ;) |
Current version of ffmpeg won't let you bind to the same udp port, so first of all we have to put in place an udp proxy to act as a gateway between the port used to talk with the homekit client and two local ports to be used with ffmpeg. Maybe I'm going to try that next days. |
Would be nice. I'm not an expert with ffmpeg at all. |
Ok now I have a "proof of concept" working! I implemented the udp proxy part and managed to receive the "speaker" stream with a separate ffmpeg instance and save to a file... Tomorrow I'll try to find time to little polish the code and attach here. |
Here is my working POC Set config["audio"] = "2way", it create the proxy and a "speaker.sdp" file in working directory that let's you play the audio sent from iOS. I saved mine to a file like this: ffmpeg -v trace -protocol_whitelist "file,udp,rtp" -i speaker.sdp speaker.mp4 |
Nice work. As soon as this is finished I am happy to test it! |
Is the idea to handle separate input and output audio streams from the video? That’s exactly what I’d like to achieve - then you’d have 2way audio working @llmett |
If so I’d like to bring the ideas across to get the intercom working fully. That would be a win 🏖 |
@llemtt give me your image of raspberry |
Attached second version of my working POC! It uses an additional ffmpeg instance to manage the speaker, set config["audio"] = "2way "+{your speaker ffmpeg output} (I've tested mine writing to a file with "2way -y speaker.mp4"). Requires audio streaming to ios device to start in less than 10 seconds otherwise the "speaker" ffmpeg instance will timeout. On raspberry tested working also with "2way -f alsa default". |
Is the expected end state to pass it a stream to write it to rather than a file? |
Yes, at the moment I don't have a way to try it out other than sending to a file, alsa, or a DLINK camera having a complicated proprietary format to solve first 😒 (btw I'm looking for a "cheaper than doorbird" doorbell with a decently working streaming api...) It would have been better to use a single ffmpeg instance but it's a nightmare because without a steady streaming to speaker (which is not because it's on only when the microphone button is active) it blocks every other input waiting. This could be a nice improvement in the "not so near" future. |
ERROR: Speaker FFmpeg exited with code 1 { |
Can you add "debug": true to your config and get the ffmpeg output into the log? BTW you have to configure alsa to work under the user running homebridge. |
[11/12/2018, 12:48:00 PM] [Camera-ffmpeg-2way] { sessionID: <Buffer 3b a9 fc 5c 74 36 43 c4 b9 f8 8f f0 89 24 f9 44>, [Speaker] [NULL @ 0x25a9df0] Unable to find a suitable output format for 'alsa' [11/12/2018, 12:48:00 PM] [Camera-ffmpeg-2way] ERROR: Speaker FFmpeg exited with code 1 Metadata: Codec AVOption tune (Tune the encoding params (cf. x264 --fullhelp)) specified for output file #0 (srtp://192.168.1.10:60331?rtcpport=60331&localrtcpport=60331&pkt_size=1316) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream. Stream mapping: Output #1, rtp, to 'srtp://127.0.0.1:61436?rtcpport=61436&localrtcpport=9998&pkt_size=188': [libfdk_aac @ 0x3611660] Queue input is backward in time [rtp @ 0x3518220] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 688; changing to 1760. This may result in incorrect timestamps in the output file. [rtp @ 0x3518220] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 1200; changing to 1760. This may result in incorrect timestamps in the output file. [libfdk_aac @ 0x3611660] Queue input is backward in time [rtp @ 0x3518220] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 1712; changing to 1760. This may result in incorrect timestamps in the output file. [rtp @ 0x3518220] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 628; changing to 1760. This may result in incorrect timestamps in the output file. [rtp @ 0x3518220] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 1140; changing to 1760. This may result in incorrect timestamps in the output file. [libfdk_aac @ 0x3611660] Queue input is backward in time [rtp @ 0x3518220] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 1652; changing to 1760. This may result in incorrect timestamps in the output file. [rtp @ 0x3518220] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 570; changing to 1760. This may result in incorrect timestamps in the output file. [rtp @ 0x3518220] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 1082; changing to 1760. This may result in incorrect timestamps in the output file. [libfdk_aac @ 0x3611660] Queue input is backward in time [rtp @ 0x3518220] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 1594; changing to 1760. This may result in incorrect timestamps in the output file. [rtp @ 0x3518220] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 512; changing to 1760. This may result in incorrect timestamps in the output file. [rtp @ 0x3518220] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 1024; changing to 1760. This may result in incorrect timestamps in the output file. [libfdk_aac @ 0x3611660] Queue input is backward in time [rtp @ 0x3518220] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 1536; changing to 1760. This may result in incorrect timestamps in the output file. [rtp @ 0x3518220] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 454; changing to 1760. This may result in incorrect timestamps in the output file. [rtp @ 0x3518220] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 966; changing to 1760. This may result in incorrect timestamps in the output file. [libfdk_aac @ 0x3611660] Queue input is backward in time [rtp @ 0x3518220] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 1478; changing to 1760. This may result in incorrect timestamps in the output file. [rtp @ 0x3518220] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 394; changing to 1760. This may result in incorrect timestamps in the output file. [rtp @ 0x3518220] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 906; changing to 1760. This may result in incorrect timestamps in the output file. [libfdk_aac @ 0x3611660] Queue input is backward in time [rtp @ 0x3518220] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 1418; changing to 1760. This may result in incorrect timestamps in the output file. [rtp @ 0x3518220] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 336; changing to 1760. This may result in incorrect timestamps in the output file. [rtp @ 0x3518220] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 848; changing to 1760. This may result in incorrect timestamps in the output file. [libfdk_aac @ 0x3611660] Queue input is backward in time [rtp @ 0x3518220] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 1360; changing to 1760. This may result in incorrect timestamps in the output file. [rtp @ 0x3518220] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 306; changing to 1760. This may result in incorrect timestamps in the output file. [rtp @ 0x3518220] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 818; changing to 1760. This may result in incorrect timestamps in the output file. [rtp @ 0x3518220] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 1330; changing to 1760. This may result in incorrect timestamps in the output file. [libfdk_aac @ 0x3611660] Queue input is backward in time [rtp @ 0x3518220] Non-monotonous DTS in output stream 1:0; previous: 1842, current: 1432; changing to 1842. This may result in incorrect timestamps in the output file. [h264_omx @ 0x3517940] Using OMX.broadcom.video_encode Output #0, rtp, to 'srtp://192.168.1.10:60331?rtcpport=60331&localrtcpport=60331&pkt_size=1316':
[libfdk_aac @ 0x3611660] Queue input is backward in time [11/12/2018, 12:48:06 PM] [Camera-ffmpeg-2way] { sessionID: <Buffer 3b a9 fc 5c 74 36 43 c4 b9 f8 8f f0 89 24 f9 44>, |
how to do it? |
Good log thanks! This is the ffmpeg speaker command: [Speaker] ffmpeg -v error -nostats -nostdin -max_ts_probe 0 -protocol_whitelist file,udp,rtp -i Home_2way_speaker.sdp -y alsa default and this is the error: [Speaker] [NULL @ 0x25a9df0] Unable to find a suitable output format for 'alsa' "-y alsa default" is wrong, it must be "-f alsa default", don't know how but your -f became -y !! Check your config. You can also test that everything is ok with alsa/ffmpeg with the following: sudo -u YOURHOMEBRIDGEUSERNAME ffmpeg -i SOMEAUDIOFILE -f alsa default |
[11/12/2018, 10:30:44 PM] [Camera-ffmpeg-2way] { sessionID: <Buffer 70 18 a8 81 2c a3 48 06 aa 09 1b 28 6b f9 3f 02>, [Speaker] [NULL @ 0x187fd80] Requested output format 'alsa' is not a suitable output format [11/12/2018, 10:30:45 PM] [Camera-ffmpeg-2way] ERROR: Speaker FFmpeg exited with code 1 Input #0, rtsp, from 'rtsp://192.168.1.17/unicast': Metadata: Codec AVOption tune (Tune the encoding params (cf. x264 --fullhelp)) specified for output file #0 (srtp://192.168.1.10:49588?rtcpport=49588&localrtcpport=49588&pkt_size=1316) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream. Stream mapping: Output #1, rtp, to 'srtp://127.0.0.1:57010?rtcpport=57010&localrtcpport=9998&pkt_size=188':
[libfdk_aac @ 0x2c346a0] Queue input is backward in time [rtp @ 0x2b85070] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 684; changing to 1760. This may result in incorrect timestamps in the output file. [rtp @ 0x2b85070] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 1196; changing to 1760. This may result in incorrect timestamps in the output file. [libfdk_aac @ 0x2c346a0] Queue input is backward in time [rtp @ 0x2b85070] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 1708; changing to 1760. This may result in incorrect timestamps in the output file. [rtp @ 0x2b85070] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 634; changing to 1760. This may result in incorrect timestamps in the output file. [rtp @ 0x2b85070] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 1146; changing to 1760. This may result in incorrect timestamps in the output file. [libfdk_aac @ 0x2c346a0] Queue input is backward in time [rtp @ 0x2b85070] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 1658; changing to 1760. This may result in incorrect timestamps in the output file. [rtp @ 0x2b85070] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 1188; changing to 1760. This may result in incorrect timestamps in the output file. [libfdk_aac @ 0x2c346a0] Queue input is backward in time [rtp @ 0x2b85070] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 1700; changing to 1760. This may result in incorrect timestamps in the output file. [rtp @ 0x2b85070] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 1134; changing to 1760. This may result in incorrect timestamps in the output file. [libfdk_aac @ 0x2c346a0] Queue input is backward in time [rtp @ 0x2b85070] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 1646; changing to 1760. This may result in incorrect timestamps in the output file. [rtp @ 0x2b85070] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 1088; changing to 1760. This may result in incorrect timestamps in the output file. [rtp @ 0x2b85070] Non-monotonous DTS in output stream 1:0; previous: 1760, current: 1600; changing to 1760. This may result in incorrect timestamps in the output file. [h264_omx @ 0x2bc3710] Using OMX.broadcom.video_encode Output #0, rtp, to 'srtp://192.168.1.10:49588?rtcpport=49588&localrtcpport=49588&pkt_size=1316': [libfdk_aac @ 0x2c346a0] Queue input is backward in time [11/12/2018, 10:30:50 PM] [Camera-ffmpeg] Snapshot from Питер at 480x270 Exiting normally, received signal 15. [11/12/2018, 10:30:51 PM] [Camera-ffmpeg-2way] Stopped streaming |
Ok, now error is: [Speaker] [NULL @ 0x187fd80] Requested output format 'alsa' is not a suitable output format your ffmpeg is not compiled with alsa support! You have to make this work first of all: sudo -u YOURHOMEBRIDGEUSERNAME ffmpeg -i SOMEAUDIOFILE -f alsa default Check that you have libasound2-dev installed before building ffmpeg, if not you have to install it: sudo apt-get install libasound2-dev |
I've been reading through these two-way audio cases with interest. I have alza support compiled and
Shouldn't there be a small microphone or something to speak ? |
yes but be aware that nothing has already been merged into this repository... |
@llemtt - I think I saw you were successful doing this, correct? Would be very interested in figuring this out with your method. I think I read there needs to be three streams? Does h264 include both audio and video in one (2 streams), which show on 0:0 and then the third stream is on 0:1. I can hear input from my camera, but I have no way to speak to the other end.
|
@llemtt - I am continuing to try to troubleshoot this and beating my head against the wall. I see problems with the URL as shown above, but changing the options as you suggest do not produce any meaningful output specifically around that error (-541478725). Do you think there were some changes/deltas added to the base homebridge-camera-ffmpeg which now may be causing some problems with your modified ffmpeg.config? Maybe you could review the deltas? I am always running in to problems presenting the sdp to the http url - something always seems to break. However, when I take input from a file instead, as we tested earlier, it works. There is some problem in reading from sdp as input and converting and presenting to the http output. Any further suggestions would be appreciated. I can include another debug if it is helpful, but I have tested so many options now, I am all over the place. |
@burnbrigther I don't use homebridge-camera-ffmpeg but Samfox2/homebridge-videodoorbell as a base so I suggest to start from there (homebridge-camera-ffmpeg has changed a lot in the meantime). changing the log level as above must produce the detailed log for the speaker part, without that log to me is almost impossible to understand what's happening I "think" your problem is not related to the sdp file, that is working when you save to a file... the error seems to be related to the http communication with your cam, maybe it doesn't support both rtsp and http running at the same time? |
Are there any more informations about 2way audio? |
@Supereg look also at Samfox2/homebridge-videodoorbell#25 maybe you forgot to attach your log file... |
@burnbrigther any step forward with the Axis cam? I think we are SO close. I've been dumping http traffic from an iOS app which supports 2ways audio called uViewerAxis and when mic (PTT) is pressed headers are like
|
Sorry, I was never able to get this to fully work. I moved on. I can try to test some things if you figure something out. |
well I got it to work.. sort of! if you want to test, this is my audio line in config.json:
then as soon as you hit the mic icon of the camera in homekit it will exit with
BUT!
|
@brian-f Glad to hear that it almost works with your camera, IIRC I already encountered the "Broken pipe" error but can't remember how it went away. I know there's a timeout problem, i.e. if your camera (+ homebridge) don't start streaming within 30s a timeout expires in the speaker part and then strange errors appear, altough I don't think it's your case. With a "debug level" log it should be clearer what's happening. Anyway "-probesize 32 -analyzeduration 32" are ffmpeg input side parameters, you better omit them from your configuration. |
WOW! It's cool! I have a Xiaofang 1S and install Dafang Hacks
Its play file for audio test and I hear audio on camera |
@DedMsk first of all you have to find a way to send an audio file to your cam using ffmpeg! audioplay seems a tool that runs locally on the cam... and I can't find the source code |
I am trying to use the raspberry pi camera and an attached audio hat with this approach. I have the one-way audio and video successfully running. I have merged the patches from @llemtt 's POC with the current release of the file in the homebridge-ffmpeg-camera: ffmpeg.js.txt. I just added a tiny modification so the proxy sdp file is stored in /var/homebridge to avoid file system permission problems. Here is my config:
Starting the stream results in a port conflict. for some reason the udp port is used by another process. Is there something I am getting wrong? Here is the log:
|
Glad to hear you have attempted to merge into current version, but first of all does it work for you without merging? I see your merge has some problem because audio output url is still like the original one: srtp://192.168.188.93:61388?rtcpport=61388&localrtcpport=61388&pkt_size=564: Input/output error host has to be 127.0.0.1 and localrtcpport 9998 (I also suggest to not change audio packet size which is established by the homekit client request to have a 30ms packet timing and cannot be negotiated... video and audio sizes are different!!) |
The "old" version does not support mapping. So I had to edit this in the code directly... This is the result:
|
So actually this looks good. I had a wrong flag in my config but this log shows that the stream is set up correctly. I hope to improve the audio stream latency and stability from the pi to the iPhone and also the audio from the iPhone to the pi seems to be sort of distorted... I will have a look again at merging the current FFmpeg.js file later on... (with more care) |
@odx good to hear that it works! my version should do automatic mapping but maybe there's something to fix, anyway with my configuration it works. To improve audio you must match the audio packet size to the "packet_time: 30," of the request so 188 is a good value, while the video packet size must be "mtu: 1378" for best performance. |
@llemtt thanks for the hint with the packet_time. The original source from this project does not allow to specify different packet sizes for audio and video. I noticed that your code always applies 188 for the audio packet size and only maps the configured packet size to the video stream. What I noticed is that the audio that is sent from my iPhone to the pi is pitched slightly lower than what the input was. The funny thing is that in the other direction (from Pi / ALSA to the iPhone) it is vice versa. As I posted here. |
Hi here is merged working ffmpeg.js from latest version of camera-ffmpeg with 2way audio support. My working setup "source": "-f alsa -ac 1 -ar 44100 -thread_queue_size 2048 -i default -re -f video4linux2 -i /dev/video0 -vsync 0 -af aresample=async=1 -vf hflip,vflip" I discovered that for working audio is crucial video4linux2 and -vsync 0 -af aresample=async=1 Audio is not working with mjpeg for me. Because easier permission access is Speaker.sdp file moved to /var/lib/homebridge (my working folder of homebridge) change it in ffmpeg.js to your actual homebridge folder. |
@brian-f Did you finally get this working with full 2way audio? I am trying to get this to work now with my newer P3375-VE. Could you share your config and which ffmpeg.js worked for you? Thanks |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
i want it for my axis doorstation, it would be nice! i do not get the mic button in the home app!? thank you! |
2-way audio does actually work for a the first maybe 2-3 seconds, but then crashes out with the error you say above. It's not clear what is causing this, but I suspect it's something with the proxy and not handling the connections properly. Too bad I don't know enough about how the code is handling multiple streams. Maybe someone would be willing to investigate with us some day. I should say this discussion applies only to the video doorbell with @llmetts enhancement for 2-way audio. |
Excuse me, I use PI4 (camera module+wm8960 audio hat) and want to try 2 way audio.Could you please share the setting method of the PI side? |
No description provided.
The text was updated successfully, but these errors were encountered: