2

I tried to add an already active stream to a new broadcast, and can't get the broadcast started. The steps I took were.

  1. Created a new Broadcast.
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
  }
}
  1. Bind the already active stream to the Broadcast. I expected the enableAutoStart in the created broadcast to auto start the broadcast, though it did not.
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
  }
}
  1. Attempted to transition the broadcast to live. I also tried transition to testing, which failed with the same error.
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"
      }
    ]
  }
}
  1. Verified the stream is still active.
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
      }
    }
  ]
}

Thoughts on how to make this work?

me_online
  • 371
  • 3
  • 11

1 Answers1

2

I figured it out.

Apparently you cannot have a brodcast created with enableAutoStart=true and then add an active stream. It seems that enableAutoStart=true fails the broadcast transition API calls to change the status to testing or live or complete.

To get this to work, I stopped then started sending to the stream, which caused the stream to transition to inactive then back to active. The transition caused the broadcast to start.

Alternatively, to get this to work without the restart of the stream, I did the following:

  1. create the broadcast with enableAutoStart=false
  2. bind the active stream to the broadcast (as in the question).
  3. transition the broadcast to testing, then to live.

This seems to work fine.

Would have been nice to have the error message for transitioning indicate it was the enableAutoStart which was the problem.

me_online
  • 371
  • 3
  • 11
  • Great! Thank you very much. As mentioned [here](https://stackoverflow.com/a/47939807/854483) you can skip setting the broadcast to testing if you insert the broadcast with contentDetails.monitorStream.enableMonitorStream set to false. – BdN3504 Apr 20 '22 at 19:56