You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

通过AWS Lambda创建RTMP MediaLive通道失败:未定义目标引用错误

AWS MediaLive 创建通道报错:未定义目标"media-package-channel"

错误信息

Exception in thread "main" software.amazon.awssdk.services.medialive.model.UnprocessableEntityException: Object references undefined destination "media-package-channel" (Service: MediaLive, Status Code: 422, Request ID: ec05c59a-5f0d-4eed-bc6d-85fcd15400c5)

问题背景

已完成MediaLive输入源及Media Package通道的创建,但调用创建MediaLive通道接口时触发上述422错误。

相关代码片段

public static CreateChannelResponse createMediaLiveChannel5(
        MediaLiveClient mediaLiveClient, String channelName, String inputId, String mediaPackageChannel) {

    // Define Encoder Settings
    EncoderSettings encoderSettings = EncoderSettings.builder()
            .timecodeConfig(TimecodeConfig.builder()
                    .source(TimecodeConfigSource.EMBEDDED)
                    .build())
            .videoDescriptions(
                    VideoDescription.builder()
                            .name("video_q7t5tl")
                            .width(1280)
                            .height(720)
                            .sharpness(50)
                            .scalingBehavior("DEFAULT")
                            .respondToAfd("NONE")
                            .codecSettings(VideoCodecSettings.builder()
                                    .h264Settings(H264Settings.builder()
                                            .adaptiveQuantization(H264AdaptiveQuantization.AUTO)
                                            .afdSignaling(AfdSignaling.NONE)
                                            .colorMetadata(H264ColorMetadata.INSERT)
                                            .entropyEncoding(H264EntropyEncoding.CABAC)
                                            .flickerAq(H264FlickerAq.ENABLED)
                                            .forceFieldPictures(H264ForceFieldPictures.DISABLED)
                                            .framerateControl("SPECIFIED")
                                            .framerateNumerator(30000)
                                            .framerateDenominator(1001)
                                            .gopBReference(H264GopBReference.DISABLED)
                                            .gopClosedCadence(1)
                                            .gopSize(90.0)
                                            .gopSizeUnits(H264GopSizeUnits.FRAMES)
                                            .level(H264Level.H264_LEVEL_AUTO)
                                            .lookAheadRateControl(H264LookAheadRateControl.MEDIUM)
                                            .numRefFrames(1)
                                            .parControl(H264ParControl.SPECIFIED)
                                            .profile(H264Profile.MAIN)
                                            .rateControlMode(H264RateControlMode.CBR)
                                            .scanType(H264ScanType.PROGRESSIVE)
                                            .sceneChangeDetect(H264SceneChangeDetect.ENABLED)
                                            .spatialAq(H264SpatialAq.ENABLED)
                                            .subgopLength("FIXED")
                                            .syntax(H264Syntax.DEFAULT)
                                            .temporalAq(H264TemporalAq.ENABLED)
                                            .timecodeInsertion("DISABLED")
                                            .build())
                                    .build())
                            .build(),
                    VideoDescription.builder()
                            .name("video_d6yva3")
                            .width(1920)
                            .height(720)
                            .sharpness(50)
                            .scalingBehavior("DEFAULT")
                            .respondToAfd("NONE")
                            .codecSettings(VideoCodecSettings.builder()
                                    .h264Settings(H264Settings.builder()
                                            .adaptiveQuantization(H264AdaptiveQuantization.AUTO)
                                            .afdSignaling(AfdSignaling.NONE)
                                            .colorMetadata(H264ColorMetadata.INSERT)
                                            .entropyEncoding(H264EntropyEncoding.CABAC)
                                            .flickerAq(H264FlickerAq.ENABLED)
                                            .forceFieldPictures(H264ForceFieldPictures.DISABLED)
                                            .framerateControl("SPECIFIED")
                                            .framerateNumerator(30000)
                                            .framerateDenominator(1001)
                                            .gopBReference(H264GopBReference.DISABLED)
                                            .gopClosedCadence(1)
                                            .gopSize(90.0)
                                            .gopSizeUnits(H264GopSizeUnits.FRAMES)
                                            .level(H264Level.H264_LEVEL_AUTO)
                                            .lookAheadRateControl(H264LookAheadRateControl.MEDIUM)
                                            .numRefFrames(1)
                                            .parControl(H264ParControl.SPECIFIED)
                                            .profile(H264Profile.MAIN)
                                            .rateControlMode(H264RateControlMode.CBR)
                                            .scanType(H264ScanType.PROGRESSIVE)
                                            .sceneChangeDetect(H264SceneChangeDetect.ENABLED)
                                            .spatialAq(H264SpatialAq.ENABLED)
                                            .subgopLength("FIXED")
                                            .syntax(H264Syntax.DEFAULT)
                                            .temporalAq(H264TemporalAq.ENABLED)
                                            .timecodeInsertion("DISABLED")
                                            .build())
                                    .build())
                            .build())
            .audioDescriptions(
                    AudioDescription.builder()
                            .name("audio_82lool")
                            .audioSelectorName("default")
                            .build(),
                    AudioDescription.builder()
                            .name("audio_l1c2h")
                            .audioSelectorName("default")
                            .build())
            .outputGroups(
                    OutputGroup.builder()
                            .name("LiveStream")
                            .outputGroupSettings(
                                    OutputGroupSettings.builder()
                                            .mediaPackageGroupSettings(
                                                    MediaPackageGroupSettings.builder()
                                                            .destination(
                                                                    OutputLocationRef.builder()
                                                                            .destinationRefId(mediaPackageChannel)
                                                                            .build())
//                                                            .mediaPackageSettings(
//                                                                    MediaPackageSettings.builder()
//                                                                            .channelId(mediaPackageChannelArn)
//                                                                            .build())
                                                            .build())
                                            .build())
                            .outputs(
                                    Output.builder()
                                            .outputName("7iwvon")
                                            .audioDescriptionNames("audio_82lool")
                                            .videoDescriptionName("video_q7t5tl")
                                            .outputSettings(
                                                    OutputSettings.builder()
                                                            .mediaPackageOutputSettings(MediaPackageOutputSettings.builder().build())
                                                            .build())
                                            .build(),
                                    Output.builder()
                                            .outputName("nhgtaj")
                                            .audioDescriptionNames("audio_l1c2h")
                                            .videoDescriptionName("video_d6yva3")
                                            .outputSettings(
                                                    OutputSettings.builder()
                                                            .mediaPackageOutputSettings(MediaPackageOutputSettings.builder().build())
                                                            .build())
                                            .build())
                            .build())
            .build();

    // Create MediaLive Channel
    return mediaLiveClient.createChannel(
            CreateChannelRequest.builder()
                    .name(channelName)
                    .inputAttachments(
                            InputAttachment.builder()
                                    .inputId(inputId)
                                    .inputAttachmentName("LiveStream2")
                                    .inputSettings(
                                            InputSettings.builder()
                                                    .sourceEndBehavior(InputSourceEndBehavior.CONTINUE)
                                                    .filterStrength(1)
                                                    .inputFilter(InputFilter.AUTO)
                                                    .deblockFilter("DISABLED")
                                                    .denoiseFilter("DISABLED")
                                                    .build())
                                    .build())
                    .encoderSettings(encoderSettings)
                    .inputSpecification(
                            InputSpecification.builder()
                                    .codec(InputCodec.AVC)
                                    .maximumBitrate(InputMaximumBitrate.MAX_20_MBPS)
                                    .resolution(InputResolution.HD)
                                    .build())
                  //  .destinations(OutputDestination.builder().id("mediaPackageChannel").build())
                    .destinations(
                            OutputDestination.builder()
                                    .mediaPackageSettings(
                                            MediaPackageOutputDestinationSettings.builder()
                                                  //  .copy().build())
                                                    .channelId(mediaPackageChannel)
                                                    .build())
                                    .id("media-package-destination")
                                    .build())
                    .channelClass(ChannelClass.SINGLE_PIPELINE)
                    .roleArn("arn:aws:iam::************:role/MediaLiveAccessRole")
                    .build());
}

解决方案

问题原因

代码中EncoderSettings里的MediaPackageGroupSettings错误地将destinationRefId设置为MediaPackage通道ID,实际上这个参数需要引用的是CreateChannelRequest中destinations定义的输出目标ID。当前destinations里定义的输出目标ID是media-package-destination,但代码里引用了不匹配的值,导致系统提示"未定义目标"。

修改步骤

  1. 修改EncoderSettings中的MediaPackageGroupSettings部分,将destinationRefId(mediaPackageChannel)替换为destinationRefId("media-package-destination"),确保和destinations里的ID一致:
MediaPackageGroupSettings.builder()
        .destination(
                OutputLocationRef.builder()
                        .destinationRefId("media-package-destination") // 与destinations中定义的ID匹配
                        .build())
        .build()
  1. 确认destinations中的MediaPackageOutputDestinationSettings的channelId正确传入MediaPackage通道ID(当前代码这部分逻辑正确,mediaPackageChannel参数即为该ID)。

修改后重新调用创建接口即可解决该错误。

内容的提问来源于stack exchange,提问作者prathamesh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 05:29:52