YouTube API V3:CRUD RTMP
YouTube API V3: CRUD RTMP
如何获取 RTMP 密钥并将其与直播相关联?
我想创建 RTMP 密钥并将它们与计划的广播相关联。
当我创建 LiveBroadcasts 时,会关联默认的 RTMP 密钥。我需要管理这些密钥才能同时对多个视频进行编程和广播。
LiveBroadcast.insert 响应中不存在 RTMP 密钥信息,但在 YouTube Studio 中,默认密钥与视频时间表相关联。
GoogleCredential cred = await auth.GetCredentialAsync();
var service = new YouTubeService(new BaseClientService.Initializer
{
HttpClientInitializer = cred
});
var liveBroadcast = new LiveBroadcast();
var snippet = new LiveBroadcastSnippet();
snippet.Title = "Video example 1";
snippet.ScheduledStartTime = new DateTime(2021, 7, 15, 9, 0, 0);
snippet.ScheduledEndTime = new DateTime(2021, 7, 15, 10, 30, 0);
liveBroadcast.Snippet = snippet;
var status = new LiveBroadcastStatus();
status.PrivacyStatus = "public";
status.SelfDeclaredMadeForKids = true;
liveBroadcast.Status = status;
var contentDetails = new LiveBroadcastContentDetails();
contentDetails.EnableAutoStart = true;
contentDetails.EnableAutoStop = true;
contentDetails.RecordFromStart = true;
contentDetails.EnableDvr = true;
liveBroadcast.ContentDetails = contentDetails;
var request = service.LiveBroadcasts.Insert(liveBroadcast, "snippet, contentDetails, status");
var response = await request.ExecuteAsync();
答案在 LiveStreams 和 LiveBroadcasts 上:绑定。
创建 LiveBroadcasts 和 LiveStreams 后,您 link 使用 LiveBroadcasts:绑定
var liveStream = new LiveStream();
var snippet = new LiveStreamSnippet();
snippet.Title = "Key A";
liveStream.Snippet = snippet;
var cdn = new CdnSettings();
cdn.Format = "";
cdn.IngestionType = "rtmp";
cdn.FrameRate = "variable";
cdn.Resolution = "variable";
liveStream.Cdn = cdn;
var request = service.LiveStreams.Insert(liveStream, "snippet, cdn");
var response = await aux.ExecuteAsync();
var liveBroadcastsBind = service.LiveBroadcasts.Bind(IdLiveBroadcasts, "id, contentDetails");
liveBroadcastsBind.StreamId = IdLiveStream;
var response = await liveBroadcastsBind.ExecuteAsync();
如何获取 RTMP 密钥并将其与直播相关联?
我想创建 RTMP 密钥并将它们与计划的广播相关联。
当我创建 LiveBroadcasts 时,会关联默认的 RTMP 密钥。我需要管理这些密钥才能同时对多个视频进行编程和广播。
LiveBroadcast.insert 响应中不存在 RTMP 密钥信息,但在 YouTube Studio 中,默认密钥与视频时间表相关联。
GoogleCredential cred = await auth.GetCredentialAsync();
var service = new YouTubeService(new BaseClientService.Initializer
{
HttpClientInitializer = cred
});
var liveBroadcast = new LiveBroadcast();
var snippet = new LiveBroadcastSnippet();
snippet.Title = "Video example 1";
snippet.ScheduledStartTime = new DateTime(2021, 7, 15, 9, 0, 0);
snippet.ScheduledEndTime = new DateTime(2021, 7, 15, 10, 30, 0);
liveBroadcast.Snippet = snippet;
var status = new LiveBroadcastStatus();
status.PrivacyStatus = "public";
status.SelfDeclaredMadeForKids = true;
liveBroadcast.Status = status;
var contentDetails = new LiveBroadcastContentDetails();
contentDetails.EnableAutoStart = true;
contentDetails.EnableAutoStop = true;
contentDetails.RecordFromStart = true;
contentDetails.EnableDvr = true;
liveBroadcast.ContentDetails = contentDetails;
var request = service.LiveBroadcasts.Insert(liveBroadcast, "snippet, contentDetails, status");
var response = await request.ExecuteAsync();
答案在 LiveStreams 和 LiveBroadcasts 上:绑定。
创建 LiveBroadcasts 和 LiveStreams 后,您 link 使用 LiveBroadcasts:绑定
var liveStream = new LiveStream();
var snippet = new LiveStreamSnippet();
snippet.Title = "Key A";
liveStream.Snippet = snippet;
var cdn = new CdnSettings();
cdn.Format = "";
cdn.IngestionType = "rtmp";
cdn.FrameRate = "variable";
cdn.Resolution = "variable";
liveStream.Cdn = cdn;
var request = service.LiveStreams.Insert(liveStream, "snippet, cdn");
var response = await aux.ExecuteAsync();
var liveBroadcastsBind = service.LiveBroadcasts.Bind(IdLiveBroadcasts, "id, contentDetails");
liveBroadcastsBind.StreamId = IdLiveStream;
var response = await liveBroadcastsBind.ExecuteAsync();