YouTube LiveStreaming method LiveStream.list does not return the stream suggested by YouTube

I stumbled upon the unexpected behavior of the YouTube liveStream API .

Whenever I request a method liveStream.list, the only threads I return are those that were triggered by my encoding software or calls liveStream.insert.

What I'm trying to extract is the stream that YouTube suggests to the default encoder setting:

enter image description here

Am I doing something wrong?

0
source share
2 answers

"Stream Now", broadcastType liveBroadcast.list.

+1

, $api_stream_url ServerURL/StreamKey

listLiveBroadcasts - .

listLiveStreams cdn - format, rtmp, streamName, ingestionAddress

try {

    // Execute an API request that lists broadcasts owned by the user who
    // authorized the request.
    $broadcastsResponse = $youtube->liveBroadcasts->listLiveBroadcasts(
        'id,snippet,contentDetails',
        array(
            'broadcastType' => 'persistent',
            'mine' => 'true',
        ));

    $boundStreamId = $broadcastsResponse['items']['0']['contentDetails']['boundStreamId'];

    $streamsResponse = $youtube->liveStreams->listLiveStreams('id,snippet,cdn', array(
//            'mine' => 'true',
        'id' => $boundStreamId
    ));


    /**
     *
     * (
    [format] => 720p
    [ingestionType] => rtmp
    [ingestionInfo] => Array
    (
    [streamName] => 4vem-9233-mz3y-detq
    [ingestionAddress] => rtmp://a.rtmp.youtube.com/live2
    [backupIngestionAddress] => rtmp://b.rtmp.youtube.com/live2?backup=1
    )

    [resolution] => 720p
    [frameRate] => 30fps
    )
     */
    $ingestionInfo = $streamsResponse['items']['0']['cdn']['ingestionInfo'];

    /**
     *  (
    [publishedAt] => 2016-06-08T12:58:38.000Z
    [channelId] => UCcdDtElpr9XM5MA1stpK
    [title] => Default Stream
    [description] =>
    [isDefaultStream] => 1
    )
     */
    $broadcastsResponse = $streamsResponse['items']['0']['snippet'];


    $api_stream_key = $ingestionInfo->streamName;
    $api_stream_address = $ingestionInfo->ingestionAddress;

    /**
     * Example:
     * rtmp://a.rtmp.youtube.com/live2/4vem-9233-mz3y-detq
     */
    $api_stream_url = $api_stream_address."/".$api_stream_key;


    return false;

} catch (Google_Service_Exception $e) {
    $htmlBody = sprintf('<p>A service error occurred: <code>%s</code></p>',
        htmlspecialchars($e->getMessage()));
} catch (Google_Exception $e) {
    $htmlBody = sprintf('<p>An client error occurred: <code>%s</code></p>',
        htmlspecialchars($e->getMessage()));
}
0

Source: https://habr.com/ru/post/1616501/


All Articles