def create_channel()

in broadcast-monitoring/infrastructure/elemental/custom_resources/custom-resource-py/libs/medialive.py [0:0]


def create_channel(config):
    # set InputSpecification based on the input resolution:
    res = 'HD'
    bitrate = 'MAX_10_MBPS'
    profile = './encoding-profiles/medialive-demo.json'

    settings = {
        'SourceEndBehavior': 'LOOP'
    }
    with open(profile) as encoding:
        EncoderSettings = json.load(encoding)

    response = medialive.create_channel(
        ChannelClass='SINGLE_PIPELINE',  # to save cost for the demo
        InputSpecification={
            'Codec': config['Codec'],
            'Resolution': res,
            'MaximumBitrate': bitrate
        },
        InputAttachments=[{
            'InputId': config['InputId'],
            'InputSettings': settings
        }],
        Destinations=[{
            'Id': "mediapackage",
            'Settings': [  # single pipeline with single media package endpoint
                {
                    'PasswordParam': config['MediaPackagePriUser'],
                    'Url': config['MediaPackagePriUrl'],
                    'Username': config['MediaPackagePriUser']
                }
            ]
        }, {
            'Id': "s3output",
            'Settings': [
                {
                    'Url': f's3://{config["LiveStreamOutputS3Bucket"]}/live/demo-pipeline/demo'
                }
            ]
        }],
        Name=config['Name'],
        RoleArn=config['Role'],
        EncoderSettings=EncoderSettings,
    )
    responseData['ChannelId'] = response['Channel']['Id']
    print('RESPONSE::{}'.format(responseData))
    return responseData