YouTubeData API v3:转换';就绪';至';直播';广播因活动流“而失败”;403无效转换“;

YouTubeData API v3:转换';就绪';至';直播';广播因活动流“而失败”;403无效转换“;,youtube,youtube-api,youtube-data-api,Youtube,Youtube Api,Youtube Data Api,我试图向新广播添加一个已激活的流,但无法启动广播。我所采取的步骤很简单 创建了一个新的广播 将已激活的流绑定到广播。我希望创建的广播中的enableAutoStart能够自动启动广播,但事实并非如此 试图将广播转换为实况广播。我还尝试了转换到测试,但失败了,出现了相同的错误 已验证流仍处于活动状态 关于如何使这项工作成功的想法?我想出来了 显然,您不能使用enableAutoStart=true创建brodcast,然后添加活动流。似乎enableAutoStart=true使广播转换API调用

我试图向新广播添加一个已激活的流,但无法启动广播。我所采取的步骤很简单

  • 创建了一个新的广播
  • 将已激活的流绑定到广播。我希望创建的广播中的enableAutoStart能够自动启动广播,但事实并非如此
  • 试图将广播转换为实况广播。我还尝试了转换到测试,但失败了,出现了相同的错误
  • 已验证流仍处于活动状态
  • 关于如何使这项工作成功的想法?

    我想出来了

    显然,您不能使用enableAutoStart=true创建brodcast,然后添加活动流。似乎enableAutoStart=true使广播转换API调用无法将状态更改为testing、live或complete

    为了让它工作,我停止了,然后开始发送到流,这导致流转换为非活动,然后返回活动。过渡导致广播开始

    或者,为了在不重新启动流的情况下实现这一点,我执行了以下操作:

  • 使用enableAutoStart=false创建广播
  • 将活动流绑定到广播(如问题中所述)
  • 将广播切换到测试,然后切换到直播
  • 这似乎很有效

    如果转换的错误消息表明问题出在enableAutoStart上,那就太好了

    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
          }
        }
      ]
    }