Skip to content
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

The streaming-pr ffmpeg command doesn't work with the original Arlo cameras #27

Closed
Djelibeybi opened this issue Dec 20, 2018 · 11 comments
Closed

Comments

@Djelibeybi
Copy link
Contributor

Ping @cbpowell and @devbobo

The ffmpeg command generated by ArloCameraSource.js assumes there is both a video and audio stream delivered by Arlo. However, the original Arlo cameras do not have a microphone therefore there is no audio stream.

If I change the video stream to -map 0:0 and comment out the entire audio stream processing block then the live stream works* just fine:

--- ArloCameraSource.js.orig	2018-12-20 17:59:11.749436930 +1100
+++ ArloCameraSource.js	2018-12-20 18:03:18.785305480 +1100
@@ -469,7 +469,7 @@
                     // Video
                     let ffmpegCommand = '-rtsp_transport tcp' +
                     vDecoder +
-                    ' -re -i ' + streamURL + ' -map 0:1' +
+                    ' -re -i ' + streamURL + ' -map 0:0' +
                     ' -c:v ' + vEncoder +
                     ' -pix_fmt yuv420p' +
                     ' -r ' + fps +
@@ -490,24 +490,24 @@
                     '&pkt_size=' + packetsize;

                     // Audio
-                    ffmpegCommand+= ' -map 0:0' +
-                    ' -acodec ' + acodec +
-                    additionalAudioCommands +
-                    ' -flags +global_header' +
-                    ' -f null' +
-                    ' -ar ' + asamplerate + 'k' +
-                    ' -b:a ' + abitrate + 'k' +
-                    ' -bufsize ' + abitrate * 2 + 'k' +
-                    ' -ac 1' +
-                    ' -payload_type 110' +
-                    ' -ssrc ' + audioSsrc +
-                    ' -f rtp' +
-                    ' -srtp_out_suite AES_CM_128_HMAC_SHA1_80' +
-                    ' -srtp_out_params ' + audioKey.toString('base64') +
-                    ' srtp://' + targetAddress + ':' + targetAudioPort +
-                    '?rtcpport=' + targetAudioPort +
-                    '&localrtcpport=' + targetAudioPort +
-                    '&pkt_size=' + packetsize;
+                    //ffmpegCommand+= ' -map 0:1?' +
+                    //' -acodec ' + acodec +
+                    //additionalAudioCommands +
+                    //' -flags +global_header' +
+                    //' -f null' +
+                    //' -ar ' + asamplerate + 'k' +
+                    //' -b:a ' + abitrate + 'k' +
+                    //' -bufsize ' + abitrate * 2 + 'k' +
+                    //' -ac 1' +
+                    //' -payload_type 110' +
+                    //' -ssrc ' + audioSsrc +
+                    //' -f rtp' +
+                    //' -srtp_out_suite AES_CM_128_HMAC_SHA1_80' +
+                    //' -srtp_out_params ' + audioKey.toString('base64') +
+                    //' srtp://' + targetAddress + ':' + targetAudioPort +
+                    //'?rtcpport=' + targetAudioPort +
+                    //'&localrtcpport=' + targetAudioPort +
+                    //'&pkt_size=' + packetsize;
  • assuming you have a new enough version of ffmpeg. I run Homebridge on an Oracle Linux 7 box and I installed ffmpeg-2.8.15-1.el7.nux.x86_64.rpm from Nux Desktop but 2.8.15 is too old to handle the stream from Arlo as you require ffmpeg 3.4 or higher for the stream source.

When I upgraded to ffmpeg-3.4.2-1.el7_5.awel.0.x86_64.rpm from AWEL Media Packages it progressed from the Operation Not Permitted error I was getting initially. Once the stream actually started, then it barfed on the video/audio mismatch issue.

So, some logic is needed to determine whether the camera has a microphone or not and build the ffmpeg command accordingly.

BTW, I grabbed https://github.com/jeffreydwalter/arlo and tested with https://github.com/jeffreydwalter/arlo/blob/master/examples/arlo-streamingvideo.py and my original Arlo generates the following video:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : 4N7168730FD8D_1545290171659
    encoder         : Lavf57.83.100
  Duration: 00:00:10.03, start: 0.000000, bitrate: 523 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 640x352, 520 kb/s, 24.64 fps, 24 tbr, 90k tbn, 48 tbc (default)
    Metadata:
      handler_name    : VideoHandler

Hope that helps! I'm not a node developer, but if I get a chance over the break I might try and fix this myself and submit a PR. But no guarantees I'll have the time, as I'm a (very) newly married man.

@cbpowell
Copy link
Contributor

cbpowell commented Dec 21, 2018

Good to know, thanks for the info! I only have Arlo Pros myself, so it's hard to test.

You're right it should be a relatively easy logic switch based on device capabilities. I haven't looked at this in awhile so I'll have to refresh my memory, but presumably the device type is buried in the device info.

@cnnn
Copy link

cnnn commented Feb 6, 2019

For some reason I don’t even see the cameras in Home app with master branch or this branch. The log shows the plugin found 3 cameras though.

@Djelibeybi
Copy link
Contributor Author

Cameras do not appear automatically in HomeKit. You need to add them manually via the + button in the top right-hand corner. Select "Add Accessory", then "Don't Have a Code or Can't Scan?" link. The cameras should appear as Nearby Accessories in the following screen. Use the HomeKit code for Homebridge itself to add each one.

@cnnn
Copy link

cnnn commented Feb 6, 2019

@Djelibeybi thank you! You saved my day.

@rob74lee
Copy link

@Djelibeybi Is there anyway you can share your arlocamerasource.js with the changes you made? I tried to follow your suggestions on removing audio but I still can't get my stream to work properly. Any help would be appreciated. Thank you!

@Djelibeybi
Copy link
Contributor Author

@Djelibeybi Is there anyway you can share your arlocamerasource.js with the changes you made?

They're up in there in the first post. :) But to be honest, I've removed the cameras from HomeKit as it was generally unstable and caused the cameras to be activated way too often, which kills the batteries.

@rob74lee
Copy link

rob74lee commented Mar 10, 2019 via email

@Djelibeybi
Copy link
Contributor Author

The streaming only ever worked the first time you access the camera(s) from HomeKit anyway. After that, it wouldn't reconnect. It also stopped grabbing stills after the first capture. So even once they were working, they didn't really work.

@rob74lee
Copy link

rob74lee commented Mar 10, 2019 via email

@Djelibeybi
Copy link
Contributor Author

Exactly what I am running into now. Thank you for helping me end my madness!

You're welcome, glad to (not really) help. :)

@cnnn
Copy link

cnnn commented Dec 29, 2019

Now I am able to repeatedly access video stream of original Arlo cameras with this commit. The snapshot is retrieved from device presigned last image instead of activating the camera, which might hit some rate limiting too quickly. Plus it doesn't drain battery much.

cnnn@bc163b1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants