jeffreydwalter / arlo

Python module for interacting with Netgear's Arlo camera system.
Apache License 2.0
520 stars 123 forks source link

4-camera video streaming problem #116

Closed zar1978 closed 4 years ago

zar1978 commented 5 years ago

Please answer these questions before submitting your issue. Thanks!

What version of Python are you using (python -V)?

2.7.13

What operating system and processor architecture are you using (python -c 'import platform; print(platform.uname());')?

'Linux', 'openHABianPi', '4.14.98-v7+', '#1200 SMP Tue Feb 12 20:27:48 GMT 2019', 'armv7l'

Which Python packages do you have installed (run the pip freeze or pip3 freeze command and paste output)?

arlo==1.2.18 beautifulsoup4==4.5.3 certifi==2019.3.9 chardet==3.0.4 cryptography==1.7.1 dnspython==1.15.0 enum34==1.1.6 html5lib==0.999999999 idna==2.8 ipaddress==1.0.17 keyring==10.1 keyrings.alt==1.3 lxml==3.7.1 monotonic==1.5 pyasn1==0.1.9 PyBluez==0.18 pycrypto==2.6.1 pygobject==3.22.0 PySocks==1.6.8 pyxdg==0.25 requests==2.21.0 RPi.GPIO==0.6.5 SecretStorage==2.3.1 six==1.12.0 sseclient==0.0.18 tzupdate==1.3.1 urllib3==1.24.1 webencodings==0.5

Which Arlo hardware do you have (camera types - [Arlo, Pro, Q, etc.], basestation model, etc.)?

base station

What did you do?

I have 4 cameras and for each one I would like to save a 10 second MP4 file. If I try to connect to only camera 0, the file is created. If instead I try to insert all 4 of them I get an error:

    import  sys, traceback
    from arlo import Arlo
    from subprocess import call
    from pprint import pprint
    USERNAME =
    PASSWORD = 
    try:
        arlo = Arlo(USERNAME, PASSWORD)
        cameras = arlo.GetDevices('camera')
        basestations = arlo.GetDevices('basestation')
        url_soggiorno = arlo.StartStream(basestations[0], cameras[0])
        url_niccolo =  arlo.StartStream(basestations[0], cameras[1])
        url_balcone_ovest =  arlo.StartStream(basestations[0], cameras[2])
        url_balcone_nord =  arlo.StartStream(basestations[0], cameras[3])
        call(['ffmpeg', '-re', '-i', url_soggiorno, '-t', '10', '-acodec', 'copy', '-vcodec', 'copy', '/srv/openhab2-conf/html/soggiorno.mp4'])
        call(['ffmpeg', '-re', '-i', url_niccolo, '-t', '10', '-acodec', 'copy', '-vcodec', 'copy', 'niccolo.mp4'])
        call(['ffmpeg', '-re', '-i', url_balcone_ovest, '-t', '10', '-acodec', 'copy', '-vcodec', 'copy', 'balconeOvest.mp4'])
        call(['ffmpeg', '-re', '-i', url_balcone_nord, '-t', '10', '-acodec', 'copy', '-vcodec', 'copy', 'balconeNord.mp4'])
    except Exception as e:
            traceback.print_exc(file=sys.stdout)
            print(e)

What did you expect to see?

4 file MP4 with video

What did you see instead?

> [14:49:19] openhabian@openHABianPi:~/python_script$ python arlo_streaming.py
Traceback (most recent call last):
  File "arlo_streaming.py", line 33, in <module>
    url_niccolo =  arlo.StartStream(basestations[0], cameras[1])
  File "/home/openhabian/.local/lib/python2.7/site-packages/arlo.py", line 1440, in StartStream
    return self.TriggerAndHandleEvent(basestation, trigger, callback)
  File "/home/openhabian/.local/lib/python2.7/site-packages/arlo.py", line 360, in TriggerAndHandleEvent
    trigger(self)
  File "/home/openhabian/.local/lib/python2.7/site-packages/arlo.py", line 1433, in trigger
    nl.stream_url_dict = self.request.post('https://arlo.netgear.com/hmsweb/users/devices/startStream', {"to":camera.get('parentId'),"from":self.user_id+"_web","resource":"cameras/"+camera.get('deviceId'),"action":"set","responseUrl":"", "publishResponse":True,"transId":self.genTransId(),"properties":{"activityState":"startUserStream","cameraId":camera.get('deviceId')}},  headers={"xcloudId":camera.get('xCloudId')})
  File "/home/openhabian/.local/lib/python2.7/site-packages/request.py", line 55, in post
    return self._request(url, 'POST', params, headers, raw)
  File "/home/openhabian/.local/lib/python2.7/site-packages/request.py", line 46, in _request
    raise HTTPError('Request ({0} {1}) failed: {2}'.format(method, url, r.json()), response=r)
