diff --git a/.changelog/30063.txt b/.changelog/30063.txt new file mode 100644 index 000000000000..cd3c9453a771 --- /dev/null +++ b/.changelog/30063.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/aws_medialive_channel: Fix type casting for `h264_settings` in `video_descriptions` +``` \ No newline at end of file diff --git a/internal/service/medialive/channel_encoder_settings_schema.go b/internal/service/medialive/channel_encoder_settings_schema.go index 7f6d2f0ae24e..83af5ffb87a5 100644 --- a/internal/service/medialive/channel_encoder_settings_schema.go +++ b/internal/service/medialive/channel_encoder_settings_schema.go @@ -4316,8 +4316,8 @@ func expandsVideoDescriptionsCodecSettingsH264Settings(tfList []interface{}) *ty if v, ok := m["gop_num_b_frames"].(int); ok { out.GopNumBFrames = int32(v) } - if v, ok := m["gop_size"].(float32); ok { - out.GopSize = float64(v) + if v, ok := m["gop_size"].(float64); ok { + out.GopSize = v } if v, ok := m["gop_size_units"].(string); ok && v != "" { out.GopSizeUnits = types.H264GopSizeUnits(v) @@ -5396,6 +5396,7 @@ func flattenCodecSettingsH264Settings(in *types.H264Settings) []interface{} { "adaptive_quantization": string(in.AdaptiveQuantization), "afd_signaling": string(in.AfdSignaling), "bitrate": int(in.Bitrate), + "buf_fill_pct": int(in.BufFillPct), "buf_size": int(in.BufSize), "color_metadata": string(in.ColorMetadata), "entropy_encoding": string(in.EntropyEncoding), @@ -5409,7 +5410,7 @@ func flattenCodecSettingsH264Settings(in *types.H264Settings) []interface{} { "gop_b_reference": string(in.GopBReference), "gop_closed_cadence": int(in.GopClosedCadence), "gop_num_b_frames": int(in.GopNumBFrames), - "gop_size": float32(in.GopSize), + "gop_size": in.GopSize, "gop_size_units": string(in.GopSizeUnits), "level": string(in.Level), "look_ahead_rate_control": string(in.LookAheadRateControl), diff --git a/internal/service/medialive/channel_test.go b/internal/service/medialive/channel_test.go index 9369011530f2..67078b5b37ba 100644 --- a/internal/service/medialive/channel_test.go +++ b/internal/service/medialive/channel_test.go @@ -324,6 +324,109 @@ func TestAccMediaLiveChannel_audioDescriptions_codecSettings(t *testing.T) { }) } +func TestAccMediaLiveChannel_videoDescriptions_codecSettings_h264Settings(t *testing.T) { + ctx := acctest.Context(t) + if testing.Short() { + t.Skip("skipping long-running test in short mode") + } + + var channel medialive.DescribeChannelOutput + rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) + resourceName := "aws_medialive_channel.test" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { + acctest.PreCheck(ctx, t) + acctest.PreCheckPartitionHasService(t, names.MediaLiveEndpointID) + testAccChannelsPreCheck(ctx, t) + }, + ErrorCheck: acctest.ErrorCheck(t, names.MediaLiveEndpointID), + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, + CheckDestroy: testAccCheckChannelDestroy(ctx), + Steps: []resource.TestStep{ + { + Config: testAccChannelConfig_videoDescriptionCodecSettingsH264Settings(rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckChannelExists(ctx, resourceName, &channel), + resource.TestCheckResourceAttrSet(resourceName, "channel_id"), + resource.TestCheckResourceAttr(resourceName, "channel_class", "STANDARD"), + resource.TestCheckResourceAttr(resourceName, "name", rName), + resource.TestCheckResourceAttrSet(resourceName, "role_arn"), + resource.TestCheckResourceAttr(resourceName, "input_specification.0.codec", "AVC"), + resource.TestCheckResourceAttr(resourceName, "input_specification.0.input_resolution", "HD"), + resource.TestCheckResourceAttr(resourceName, "input_specification.0.maximum_bitrate", "MAX_20_MBPS"), + resource.TestCheckTypeSetElemNestedAttrs(resourceName, "input_attachments.*", map[string]string{ + "input_attachment_name": "example-input1", + }), + resource.TestCheckTypeSetElemNestedAttrs(resourceName, "destinations.*", map[string]string{ + "id": rName, + }), + resource.TestCheckResourceAttr(resourceName, "encoder_settings.0.timecode_config.0.source", "EMBEDDED"), + resource.TestCheckTypeSetElemNestedAttrs(resourceName, "encoder_settings.0.audio_descriptions.*", map[string]string{ + "audio_selector_name": rName, + "name": rName, + }), + resource.TestCheckTypeSetElemNestedAttrs(resourceName, "encoder_settings.0.video_descriptions.*", map[string]string{ + "name": "test-video-name", + "respond_to_afd": "NONE", + "scaling_behavior": "DEFAULT", + "sharpness": "100", + "height": "720", + "width": "1280", + }), + resource.TestCheckTypeSetElemNestedAttrs(resourceName, "encoder_settings.0.video_descriptions.0.codec_settings.0.h264_settings.*", map[string]string{ + "adaptive_quantization": "LOW", + "afd_signaling": "NONE", + "bitrate": "5400000", + "buf_fill_pct": "90", + "buf_size": "10800000", + "color_metadata": "IGNORE", + "entropy_encoding": "CABAC", + "filter_settings": "", + "fixed_afd": "", + "flicker_aq": "ENABLED", + "force_field_pictures": "DISABLED", + "framerate_control": "SPECIFIED", + "framerate_denominator": "1", + "framerate_numerator": "50", + "gop_b_reference": "DISABLED", + "gop_closed_cadence": "1", + "gop_num_b_frames": "1", + "gop_size": "1.92", + "gop_size_units": "SECONDS", + "level": "H264_LEVEL_AUTO", + "look_ahead_rate_control": "HIGH", + "max_bitrate": "0", + "min_i_interval": "0", + "num_ref_frames": "3", + "par_control": "INITIALIZE_FROM_SOURCE", + "par_denominator": "0", + "par_numerator": "0", + "profile": "HIGH", + "quality_level": "", + "qvbr_quality_level": "0", + "rate_control_mode": "CBR", + "scan_type": "PROGRESSIVE", + "scene_change_detect": "DISABLED", + "slices": "1", + "spatial_aq": "0", + "subgop_length": "FIXED", + "syntax": "DEFAULT", + "temporal_aq": "ENABLED", + "timecode_insertion": "PIC_TIMING_SEI", + }), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"start_channel"}, + }, + }, + }) +} + func TestAccMediaLiveChannel_hls(t *testing.T) { ctx := acctest.Context(t) if testing.Short() { @@ -1191,6 +1294,132 @@ resource "aws_medialive_channel" "test" { `, rName)) } +func testAccChannelConfig_videoDescriptionCodecSettingsH264Settings(rName string) string { + return acctest.ConfigCompose( + testAccChannelBaseConfig(rName), + testAccChannelBaseS3Config(rName), + testAccChannelBaseMultiplexConfig(rName), + fmt.Sprintf(` +resource "aws_medialive_channel" "test" { + name = %[1]q + channel_class = "STANDARD" + role_arn = aws_iam_role.test.arn + + input_specification { + codec = "AVC" + input_resolution = "HD" + maximum_bitrate = "MAX_20_MBPS" + } + + input_attachments { + input_attachment_name = "example-input1" + input_id = aws_medialive_input.test.id + } + + destinations { + id = %[1]q + + settings { + url = "s3://${aws_s3_bucket.test1.id}/test1" + } + + settings { + url = "s3://${aws_s3_bucket.test2.id}/test2" + } + } + + encoder_settings { + timecode_config { + source = "EMBEDDED" + } + + audio_descriptions { + audio_selector_name = %[1]q + name = %[1]q + codec_settings { + aac_settings { + rate_control_mode = "CBR" + } + } + } + + video_descriptions { + name = "test-video-name" + respond_to_afd = "NONE" + sharpness = 100 + scaling_behavior = "DEFAULT" + width = 1280 + height = 720 + codec_settings { + h264_settings { + afd_signaling = "NONE" + color_metadata = "IGNORE" + adaptive_quantization = "LOW" + bitrate = "5400000" + buf_size = "10800000" + buf_fill_pct = "90" + entropy_encoding = "CABAC" + flicker_aq = "ENABLED" + force_field_pictures = "DISABLED" + framerate_control = "SPECIFIED" + framerate_numerator = "50" + framerate_denominator = "1" + gop_b_reference = "DISABLED" + gop_closed_cadence = "1" + gop_num_b_frames = "1" + gop_size = "1.92" + gop_size_units = "SECONDS" + subgop_length = "FIXED" + scan_type = "PROGRESSIVE" + level = "H264_LEVEL_AUTO" + look_ahead_rate_control = "HIGH" + num_ref_frames = "3" + par_control = "INITIALIZE_FROM_SOURCE" + profile = "HIGH" + rate_control_mode = "CBR" + syntax = "DEFAULT" + scene_change_detect = "ENABLED" + slices = "1" + spatial_aq = "ENABLED" + temporal_aq = "ENABLED" + timecode_insertion = "PIC_TIMING_SEI" + } + } + } + + output_groups { + output_group_settings { + archive_group_settings { + destination { + destination_ref_id = %[1]q + } + } + } + + outputs { + output_name = "test-output-name" + video_description_name = "test-video-name" + audio_description_names = [%[1]q] + output_settings { + archive_output_settings { + name_modifier = "_1" + extension = "m2ts" + container_settings { + m2ts_settings { + audio_buffer_model = "ATSC" + buffer_model = "MULTIPLEX" + rate_mode = "CBR" + } + } + } + } + } + } + } +} +`, rName)) +} + func testAccChannelConfig_hls(rName string) string { return acctest.ConfigCompose( testAccChannelBaseConfig(rName),