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

LiveStream has different "stream name" when created from LiveStream API PHP (checked API result, with API Explorer and also YouTube page)

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

由于某种原因,插入的LiveStream对象带有响应 与 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
                )
        )
    ...
)

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 直播API 资源管理器

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

{
 "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 页面中的结果不匹配

很久之后,有人回复了我填的错误到Google。

这是来自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 获得的流名称进行投射,但没有成功。

正在测试,有效。