gpt4 book ai didi

php - 从 LiveStream API PHP 创建时,LiveStream 具有不同的 "stream name"(检查 API 结果,使用 API Explorer 和 YouTube 页面)

转载 作者:行者123 更新时间:2023-12-03 06:18:05 25 4
gpt4 key购买 nike

我做错了什么,还是我们在 LiveStream API 中有错误?三个不同的来源如何为同一个 Ingestion 显示三个不同的直播流名称?

由于某种原因,插入的 LiveStream 对象带有响应
与 YouTube 网页不匹配。

这个问题的部分:

  • 直播 PHP 代码
  • API 结果到 $liveStream
  • 广播插入和绑定(bind)的 PHP 代码
  • 响应 $bindBroadcastResponse
  • YouTube LiveStream API Explorer
  • 回顾
  • 并且 YouTube 页面中的结果不匹配

  • 直播 PHP 代码
    $streamSnippet = new \Google_Service_YouTube_LiveStreamSnippet();
    $streamSnippet->setTitle($cameraName);

    $cdn = new \Google_Service_YouTube_CdnSettings();
    $cdn->setFormat($cameraName);
    $cdn->setIngestionType('rtmp');

    $streamInsert = new \Google_Service_YouTube_LiveStream();
    $streamInsert->setSnippet($streamSnippet);
    $streamInsert->setCdn($cdn);
    $streamInsert->setKind('youtube#liveStream');

    $liveStream = $youtube->liveStreams->insert('snippet,cdn',$streamInsert, array());

    API 结果到 $liveStream
    Google_Service_YouTube_LiveStream Object
    (
    [cdnType:protected] => Google_Service_YouTube_CdnSettings
    ...
    [etag] => "5C5HHOaBSHC5ZXfkrT4ZlRCi01A/lY9i12sOWOAkTwfchEAQUxEWdX8"
    [id] => UOzxsX96_We6MrMTsP5RiA1480670405575117
    [kind] => youtube#liveStream
    ...
    [modelData:protected] => Array
    (
    ...
    [cdn] => Array
    (
    [format] => 1440p
    [ingestionType] => rtmp
    [ingestionInfo] => Array
    (
    [streamName] => 9zfr-ggd9-brtf-XXXX
    [ingestionAddress] => rtmp://a.rtmp.youtube.com/live2
    [backupIngestionAddress] => rtmp://b.rtmp.youtube.com/live2?backup=1
    )
    [resolution] => 1440p
    [frameRate] => 30fps
    )
    )
    ...
    )

    广播插入和绑定(bind)的 PHP 代码
    $broadcastInsert = new \Google_Service_YouTube_LiveBroadcast();
    $broadcastInsert->setSnippet($broadcastSnippet);
    $broadcastInsert->setStatus($status);
    $broadcastInsert->setKind('youtube#liveBroadcast');
    $broadcastsResponse = $youtube->liveBroadcasts->insert('snippet,status',$broadcastInsert, array());

    $bindBroadcastResponse = $youtube->liveBroadcasts->bind($broadcastsResponse['id'],'id,contentDetails',array('streamId' => $liveStream['id'],));

    响应 $bindBroadcastResponse
    Google_Service_YouTube_LiveBroadcast Object
    (
    ...
    [etag] => "5C5HHOaBSHC5ZXfkrT4ZlRCi01A/_2Jev_YmRlYUwMBX1ptq_Kp8uVs"
    [id] => idd8f7dSLzk
    [kind] => youtube#liveBroadcast
    ...
    [modelData:protected] => Array
    (
    [contentDetails] => Array
    (
    [boundStreamId] => UOzxsX96_We6MrMTsP5RiA1480670405575117
    ...
    )
    )
    )

    YouTube LiveStream API Explorer

    如果我稍后列出所有流,使用 LiveStream API Explorer ,见下图,我得到了第三个不同的结果(见下面的代码)。

    enter image description here
    {
    "kind": "youtube#liveStreamListResponse",
    "etag": "\"5C5HHOaBSHC5ZXfkrT4ZlRCi01A/RGcoFd2XK9IZmX0hgw_pFxuaeC4\"",
    "pageInfo": {
    "totalResults": 0,
    "resultsPerPage": 5
    },
    "items": [
    {
    "kind": "youtube#liveStream",
    "etag": "\"5C5HHOaBSHC5ZXfkrT4ZlRCi01A/d-ptvs6HC_oItk2Kv2PtrovurCk\"",
    "id": "UOzxsX96_We6MrMTsP5RiA1480670405575117",
    "snippet": ...,
    "cdn": {
    "format": "1440p",
    "ingestionType": "rtmp",
    "ingestionInfo": {
    "streamName": "1wzh-zjwb-b0fr-XXXX",
    "ingestionAddress": "rtmp://a.rtmp.youtube.com/live2",
    "backupIngestionAddress": "rtmp://b.rtmp.youtube.com/live2?backup=1"
    },
    "resolution": "1440p",
    "frameRate": "30fps"
    }
    }
    ]
    }

    回顾
    PHP-> Google_Service_YouTube_LiveBroadcast[id] => idd8f7dSLzk
    PHP-> Google_Service_YouTube_LiveStream->modelData[cdn][ingestionInfo][streamName] => 9zfr-ggd9-brtf-XXXX
    API Explorer -> items[0].cdn.ingestionInfo.streamName => "1wzh-zjwb-b0fr-XXXX"

    并且 YouTube 页面中的结果不匹配

    LiveStream id does not match the one I got from creation

    最佳答案

    之后 非常很长一段时间,有人将我填写的错误回复给谷歌。

    这是来自 this thread 的回复:

    It's not necessarily expected for the stream key provided by the API to match the stream key provided by the user interface. However, if the two stream keys are different, both should work.

    Please respond on this bug if you're seeing an issue where the stream keys are different and only one of them works.



    问题是我之前曾尝试使用从 API 获得的流名称进行转换,但它没有奏效。

    现在测试,它可以工作。

    关于php - 从 LiveStream API PHP 创建时,LiveStream 具有不同的 "stream name"(检查 API 结果,使用 API Explorer 和 YouTube 页面),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40929217/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com