0

I am trying to use AWS Elemental MediaLive via NET SDK.
(Dependencies Info: Net Core 6.0 & AWSSDK.MediaLive 3.7.106.36 & AWSSDK.Core 3.7.106.42)

My code looks like this

[HttpGet("Create-New-Channel")]
public async Task<IActionResult> CreateNewChannel()
{
    try
    {
        CreateChannelRequest req = new CreateChannelRequest
        {
            Name = $"Create Channel Name-{DateTime.Now:dd-MM-yyyy HH-mm-ss}",
            EncoderSettings = new EncoderSettings(),
            ChannelClass = ChannelClass.SINGLE_PIPELINE,
            InputSpecification = new InputSpecification 
            {
                Codec = InputCodec.AVC,
                MaximumBitrate = InputMaximumBitrate.MAX_10_MBPS,
                Resolution = InputResolution.SD
            }
        };
        InputAttachment iA = new InputAttachment
        {
            InputAttachmentName = $"Input Attachment Name-{DateTime.Now:dd-MM-yyyy HH-mm-ss}",
            InputId = "_______"
        };
        req.InputAttachments.Add(iA);


        OutputDestination optDes = new OutputDestination
        {
            Id = "My-problematic-ID"
        };
        optDes.Settings.Add(
            new OutputDestinationSettings {
                Url = "s3ssl://my-output-bucket/first-channel/DesA"
            }
        );
        req.Destinations.Add(optDes);
        
        CreateChannelResponse res = await _client.CreateChannelAsync(req);
        return Ok(res.HttpStatusCode);
    }
    catch (AmazonMediaLiveException mlex)
    {
        throw mlex;
    }
}

Id property in OutputDestination is required. (A combination of letters & numbers & hyphens).
So, I tried some random string ("My-problematic-ID").

Then, this line CreateChannelResponse res = await _client.CreateChannelAsync(req); returns

Amazon.MediaLive.Model.UnprocessableEntityException: Destination "My-problematic-ID" is not referenced ---> Amazon.Runtime.Internal.HttpErrorResponseException: Exception of type 'Amazon.Runtime.Internal.HttpErrorResponseException' was thrown. at Amazon.Runtime.HttpWebRequestMessage.GetResponseAsync(CancellationToken cancellationToken) at Amazon.Runtime.Internal.HttpHandler`1.InvokeAsync[T](IExecutionContext executionContext) at Amazon.Runtime.Internal.Unmarshaller.InvokeAsync[T](IExecutionContext executionContext) at Amazon.Runtime.Internal.ErrorHandler.InvokeAsync[T](IExecutionContext executionContext) --- End of inner exception stack trace ---

So, my questions are What is the right Id for OutputDestination class and How can I make a "reference" to this thing ?

ZodiacLeo123
  • 115
  • 2
  • 8

1 Answers1

0

I was able to create a new channel successfully.

  1. The Id for OutputDestination class is not null and a combination of letters/numbers/hyphens as the error warns in the error response.

  2. For the "reference", it was something like this

[HttpGet("CreateChannel")]
public async Task<IActionResult> CreateChannel()
{
    try
    {
        string destinationId = $"dId-{DateTime.Now:dd-MM-yyyy-HH-mm-ss}";
        ...
        OutputGroup outputGroup = new OutputGroup
        {
            Name = $"opgr-name-{DateTime.Now:dd-MM-yyyy HH-mm-ss}",
            OutputGroupSettings = new OutputGroupSettings
            {
                ArchiveGroupSettings = new ArchiveGroupSettings
                {
                    Destination = new OutputLocationRef
                    {
                        DestinationRefId = destinationId
                    }
                }
            }
        };
        ...
        OutputDestination optDes = new OutputDestination();
        optDes.Id = destinationId;
        ...
        CreateChannelResponse res = await _client.CreateChannelAsync(req);
        return Ok(res.Channel.Id);
    }
    catch (AmazonMediaLiveException mlex)
    {
        throw mlex;
    }
}

In my case, I was trying to save a mp4 file to S3 bucket from the live stream. Thus, the target class in my OutputGroupSettings was ArchiveGroupSettings.

※Note for future reference:
The code from the question is far from completion and it still needs a lot of modifications. My approach was creating a simple channel on AWS medialive's user interface.

Then, you can see the configuration in this section Channel Advanced Details


Or you can get it via AWS CLI using below command:
aws medialive describe-channel --channel-id=<Your_Created_Channel_ID>
Ex: aws medialive describe-channel --channel-id=6249116

ZodiacLeo123
  • 115
  • 2
  • 8