【问题标题】:How do I change "type of stream" Streaming software to Built-in webcam如何将“流类型”流媒体软件更改为内置网络摄像头
【发布时间】:2021-06-15 12:29:37
【问题描述】:

我正在使用 Google API 创建 YouTube 直播。并成功创建。 它的默认流选项类型是“流媒体软件”

我需要将其更改为“内置网络摄像头”

我正在使用this使用PHP来实现。

$client = new Google_Client();
$client->setClientId($OAUTH2_CLIENT_ID);
$client->setClientSecret($OAUTH2_CLIENT_SECRET);
$client->setScopes('https://www.googleapis.com/auth/youtube');

$client->setAccessToken($accessToken);
try {



// Define service object for making API requests.
    $service = new Google_Service_YouTube($client);

// Define the $liveBroadcast object, which will be uploaded as the request body.
    $liveBroadcast = new Google_Service_YouTube_LiveBroadcast();

// Add 'contentDetails' object to the $liveBroadcast object.
    $liveBroadcastContentDetails = new Google_Service_YouTube_LiveBroadcastContentDetails();
    $liveBroadcastContentDetails->setEnableClosedCaptions(true);
    $liveBroadcastContentDetails->setEnableContentEncryption(true);
    $liveBroadcastContentDetails->setEnableDvr(true);
// $liveBroadcastContentDetails->setEnableEmbed(true);
    $liveBroadcastContentDetails->setRecordFromStart(true);
    $liveBroadcastContentDetails->setStartWithSlate(true);
    $liveBroadcast->setContentDetails($liveBroadcastContentDetails);

// Add 'snippet' object to the $liveBroadcast object.
    $liveBroadcastSnippet = new Google_Service_YouTube_LiveBroadcastSnippet();
    $liveBroadcastSnippet->setScheduledStartTime($start_date_time);
    $liveBroadcastSnippet->setTitle($class_name);
    $liveBroadcast->setSnippet($liveBroadcastSnippet);

// Add 'status' object to the $liveBroadcast object.
    $liveBroadcastStatus = new Google_Service_YouTube_LiveBroadcastStatus();
    $liveBroadcastStatus->setPrivacyStatus('unlisted');
    $liveBroadcast->setStatus($liveBroadcastStatus);

    $response = $service->liveBroadcasts->insert('snippet,contentDetails,status', $liveBroadcast);
    return ($response->id);


} catch (Google_Service_Exception $e) {
    return;
} catch (Google_Exception $e) {
    return;
}

【问题讨论】:

    标签: php google-api youtube-data-api


    【解决方案1】:

    请确认内置网络摄像头是一种用户只能在 YouTube Studio 中设置的流媒体。

    YouTube Studio 应用可以让用户按照更短的路径创建连接到网络摄像头的直播;这样就不需要将他/她的网络摄像头显式连接到直播编码软件。

    另一方面,当涉及到以编程方式创建和管理 YouTube 直播时(即使用YouTube Live Streaming API 时),一个人的工作是 w.r.t.创建网络摄像头实时流有点复杂。这是因为通过使用 YouTube Studio 实现的几个中间步骤必须在使用 API 开发的应用程序中明确执行。

    也就是说,如果您想以编程方式创建网络摄像头 YouTube 直播,您将必须遵循直播和直播所需的所有 API 步骤,以及创建合适的直播所需的额外工作在您的本地计算机中处理捕获网络摄像头并发布 YouTube 能够摄取的 suitable encoded stream

    在这种情况下,YouTube Studio 会将您的流的类型指示为流媒体软件,因为事实上,从 YouTube 的角度来看,您的流正是这种类型。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-09-10
      • 2015-09-10
      • 2017-05-24
      • 2020-05-05
      • 1970-01-01
      • 1970-01-01
      • 2021-04-10
      相关资源
      最近更新 更多