2016-12-02 20 views
0

我做错了什么,或者在LiveStream API中有错误?三个不同的来源如何为同一个摄取显示三个不同的直播流名称?LiveStream在使用LiveStream API PHP创建时有不同的“流名称”(检查API结果,API Explorer和YouTube页面)

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

节:

  • PHP代码用于直播的
  • API结果为$直播视频
  • PHP代码的结合
  • 响应到$ bindBroadcastResponse
  • 的YouTube直播视频播放插入& API Explorer
  • Recap
  • 而结果在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结果为$直播视频

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所有后来流,见下面的图片,我得到了第三个不同结果(见下面的代码)。

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

+0

我知道这可能看起来类似于http://stackoverflow.com/questions/18235664/difference-in-ingestation-settings-creating-a-live-event-using-youtube-api-vs-we?rq= 1,但事实并非如此。该线程很久以前就不适用了。当时的API版本为v2,现在版本为v3版(我正在使用v3 api) –

+0

刚刚在Google上打开了一个缺陷:https://code.google.com/p/gdata-issues/issues/detail?id = 8814&q = label%3AAPi-YouTube&sort = -id&colspec = API%20ID%20Type%20Status%20Priority%20Stars%20Summary –

+0

仍在发生.... –

回答

0

经过非常很长一段时间,有人回复我已经填补了谷歌的错误。

这是this thread响应:

它不一定预期由API 提供以匹配用户界面提供的流密钥流密钥。但是,如果 这两个流密钥不同,则两者都应该工作。

如果您发现流 键不同且只有其中一个有效的问题,请回复此错误。

事情是,我曾尝试使用我从API获得的流名称进行投射,但它没有奏效。

现在测试,它的工作原理。

相关问题