2

I am using the following API by Google, https://developers.google.com/nest/device-access/traits/device/camera-live-stream

I have successfully been able to see a list of my devices and relevant information. I also am able to make a successful GenerateRtspStream request. I receive the following response as documented on their API

{
  "results" : {
    "streamUrls" : {
      "rtsp_url" : "rtsps://someurl.com/CjY5Y3VKaTZwR3o4Y19YbTVfMF...?auth=g.0.streamingToken"
    },
    "streamExtensionToken" : "CjY5Y3VKaTZwR3o4Y19YbTVfMF...",
    "streamToken" : "g.0.streamingToken",
    "expiresAt" : "2018-01-04T18:30:00.000Z"
  }
}

The problem however is I am unable to access the video feed. I have tried using things like VLC player and Pot Player to view the live feed, but they say that URL does not exist. I have also tried using OpenCV in python to try and access the live-feed as well and it also does not work ( I have tested opencv on local files and they work just fine ).

Am I doing something wrong with rtsps urls? How do I access the live-feed, either in python or some third-party application like VLC Player

Here is some examples of what I have already tried doing:

import cv2 as cv
x = cv.VideoCapture(STREAM_URL)
# ret is False --- it works on local files as it returns True and I am able to view the media 
ret, img = x.read()

Here is the attempt using Pot Player/VLC

enter image description here

My goal is to do processing on this video-feed/image in python, so ideally my solution would be using opencv or something along those lines. I was mainly using VLC and other players to debug the issue with this url first.

UPDATE

I have tested using the following public link rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov :

MYURL = "rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov"
MYURL = STREAM_URL
import cv2 as cv
x = cv.VideoCapture(MYURL)
while(True):
    ret, img = x.read()
    if not ret:
        print('URL not working')
        break
    cv.imshow('frame', img)
    cv.waitKey(1)

And it works perfectly with opencv as well as Pot Player. So maybe the issue is with the Google Devices Access API? The URL they provide may not be correct? Or am I missing something here?

Maybe it has to do with the rtsps URL vs rtsp? How can I fix that?

road_to_quantdom
  • 1,341
  • 1
  • 13
  • 20
  • Dont you know rtsp link of your webcam? Which link are u using for web browser interface ? – Yunus Temurlenk Sep 24 '20 at 04:56
  • I am using the rtsps link that the google api provides. My problem seems to be that opencv, VLC, and PotPlayer all do not support rtsps. But only rtsp. I found a solution where using ffmpeg works. I guess I’ll have to use ffmpeg, and then opencv the file created by ffmpeg – road_to_quantdom Sep 24 '20 at 11:53
  • @road_to_quantdom Could you share the ffmpeg solution you found? Would love to do the same! – Trygve Oct 04 '20 at 18:56

2 Answers2

1

Both ffmpeg and ffplay worked fine for me, no rebuild necessary. On MacOS I just did:

brew install ffmpeg
ffplay -rtsp_transport tcp "rtsps://..."

Fill in the huge stream URL. Note the quotes, there was something about the URL without quotes that zsh didn't like. Alternatively to save the stream to a file

ffmpeg -y -loglevel fatal -rtsp_transport tcp -i "rtsps://..." -acodec copy -vcodec copy /path/to/out.mp4

You could use different options with ffmpeg to transform the stream to something other than rtsps for consumption by some other application.

Interestingly, despite the API telling me this:

  "maxVideoResolution": {
    "width": 640,
    "height": 480
  },

this is the info from ffplay:

  Metadata:
    title           : SDM
  Duration: N/A, start: -0.110000, bitrate: N/A
    Stream #0:0: Audio: aac (LC), 48000 Hz, stereo, fltp
    Stream #0:1: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1600x1200 [SAR 1:1 DAR 4:3], 15 fps, 15 tbr, 90k tbn, 30 tbc

Indicating 1600x1200, not sure why maxVideoResolution isn't actually the max resolution?

Ted
  • 83
  • 8
0

I'd suggest trying with ffmpeg, however you may need to build it from source.

If you're having trouble with ffmpeg, you can modify the ffmpeg source to increase control_uri (in libavformat/rtsp.h) size from 1024 to 2048, and recompile. Then ffmpeg should be able to play the RTSPS streams.

ejf
  • 619
  • 6
  • 13
  • I have got it working with `ffmpeg`. I have a question though. I would like to do two things. 1) copy the stream over ( which I have figured out how to do ) 2) process the stream in real-time frame-by-frame ( or at least some frame-rate of it) Would I be able to that in one-step? Or would I have to create a `ffmpeg` pipe for copying the stream, and also one for saving image frames? – road_to_quantdom Sep 24 '20 at 21:04