YouTube liveStreaming API方法LiveStream.list不';YouTube提出的t返回流

YouTube liveStreaming API方法LiveStream.list不';YouTube提出的t返回流,youtube,youtube-api,youtube-data-api,Youtube,Youtube Api,Youtube Data Api,我偶然发现了一个意想不到的行为 每当我请求liveStream.list方法时,我得到的唯一流就是由编码软件或liveStream.insert调用启动的流 我想取而代之的是YouTube在 默认编码器设置: 我做错什么了吗?您可以通过在中传递broadcastType参数的persistent来检索有关默认广播或“现在流”广播的信息。这是我的最终完整代码,$api\u Stream\u url包含ServerURL/StreamKey 持续–仅返回持续广播 cdn-格式,rtmp,strea

我偶然发现了一个意想不到的行为

每当我请求
liveStream.list
方法时,我得到的唯一流就是由编码软件或
liveStream.insert
调用启动的流

我想取而代之的是YouTube在 默认编码器设置:


我做错什么了吗?

您可以通过在中传递broadcastType参数的persistent来检索有关默认广播或“现在流”广播的信息。

这是我的最终完整代码,
$api\u Stream\u url
包含
ServerURL/StreamKey

持续–仅返回持续广播

cdn-
格式
rtmp
streamName
摄取地址

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()));
}

看来这是不可能的。通读这篇文章,还没有办法做到这一点。但是,您可以尝试手动设置liveBroadcast和liveStream对象,将它们与liveBroadcasts绑定。绑定、测试流,并使用status在liveStream对象上转换为live。StreamStatus a
broadcast
(aka event)必须具有
(尽管数据可能稍后会出现),问题是你在一个
广播
页面上,所以YouTube自动生成