我试图向新广播中添加一个已经处于活动状态的流,但无法启动广播。我所采取的步骤是。
curl --request POST \
"https://youtube.googleapis.com/youtube/v3/liveBroadcasts?part=snippet,contentDetails,status" \
--header "Authorization: Bearer XXX" \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data "{'snippet':{'scheduledStartTime':'2021-05-18T17:28:00Z','title':'Tester','description':'descr'},'status':{'privacyStatus':'public','selfDeclaredMadeForKids':false},'contentDetails':{'enableAutoStart':true,'recordFromStart':true,'latencyPreference':'normal','enableAutoStop':false}}"
{
"kind": "youtube#liveBroadcast",
"etag": "gyv8ux9AiVL_NuZefS8SGXc3iZQ",
"id": "z--Lm8b1mU0",
"snippet": {
"publishedAt": "2021-05-18T17:27:39Z",
"channelId": "XXXXXXXXXXXXXXXX",
"title": "Tester",
"description": "descr",
...
},
"scheduledStartTime": "2021-05-18T17:28:00Z",
"isDefaultBroadcast": false,
"liveChatId": "KicKGFVDRUZXb015R0VtWFdrcDdkV1BMWWRXQRILei0tTG04YjFtVTA"
},
"status": {
"lifeCycleStatus": "created",
"privacyStatus": "public",
"recordingStatus": "notRecording",
"madeForKids": false,
"selfDeclaredMadeForKids": false
},
"contentDetails": {
"monitorStream": {
"enableMonitorStream": true,
"broadcastStreamDelayMs": 0,
...
},
"enableEmbed": false,
"enableDvr": true,
"enableContentEncryption": false,
"startWithSlate": false,
"recordFromStart": true,
"enableClosedCaptions": false,
"closedCaptionsType": "closedCaptionsDisabled",
"enableLowLatency": false,
"latencyPreference": "normal",
"projection": "rectangular",
"enableAutoStart": true,
"enableAutoStop": false
}
}curl --request POST "https://youtube.googleapis.com/youtube/v3/liveBroadcasts/bind?id=z--Lm8b1mU0&part=snippet,contentDetails,status&streamId=EFWoMyGEmXWkp7dWPLYdWA1615776388366728" --header "Authorization: Bearer XXXXXXXX" --header "Accept: application/json"
{
"kind": "youtube#liveBroadcast",
"etag": "L_Q87yK0gMxEM7VZ-aKHCTZ7n8g",
"id": "z--Lm8b1mU0",
"snippet": {
"publishedAt": "2021-05-18T17:27:39Z",
"channelId": "UCEFWoMyGEmXWkp7dWPLYdWA",
"title": "Tester",
"description": "descr",
},
"scheduledStartTime": "2021-05-18T17:28:00Z",
"isDefaultBroadcast": false,
"liveChatId": "KicKGFVDRUZXb015R0VtWFdrcDdkV1BMWWRXQRILei0tTG04YjFtVTA"
},
"status": {
"lifeCycleStatus": "ready",
"privacyStatus": "public",
"recordingStatus": "notRecording",
"madeForKids": false,
"selfDeclaredMadeForKids": false
},
"contentDetails": {
"boundStreamId": "EFWoMyGEmXWkp7dWPLYdWA1615776388366728",
"boundStreamLastUpdateTimeMs": "2021-05-18T16:58:04Z",
"monitorStream": {
"enableMonitorStream": true,
"broadcastStreamDelayMs": 0,
...
},
"enableEmbed": false,
"enableDvr": true,
"enableContentEncryption": false,
"startWithSlate": false,
"recordFromStart": true,
"enableClosedCaptions": false,
"closedCaptionsType": "closedCaptionsDisabled",
"enableLowLatency": false,
"latencyPreference": "normal",
"projection": "rectangular",
"enableAutoStart": true,
"enableAutoStop": false
}
}curl --request POST -H "Authorization: Bearer XXXXXX" "https://www.googleapis.com/youtube/v3/liveBroadcasts/transition?part=id,snippet,contentDetails,status&broadcastStatus=live&id=z--Lm8b1mU0"
{
"error": {
"code": 403,
"message": "Invalid transition",
"errors": [
{
"message": "Invalid transition",
"domain": "youtube.liveBroadcast",
"reason": "invalidTransition",
"extendedHelp": "https://developers.google.com/youtube/v3/live/docs/liveBroadcasts/transition#params"
}
]
}
}curl "https://youtube.googleapis.com/youtube/v3/liveStreams?part=snippet,cdn,contentDetails,status&id=EFWoMyGEmXWkp7dWPLYdWA1615776388366728" -H "Authorization: Bearer XXXXXXXXXXX" -H "Accept: application/json"
{
"kind": "youtube#liveStreamListResponse",
"etag": "ejyo1UhcC8AFCfiY-TxKo4yhwv0",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#liveStream",
"etag": "IZNA8olA5tx8tu2fGKPg4ws0YpM",
"id": "EFWoMyGEmXWkp7dWPLYdWA1615776388366728",
"snippet": {
"publishedAt": "2021-03-15T02:46:29Z",
"channelId": "XXXXXXXXXXXXXXXXXXXXXXXX",
"title": "Default stream key",
"description": "Description for default stream key",
"isDefaultStream": false
},
"cdn": {
"ingestionType": "rtmp",
"ingestionInfo": {
"streamName": "XXXX-XXXX-XXXX-XXXX-XXXX",
"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"
}
},
"contentDetails": {
...
"isReusable": true
}
}
]
}关于如何使这件事奏效的想法?
发布于 2021-05-18 20:36:48
我想通了。
显然,您不能用enableAutoStart=true创建一个brodcast,然后添加一个活动流。enableAutoStart=true似乎失败了广播转换API调用,以将状态更改为测试或活动或完成。
为了使其工作,我停止了然后开始发送到流,这导致流转换为非活动,然后返回到活动。这一转变使广播开始。
或者,为了使它在不重新启动流的情况下工作,我执行了以下操作:
使用enableAutoStart=false
)
这看起来挺好的。
如果转换的错误消息表明是enableAutoStart造成了问题,那就太好了。
https://stackoverflow.com/questions/67592373
复制相似问题