Selecting 'go live' from the camera icon in YouTube, brings me to the studio where my default stream is.
I seem to need to navigate there (to enable it) before I can start uploading data via rtmp to that stream. Similarly, if there is a break in the stream for a minute or so, the stream automatically ends, and i need to go to the page and click the 'dismiss' button to start it again.
I found I can programmatically check if the stream is running with:
curl -H "Authorization: Bearer XXXXXXX_AUTHTOKEN" "https://www.googleapis.com/youtube/v3/liveStreams?part=snippet,cdn,contentDetails,status&mine=true"
where I get the an entry in the JSON with the same dn.ingestionInfo.streamName
as the stream key on the studio page. The entry also shows contentDetails.isReusable=true
and status.streamStatus=active
(where I believe it needs to be 'ready' to be able to accept / start the stream.
{
"kind": "youtube#liveStream",
"title": "Default stream key",
"description": "Description for default stream key",
"isDefaultStream": false
},
"cdn": {
"ingestionType": "rtmp",
"ingestionInfo": {
"streamName": "XXXXXXXXXXXXXXX",
"ingestionAddress": "rtmp://a.rtmp.youtube.com/live2",
"backupIngestionAddress": "rtmp://b.rtmp.youtube.com/live2?backup=1",
"rtmpsIngestionAddress": "rtmps://a.rtmps.youtube.com/live2",
"rtmpsBackupIngestionAddress": "rtmps://b.rtmps.youtube.com/live2?backup=1"
},
"resolution": "variable",
"frameRate": "variable"
},
"status": {
"streamStatus": "active",
"healthStatus": {
"status": "good"
}
},
"isReusable": true
}
}
Is there an API set I can use to reuse this default stream and programmatically change its state from active to ready?
I tried doing this below, but it always gives a new streamName
instead of changing the status.streamStatus
of the default one.
curl -H "Authorization: Bearer AUTHTOKEN" -H "Accept: application/json" -H "Content-Type: application/json" --data "{'id':'STREAMID_FROM_DEFAULT_IN_STATUS_CALL','snippet':{'title':'test','description':'test.'},'status':{'streamStatus':'ready'},'cdn':{'ingestionType':'rtmp','frameRate':'variable','resolution':'variable','ingestionInfo':{'streamName':'STREAM_NAME_FROM_DEFAULT_IN_STATUS_CALL'}}}" --request POST "https://youtube.googleapis.com/youtube/v3/liveStreams?part=snippet,status,cdn"
.
However, this returns a different id
, and a different cdn.ingestionInfo.streamName
than the ones I specified in the call.
Thoughts or ideas on how I can reuse the default 'Go live' studio stream programmatically?