- Más nuevo
- Más votos
- Más comentarios
Hi Meriem,
We are currently still in the process of improving and adding to our documentation but here are some example codes that show how to create an Internet Security Group, an Input and a Channel.
private static String createInputSecurityGroup(AWSMediaLive client, String sourceCIDR) {
System.out.println("Creating an input security group");
InputWhitelistRuleCidr c1 = new InputWhitelistRuleCidr().withCidr(sourceCIDR);
ArrayList<InputWhitelistRuleCidr> cidrs = new ArrayList<InputWhitelistRuleCidr>();
cidrs.add(c1);
CreateInputSecurityGroupRequest createISGRequest = new CreateInputSecurityGroupRequest().withWhitelistRules(cidrs)
.withTags(Collections.singletonMap("this_is", "an_input_security_group"));
CreateInputSecurityGroupResult createISGResult = client.createInputSecurityGroup(createISGRequest);
System.out.println("Input Security Group creation completed");
return createISGResult.getSecurityGroup().getId();
}
private static String createInput(AWSMediaLive client, String isgId, String inputType) {
System.out.println("Creating a input");
CreateInputRequest createInputRequest = new CreateInputRequest()
.withName("Test")
.withType(inputType)
.withInputSecurityGroups(Arrays.asList(isgId))
.withTags(Collections.singletonMap("this_is", "an_input"));
CreateInputResult createInputResult = client.createInput(createInputRequest);
System.out.println("Input creation completed");
return createInputResult.getInput().getId();
}
private static String createChannel(ArrayList<String> inputList, AWSMediaLive client) {
System.out.println("Creating a channel");
NetworkInputSettings networkInputSettings = new NetworkInputSettings();
InputSettings inputSettings = new InputSettings().withNetworkInputSettings(networkInputSettings);
ArrayList<InputAttachment> inputAttachments = new ArrayList<>();
for (String inputId : inputList) {
InputAttachment inpAttach = new InputAttachment()
.withInputId(inputId)
.withInputAttachmentName("example.reference." + inputId)
.withInputSettings(inputSettings);
inputAttachments.add(inpAttach);
}
// HLS output destination
ArrayList<OutputDestinationSettings> hlsOutputDestinationSettings = new ArrayList<OutputDestinationSettings>() {{
add(new OutputDestinationSettings().withUrl("https://example.com/a"));
add(new OutputDestinationSettings().withUrl("https://example.com/b"));
}};
AudioCodecSettings audioCodecSettings = new AudioCodecSettings()
.withAacSettings(new AacSettings().withBitrate((double) 96000));
AudioDescription audioDescription = new AudioDescription()
.withAudioSelectorName("default")
.withName("audio1")
.withCodecSettings(audioCodecSettings);
VideoDescription videoDescription = new VideoDescription()
.withName("video1")
.withHeight(720)
.withWidth(1280)
.withCodecSettings(new VideoCodecSettings()
.withH264Settings(new H264Settings()
.withBitrate(4500000)
)
);
OutputGroup hlsOutputGroup = createHlsOutputGroup();
EncoderSettings encoderSettings = new EncoderSettings()
.withTimecodeConfig(new TimecodeConfig().withSource("EMBEDDED"))
.withAudioDescriptions(audioDescription)
.withVideoDescriptions(videoDescription, frameCaptureVideoDescription)
.withOutputGroups(udpOutputGroup, hlsOutputGroup, frameCaptureOutputGroup);
InputSpecification inputSpecification = new InputSpecification()
.withMaximumBitrate("MAX_50_MBPS")
.withCodec("HEVC")
.withResolution("SD");
CreateChannelRequest createChannelRequest = new CreateChannelRequest()
.withName("TestChannel")
.withInputAttachments(inputAttachments)
.withDestinations(
new OutputDestination().withId("utpOutputDestination").withSettings(udpOutputDestinationSettings),
new OutputDestination().withId("hlsOutputDestination").withSettings(hlsOutputDestinationSettings),
new OutputDestination().withId("frameCaptureOutputDestination").withSettings(frameCaptureOutputDestinationSettings)
)
.withEncoderSettings(encoderSettings)
.withInputSpecification(inputSpecification)
.withTags(Collections.singletonMap("this_is", "a_channel"));
CreateChannelResult createChannelResult = client.createChannel(createChannelRequest);
System.out.println("Channel creation completed");
return createChannelResult.getChannel().getId();
}
private static OutputGroup createHlsOutputGroup() {
OutputGroupSettings outputGroupSettings = new OutputGroupSettings()
.withHlsGroupSettings(new HlsGroupSettings()
.withDestination(new OutputLocationRef()
.withDestinationRefId("hlsOutputDestination"))
.withHlsCdnSettings(new HlsCdnSettings()
.withHlsBasicPutSettings(new HlsBasicPutSettings()))
// Redundant manifests
.withBaseUrlManifest("http://example.com/manifest/a")
.withBaseUrlContent("http://example.com/context/a")
.withBaseUrlManifest1("http://example.com/manifest/b")
.withBaseUrlContent1("http://example.com/context/b")
.withRedundantManifest(HlsRedundantManifest.ENABLED)
// No not use timed metadata with fMP4
.withTimedMetadataId3Frame(HlsTimedMetadataId3Frame.NONE)
.withHlsId3SegmentTagging(HlsId3SegmentTaggingState.ENABLED)
);
OutputSettings outputSettings = new OutputSettings()
.withHlsOutputSettings(new HlsOutputSettings()
// Configure this channel with fMP4
.withHlsSettings(new HlsSettings()
.withFmp4HlsSettings(new Fmp4HlsSettings()
.withAudioRenditionSets("program_audio")
)
)
.withH265PackagingType(HlsH265PackagingType.HEV1)
);
// Do not specify an audio description when using fMP4
Output output = new Output()
.withOutputName("HLS output")
.withVideoDescriptionName("video1")
.withOutputSettings(outputSettings);
OutputGroup outputGroup = new OutputGroup()
.withName("HLS group 1")
.withOutputGroupSettings(outputGroupSettings)
.withOutputs(output);
return outputGroup;
}
Zach
Hi Mariem,
Thank you for reaching out on the AWS MediaLive forums with this question. Here is a link to the AWS Java SDK for AWS MediaLive.
Please let me know if this is helpful,
Zach
Thank you zack for answering my question.
I'm a beginner in aws services and I have to read all the documentation in details to know how using all these methods and theirs parameters to have a correct code for mediaLive service. Please, there isn't a complete sdk java code example for mediaLive as the the other services?
regards
Contenido relevante
- OFICIAL DE AWSActualizada hace 5 meses
- OFICIAL DE AWSActualizada hace 3 años
hi, how to use MediaLive with output/destination as MediaPackage ?