0

My code is creating the Live video on Youtube and returning the Streaming URL. But on this point, it throws the exception: "Resolution is Required"

$streamsResponse = $this->youtube->liveStreams->insert('snippet,cdn', $this->live_stream, array());
$response['stream_response'] = $streamsResponse;
stvar
  • 6,551
  • 2
  • 13
  • 28
akifquddus
  • 632
  • 2
  • 10
  • 25

1 Answers1

0

According to the official documentation of the LiveStreams.insert API endpoint, the following live stream properties are required to be specified when invoking it:

Request body

Provide a liveStream resource in the request body. For that resource:

You must specify a value for these properties:

  • snippet.title
  • cdn.frameRate
  • cdn.ingestionType
  • cdn.resolution

[...]

Now, you have to acknowledge that the error message has meaning, since you very likely did not passed to LiveStreams.insert the required resolution property.

Your code snippet above does not show how you're constructing the object $this->live_stream. Fixing the Google's sample code in the file create_broadcast.php, you'll have to have something like the code below:

// Create an object for content distribution network details for the live
// stream and specify the stream's resolution, frame rate and ingestion type.
$cdn = new Google_Service_YouTube_CdnSettings();
$cdn->setResolution("variable");
$cdn->setFrameRate("variable");
$cdn->setIngestionType('rtmp');

// Create the API request that inserts the liveStream resource.
$streamInsert = new Google_Service_YouTube_LiveStream();
$streamInsert->setSnippet($streamSnippet);
$streamInsert->setCdn($cdn);

// Execute the request and return an object that contains information
// about the new stream.
$streamsResponse = $youtube->liveStreams->insert('snippet,cdn',
    $streamInsert, array());
stvar
  • 6,551
  • 2
  • 13
  • 28