1

我在 youtube 上创建了一个直播活动,并将自定义摄取(直播流)与该直播活动相关联。

我可以通过调用获取实时事件列表

https://www.googleapis.com/youtube/v3/liveBroadcasts?part=snippet&broadcastStatus=all

回复

{
 "kind": "youtube#liveBroadcastListResponse",
 "etag": "\"sGDdEsjSJ_SnACpEvVQ6MtTzkrI/6LS8J5LIkMcXRAIUEViaRonO_jk\"",
 "items": [
  {

   "kind": "youtube#liveBroadcast",
   "etag": "\"sGDdEsjSJ_SnACpEvVQ6MtTzkrI/eSW3gnAC5A4iNg4xj-r8vvP4ha8\"",
   "id": "M96Pswa174I",
   "snippet": {
    "publishedAt": "2015-08-27T09:26:52.000Z",
    "channelId": "UCx_ZkmygOl4Bc0PHV8zXeag",
    "title": "My new event",
    "description": "This is test event",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/M96Pswa174I/default_live.jpg",
      "width": 120,
      "height": 90
     },
     "medium": {
      "url": "https://i.ytimg.com/vi/M96Pswa174I/mqdefault_live.jpg",
      "width": 320,
      "height": 180
     },
     "high": {
      "url": "https://i.ytimg.com/vi/M96Pswa174I/hqdefault_live.jpg",
      "width": 480,
      "height": 360
     }
    },
    "scheduledStartTime": "2015-08-27T09:30:00.000Z",
    "isDefaultBroadcast": false
   }
  }
 ]
}

然后我可以通过调用来获得直播

https://www.googleapis.com/youtube/v3/liveStreams?part=cdn%2Csnippet&mine=true

回复

- SHOW HEADERS -
{
 "kind": "youtube#liveStreamListResponse",
 "etag": "\"sGDdEsjSJ_SnACpEvVQ6MtTzkrI/ctbzD5B9MI-wBMxDXCWCto2oFO8\"",
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 5
 },
 "items": [
  {

   "kind": "youtube#liveStream",
   "etag": "\"sGDdEsjSJ_SnACpEvVQ6MtTzkrI/LEFmnjMqvHydtqmxovlaXCai3vM\"",
   "id": "x_ZkmygOl4Bc0PHV8zXeag1440668944469033",
   "snippet": {
    "publishedAt": "2015-08-27T09:49:04.000Z",
    "channelId": "UCx_ZkmygOl4Bc0PHV8zXeag",
    "title": "My new stream",
    "description": "this is demo stream",
    "isDefaultStream": false
   },
   "cdn": {
    "format": "720p_hfr",
    "ingestionType": "rtmp",
    "ingestionInfo": {
     "streamName": "rathodm63.6584-jszu-8p4h-43yg",
     "ingestionAddress": "rtmp://a.rtmp.youtube.com/live2",
     "backupIngestionAddress": "rtmp://b.rtmp.youtube.com/live2?backup=1"
    }
   }
  }
 ]
}

但是如何识别该蒸汽属于上述指定的现场活动?

4

1 回答 1

1

您必须使用LiveBroadcasts.bind将 YouTube 广播绑定到流。请注意,一个广播只能绑定到一个视频流,尽管一个视频流可以绑定到多个广播。然后,您可以使用LiveBroadcasts.list请求并检查contentDetails.boundStreamId,这将是与该直播关联的流。您必须指定part=contentDetails是否要通过 HTTP 请求执行此操作。

于 2015-09-01T22:36:55.523 回答