gpt4 book ai didi

youtube - 在使用 YouTube Live Streaming API 时使用基本摄取或避免重复的自定义摄取

转载 作者:行者123 更新时间:2023-12-04 15:41:52 26 4
gpt4 key购买 nike

我们将 YouTube Live Streaming API 与 Google API PHP Client 结合使用我无法弄清楚如何使用基本(预设)摄取而不是自定义摄取。

自定义的没问题,但出于某种原因,即使您将它们命名为相同的名称,它也会不断为您创建的每个流创建重复项。

所以我的问题是,我们如何让它使用基本摄取或能够选择自定义摄取而不每次都创建新摄取?

例如,以下是您在 YouTube 帐户中手动设置流时可以选择的基本摄取:

YouTube encoder

相关 PHP 代码:

// Create an object for the liveBroadcast resource's snippet. Specify values
// for the snippet's title, scheduled start time, and scheduled end time.
$broadcastSnippet = new Google_Service_YouTube_LiveBroadcastSnippet();
$broadcastSnippet->setTitle($this->title);
$broadcastSnippet->setDescription($this->desc);
$broadcastSnippet->setScheduledStartTime($this->start_time);

// Create an object for the liveBroadcast resource's status, and set the
// broadcast's status.
$status = new Google_Service_YouTube_LiveBroadcastStatus();
$status->setPrivacyStatus($this->privacy_status);

// Create the API request that inserts the liveBroadcast resource.
$broadcastInsert = new Google_Service_YouTube_LiveBroadcast();
$broadcastInsert->setSnippet($broadcastSnippet);
$broadcastInsert->setStatus($status);
$broadcastInsert->setKind('youtube#liveBroadcast');

// Execute the request and return an object that contains information
// about the new broadcast.
$broadcastsResponse = $this->youtube->liveBroadcasts->insert('snippet,status', $broadcastInsert, array());

// Create an object for the liveStream resource's snippet. Specify a value
// for the snippet's title.
$streamSnippet = new Google_Service_YouTube_LiveStreamSnippet();
$streamSnippet->setTitle($this->stream_title);

// Create an object for content distribution network details for the live
// stream and specify the stream's format and ingestion type.
$cdn = new Google_Service_YouTube_CdnSettings();
# TODO: Update the below `Format` method to use the new 'resolution' and 'frameRate' methods
$cdn->setFormat($this->format);
$cdn->setIngestionType('rtmp');

// Create the API request that inserts the liveStream resource.
$streamInsert = new Google_Service_YouTube_LiveStream();
$streamInsert->setSnippet($streamSnippet);
$streamInsert->setCdn($cdn);
$streamInsert->setKind('youtube#liveStream');

// Execute the request and return an object that contains information
// about the new stream.
$streamsResponse = $this->youtube->liveStreams->insert('snippet,cdn', $streamInsert, array());

// Bind the broadcast to the live stream.
$bindBroadcastResponse = $this->youtube->liveBroadcasts->bind(
$broadcastsResponse['id'], 'id,contentDetails',
array(
'streamId' => $streamsResponse['id'],
));

最佳答案

我不确定您所说的“基本摄取”是什么意思。根据 API,唯一可设置的摄取属性是 cdn.ingestionType目前仅支持 RTMP 摄取。

您在 Web 门户中看到的编码器设置等效于 cdn.format 值,提供了一个界面来为您的直播选择比特率-分辨率对。此属性已于 2016 年 4 月 18 日弃用,取而代之的是两个新属性: cdn.frameRate cdn.resolution . Web 门户中列出的比特率值是每个分辨率的推荐比特率,由您的编码器配置,而不是 API。

正确设置自定义 cdn格式不应导致重复的 Live Stream 对象。您的代码中其他地方可能存在错误。如果你觉得这是一个API缺陷,我建议你给Google开一张票here .

关于youtube - 在使用 YouTube Live Streaming API 时使用基本摄取或避免重复的自定义摄取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36965048/

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