HTTPError: Request (POST https://arlo.netgear.com/hmsweb/users/devices/startStream) failed: {u'data': {u'message': u'The device does not exist.', u'reason': u'No such device.', u'error': u'2217'}, u'success': False}
Request (POST https://arlo.netgear.com/hmsweb/users/devices/startStream) failed: {u'data': {u'message': u'The device does not exist.', u'reason': u'No such device.', u'error': u'2217'}, u'success': False}

If I try to download one file at a time I get the room number from the script:

> 15:59:40] openhabian@openHABianPi:~/python_script$ python arlo_streaming_camera.py 1
Request (POST https://arlo.netgear.com/hmsweb/users/devices/startStream) failed: {u'data': {u'message': u'The device does not exist.', u'reason': u'No such device.', u'error': u'2217'}, u'success': False}
[15:59:48] openhabian@openHABianPi:~/python_script$ python arlo_streaming_camera.py 3
Request (POST https://arlo.netgear.com/hmsweb/users/devices/startStream) failed: {u'data': {u'message': u'The device failed to connect. Please try again.', u'reason': u' Ingress timedout for cameraId:4N727CS9BBAFE_1555596007334 & ingressStream:03a4ab7d_43df_48b1_9a52_48db17e5917d', u'error': u'5011'}, u'success': False}
[16:00:37] openhabian@openHABianPi:~/python_script$ python arlo_streaming_camera.py 4
Request (POST https://arlo.netgear.com/hmsweb/users/devices/startStream) failed: {u'data': {u'message': u'The device failed to connect. Please try again.', u'reason': u' Ingress timedout for cameraId:4N727CSAB9E09_1555596048813 & ingressStream:1d8a0ddf_e4b9_4191_8084_e328ff354a77', u'error': u'5011'}, u'success': False}
[16:01:18] openhabian@openHABianPi:~/python_script$ python arlo_streaming_camera.py 2
Request (POST https://arlo.netgear.com/hmsweb/users/devices/startStream) failed: {u'data': {u'message': u'The device failed to connect. Please try again.', u'reason': u' Ingress timedout for cameraId:4N71697P44ED5_1555596104011 & ingressStream:7ac34d3b_9c96_4c37_a3d8_f7155846d8a1', u'error': u'5011'}, u'success': False}
[16:02:14] openhabian@openHABianPi:~/python_script$ ll -rt
totale 1.3M

Does this issue reproduce with the latest release?

Yes

jeffreydwalter commented 5 years ago

Can you please paste the output of arlo.GetDevices(). The first error message you're receiving is telling you that you have the wrong device. Once I see your device JSON I'll probably be able to tell you why. I believe the second error message is telling you that you waited too long to download the video stream after calling StartStream.

jeffreydwalter commented 5 years ago

To avoid the timeout issue, you might try rewriting the script like so:

    import  sys, traceback
    from arlo import Arlo
    from subprocess import call
    from pprint import pprint
    USERNAME =
    PASSWORD = 
    try:
        arlo = Arlo(USERNAME, PASSWORD)
        cameras = arlo.GetDevices('camera')
        basestations = arlo.GetDevices('basestation')
        url_soggiorno = arlo.StartStream(basestations[0], cameras[0])
        call(['ffmpeg', '-re', '-i', url_soggiorno, '-t', '10', '-acodec', 'copy', '-vcodec', 'copy', '/srv/openhab2-conf/html/soggiorno.mp4'])
        url_niccolo =  arlo.StartStream(basestations[0], cameras[1])
        call(['ffmpeg', '-re', '-i', url_niccolo, '-t', '10', '-acodec', 'copy', '-vcodec', 'copy', 'niccolo.mp4'])
        url_balcone_ovest =  arlo.StartStream(basestations[0], cameras[2])
        call(['ffmpeg', '-re', '-i', url_balcone_ovest, '-t', '10', '-acodec', 'copy', '-vcodec', 'copy', 'balconeOvest.mp4'])
        url_balcone_nord =  arlo.StartStream(basestations[0], cameras[3])
        call(['ffmpeg', '-re', '-i', url_balcone_nord, '-t', '10', '-acodec', 'copy', '-vcodec', 'copy', 'balconeNord.mp4'])
    except Exception as e:
            traceback.print_exc(file=sys.stdout)
            print(e)
stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

slobglob commented 4 years ago

@jeffreydwalter Do you know why / when does the ingress timeout error happens?

jeffreydwalter commented 4 years ago

@slobglob I don't, but my gut tells me it's related to starting a stream and not consuming it. You have to consume the stream with a certain number of seconds. (I don't know how many anymore.)

slobglob commented 4 years ago

@jeffreydwalter But why does the startStream call gets it? It should just return the url, if you don't consume it you'll get 403 error from ffmpeg (or any other client you use).

jeffreydwalter commented 4 years ago

@slobglob I really don't know. There's 0 documentation available about Arlo's API. It could be issues with the basestation talking to the server.