YouTube API V3: CRUD RTMP

Viewed 60

How do you get an RTMP key and associate it with LiveBroadcasts?

I would like to create RTMP keys and associate them with scheduled broadcasts.

When I create a LiveBroadcasts the default RTMP key is associated. I need to manage these keys to be able to program and broadcast several videos simultaneously.

The RTMP key information does not exist in the LiveBroadcast.insert response, but in YouTube Studio the default key is associated with the video schedule.

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();
1 Answers

The answer is on LiveStreams and LiveBroadcasts: bind.

Once the LiveBroadcasts and LiveStreams have been created, you link them using LiveBroadcasts: bind

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();
Related