使用 mp4、mp3 和 SRT 作为输入为 HLS 输出创建 mediaconvert 作业时出错

Error creating mediaconvert job for HLS output with mp4, mp3 and SRT as input

我正在尝试编写 Go 代码以在 MediaConvert 上创建一个作业,该作业将 MP4 视频作为输入,一些 MP3 用作不同的音轨,一些 SRT 文件用于字幕。

我的 Go 代码生成了发送到 AWS 的 JSON:

{
    "clientRequestToken": "---",
    "role": "---",
    "settings": {
        "inputs": [{
            "audioSelectors": {
                "ENG": {
                    "defaultSelection": "NOT_DEFAULT",
                    "externalAudioFileInput": "s3://mybucket/test/sample1.mp3",
                    "languageCode": "ENG",
                    "offset": 0,
                    "programSelection": 1,
                    "selectorType": "TRACK"
                },
                "SPA": {
                    "defaultSelection": "NOT_DEFAULT",
                    "externalAudioFileInput": "s3://mybucket/test/sample3.mp3",
                    "languageCode": "SPA",
                    "offset": 0,
                    "programSelection": 1,
                    "selectorType": "TRACK"
                },
                "floor": {
                    "defaultSelection": "DEFAULT",
                    "offset": 0,
                    "programSelection": 1
                }
            },
            "captionSelectors": {
                "ENG": {
                    "languageCode": "ENG",
                    "sourceSettings": {
                        "fileSourceSettings": {
                            "sourceFile": "s3://mybucket/test/eng.srt"
                        },
                        "sourceType": "SRT"
                    }
                },
                "SPA": {
                    "languageCode": "SPA",
                    "sourceSettings": {
                        "fileSourceSettings": {
                            "sourceFile": "s3://mybucket/test/spa.srt"
                        },
                        "sourceType": "SRT"
                    }
                }
            },
            "deblockFilter": "DISABLED",
            "denoiseFilter": "DISABLED",
            "fileInput": "s3://mybucket/test/video.mp4",
            "filterEnable": "AUTO",
            "psiControl": "USE_PSI",
            "timecodeSource": "EMBEDDED",
            "videoSelector": {
                "alphaBehavior": "DISCARD",
                "colorSpace": "FOLLOW",
                "rotate": "DEGREE_0"
            }
        }],
        "outputGroups": [{
            "name": "Apple HLS",
            "outputGroupSettings": {
                "hlsGroupSettings": {
                    "captionLanguageSetting": "OMIT",
                    "clientCache": "ENABLED",
                    "codecSpecification": "RFC_4281",
                    "destination": "s3://mybucket/1/encoded",
                    "directoryStructure": "SINGLE_DIRECTORY",
                    "manifestCompression": "NONE",
                    "manifestDurationFormat": "INTEGER",
                    "minSegmentLength": 0,
                    "outputSelection": "MANIFESTS_AND_SEGMENTS",
                    "programDateTime": "EXCLUDE",
                    "programDateTimePeriod": 600,
                    "segmentControl": "SEGMENTED_FILES",
                    "segmentLength": 5,
                    "streamInfResolution": "INCLUDE",
                    "timedMetadataId3Period": 10
                },
                "type": "HLS_GROUP_SETTINGS"
            },
            "outputs": [{
                "audioDescriptions": [{
                        "audioSourceName": "floor",
                        "codecSettings": {
                            "aacSettings": {
                                "audioDescriptionBroadcasterMix": "NORMAL",
                                "bitrate": 96000,
                                "codecProfile": "LC",
                                "codingMode": "CODING_MODE_2_0",
                                "rateControlMode": "CBR",
                                "rawFormat": "NONE",
                                "sampleRate": 48000,
                                "specification": "MPEG4"
                            },
                            "codec": "AAC"
                        },
                        "languageCode": "FOLLOW_INPUT"
                    },
                    {
                        "audioSourceName": "ENG",
                        "codecSettings": {
                            "aacSettings": {
                                "audioDescriptionBroadcasterMix": "NORMAL",
                                "bitrate": 96000,
                                "codecProfile": "LC",
                                "codingMode": "CODING_MODE_2_0",
                                "rateControlMode": "CBR",
                                "rawFormat": "NONE",
                                "sampleRate": 48000,
                                "specification": "MPEG4"
                            },
                            "codec": "AAC"
                        },
                        "languageCode": "FOLLOW_INPUT"
                    },
                    {
                        "audioSourceName": "SPA",
                        "codecSettings": {
                            "aacSettings": {
                                "audioDescriptionBroadcasterMix": "NORMAL",
                                "bitrate": 96000,
                                "codecProfile": "LC",
                                "codingMode": "CODING_MODE_2_0",
                                "rateControlMode": "CBR",
                                "rawFormat": "NONE",
                                "sampleRate": 48000,
                                "specification": "MPEG4"
                            },
                            "codec": "AAC"
                        },
                        "languageCode": "FOLLOW_INPUT"
                    }
                ],
                "captionDescriptions": [{
                        "captionSelectorName": "ENG",
                        "destinationSettings": {
                            "destinationType": "EMBEDDED"
                        }
                    },
                    {
                        "captionSelectorName": "SPA",
                        "destinationSettings": {
                            "destinationType": "EMBEDDED"
                        }
                    }
                ],
                "containerSettings": {
                    "container": "M3U8",
                    "m3u8Settings": {}
                },
                "extension": "m3u8",
                "nameModifier": "1",
                "outputSettings": {
                    "hlsSettings": {
                        "audioGroupId": "program_audio",
                        "audioOnlyContainer": "AUTOMATIC",
                        "iFrameOnlyManifest": "EXCLUDE"
                    }
                },
                "videoDescription": {
                    "afdSignaling": "NONE",
                    "antiAlias": "ENABLED",
                    "codecSettings": {
                        "codec": "H_264",
                        "h264Settings": {
                            "adaptiveQuantization": "HIGH",
                            "codecLevel": "AUTO",
                            "codecProfile": "MAIN",
                            "dynamicSubGop": "STATIC",
                            "entropyEncoding": "CABAC",
                            "fieldEncoding": "PAFF",
                            "flickerAdaptiveQuantization": "DISABLED",
                            "framerateControl": "INITIALIZE_FROM_SOURCE",
                            "framerateConversionAlgorithm": "DUPLICATE_DROP",
                            "gopBReference": "DISABLED",
                            "gopClosedCadence": 0,
                            "gopSize": 90,
                            "gopSizeUnits": "FRAMES",
                            "interlaceMode": "PROGRESSIVE",
                            "maxBitrate": 5000000,
                            "minIInterval": 0,
                            "numberBFramesBetweenReferenceFrames": 2,
                            "numberReferenceFrames": 3,
                            "parControl": "INITIALIZE_FROM_SOURCE",
                            "qualityTuningLevel": "SINGLE_PASS",
                            "rateControlMode": "QVBR",
                            "repeatPps": "DISABLED",
                            "sceneChangeDetect": "ENABLED",
                            "slices": 1,
                            "slowPal": "DISABLED",
                            "softness": 0,
                            "spatialAdaptiveQuantization": "ENABLED",
                            "syntax": "DEFAULT",
                            "telecine": "NONE",
                            "temporalAdaptiveQuantization": "ENABLED",
                            "unregisteredSeiTimecode": "DISABLED"
                        }
                    },
                    "colorMetadata": "INSERT",
                    "dropFrameTimecode": "ENABLED",
                    "respondToAfd": "NONE",
                    "scalingBehavior": "DEFAULT",
                    "sharpness": 50,
                    "timecodeInsertion": "DISABLED"
                }
            }]
        }],
        "timecodeConfig": {
            "source": "ZEROBASED"
        }
    },
    "tags": {
        "Env": "dev"
    }
}

我的问题是 rest api return error 400 bad request with message:

"message" : "The request could not be interpreted.","settingsValidationErrorsJsonBlob" : ""

有人可以给我一些建议以了解可能是哪个问题吗?

谢谢!

首先,让我先声明一下我不熟悉 Go,因此我将您的 JSON 转换为 Pascal 大小写并通过 AWS CLI 进行了测试。我已经在下面为您将我的结果转换回驼峰式大小写。

根据我的发现 - JSON 的开头和结尾似乎有一些无关的文本。从顶部删除以下位后:

{
  "clientRequestToken": "---",
  "role": "---",
  "settings": 

以及倒数以下

,
  "tags": {
    "Env": "dev"
  }
}

我收到了不同的错误响应:

An error occurred (BadRequestException) when calling the CreateJob operation: The request could not be interpreted.

更深入地观察,我注意到您的输入音频选择器中也有一些相互矛盾的参数。如果我不得不猜测,如果我错了请纠正我,你正在尝试在音频选择器声明中设置语言代码。这是音频选择器之一,以突出显示我在说什么:

                "ENG": {
                    "defaultSelection": "NOT_DEFAULT",
                    "externalAudioFileInput": "s3://mybucket/test/sample1.mp3",
                    "languageCode": "ENG",
                    "offset": 0,
                    "programSelection": 1,
                    "selectorType": "TRACK"
                }

"languageCode": "ENG" 告诉 MediaConvert 您想要从音频源文件中提取 ENG 轨道,但是您还声明了 "selectorType": "TRACK" 告诉 MediaConvert 您想要按曲目号提取音频。由于您指定了音轨选择器类型,我假设您实际上只想从音频文件中提取音轨 1 并将音频选择器修改为如下所示:

        "ENG": {
          "tracks": [
            1
          ],
          "defaultSelection": "NOT_DEFAULT",
          "selectorType": "TRACK",
          "externalAudioFileInput": "s3://mybucket/test/sample1.mp3"
        },

如果我猜错了而你确实打算使用 ENG 曲目,那么该节应该如下所示:

          "ENG": {
            "DefaultSelection": "NOT_DEFAULT",
            "SelectorType": "LANGUAGE_CODE",
            "ExternalAudioFileInput": "s3://mybucket/test/sample1.mp3",
            "LanguageCode": "ENG"
          },

最后,我将语言代码移到了 ENG 和 SPA 音轨的输出端,这是您需要调出它们的地方。另请注意,FOLLOW_INPUT 对 LanguageCode 无效,因此我已将这些键更改为 LanguageCodeControl。这是工作 JSON:

{
  "inputs": [
    {
      "audioSelectors": {
        "ENG": {
          "tracks": [
            1
          ],
          "defaultSelection": "NOT_DEFAULT",
          "selectorType": "TRACK",
          "externalAudioFileInput": "s3://mybucket/test/sample1.mp3"
        },
        "SPA": {
          "tracks": [
            1
          ],
          "defaultSelection": "NOT_DEFAULT",
          "selectorType": "TRACK",
          "externalAudioFileInput": "s3://mybucket/test/sample3.mp3"
        },
        "floor": {
          "defaultSelection": "DEFAULT"
        }
      },
      "captionSelectors": {
        "ENG": {
          "languageCode": "ENG",
          "sourceSettings": {
            "fileSourceSettings": {
              "sourceFile": "s3://mybucket/test/eng.srt"
            },
            "sourceType": "SRT"
          }
        },
        "SPA": {
          "languageCode": "SPA",
          "sourceSettings": {
            "fileSourceSettings": {
              "sourceFile": "s3://mybucket/test/spa.srt"
            },
            "sourceType": "SRT"
          }
        }
      },
      "deblockFilter": "DISABLED",
      "denoiseFilter": "DISABLED",
      "fileInput": "s3://mybucket/test/video.mp4",
      "filterEnable": "AUTO",
      "psiControl": "USE_PSI",
      "timecodeSource": "EMBEDDED",
      "videoSelector": {
        "alphaBehavior": "DISCARD",
        "colorSpace": "FOLLOW",
        "rotate": "DEGREE_0"
      }
    }
  ],
  "outputGroups": [
    {
      "name": "Apple HLS",
      "outputGroupSettings": {
        "hlsGroupSettings": {
          "captionLanguageSetting": "OMIT",
          "clientCache": "ENABLED",
          "codecSpecification": "RFC_4281",
          "destination": "s3://mybucket/1/encoded",
          "directoryStructure": "SINGLE_DIRECTORY",
          "manifestCompression": "NONE",
          "manifestDurationFormat": "INTEGER",
          "minSegmentLength": 0,
          "outputSelection": "MANIFESTS_AND_SEGMENTS",
          "programDateTime": "EXCLUDE",
          "programDateTimePeriod": 600,
          "segmentControl": "SEGMENTED_FILES",
          "segmentLength": 5,
          "streamInfResolution": "INCLUDE",
          "timedMetadataId3Period": 10
        },
        "type": "HLS_GROUP_SETTINGS"
      },
      "outputs": [
        {
          "audioDescriptions": [
            {
              "audioSourceName": "floor",
              "codecSettings": {
                "aacSettings": {
                  "audioDescriptionBroadcasterMix": "NORMAL",
                  "bitrate": 96000,
                  "codecProfile": "LC",
                  "codingMode": "CODING_MODE_2_0",
                  "rateControlMode": "CBR",
                  "rawFormat": "NONE",
                  "sampleRate": 48000,
                  "specification": "MPEG4"
                },
                "codec": "AAC"
              },
              "languageCodeControl": "FOLLOW_INPUT"
            },
            {
              "audioSourceName": "ENG",
              "codecSettings": {
                "aacSettings": {
                  "audioDescriptionBroadcasterMix": "NORMAL",
                  "bitrate": 96000,
                  "codecProfile": "LC",
                  "codingMode": "CODING_MODE_2_0",
                  "rateControlMode": "CBR",
                  "rawFormat": "NONE",
                  "sampleRate": 48000,
                  "specification": "MPEG4"
                },
                "codec": "AAC"
              },
              "languageCode": "ENG"
            },
            {
              "audioSourceName": "SPA",
              "codecSettings": {
                "aacSettings": {
                  "audioDescriptionBroadcasterMix": "NORMAL",
                  "bitrate": 96000,
                  "codecProfile": "LC",
                  "codingMode": "CODING_MODE_2_0",
                  "rateControlMode": "CBR",
                  "rawFormat": "NONE",
                  "sampleRate": 48000,
                  "specification": "MPEG4"
                },
                "codec": "AAC"
              },
              "languageCode": "SPA"
            }
          ],
          "captionDescriptions": [
            {
              "captionSelectorName": "ENG",
              "destinationSettings": {
                "destinationType": "EMBEDDED"
              }
            },
            {
              "captionSelectorName": "SPA",
              "destinationSettings": {
                "destinationType": "EMBEDDED"
              }
            }
          ],
          "containerSettings": {
            "container": "M3U8",
            "m3u8Settings": {}
          },
          "extension": "m3u8",
          "nameModifier": "1",
          "outputSettings": {
            "hlsSettings": {
              "audioGroupId": "program_audio",
              "audioOnlyContainer": "AUTOMATIC",
              "iFrameOnlyManifest": "EXCLUDE"
            }
          },
          "videoDescription": {
            "afdSignaling": "NONE",
            "antiAlias": "ENABLED",
            "codecSettings": {
              "codec": "H_264",
              "h264Settings": {
                "adaptiveQuantization": "HIGH",
                "codecLevel": "AUTO",
                "codecProfile": "MAIN",
                "dynamicSubGop": "STATIC",
                "entropyEncoding": "CABAC",
                "fieldEncoding": "PAFF",
                "flickerAdaptiveQuantization": "DISABLED",
                "framerateControl": "INITIALIZE_FROM_SOURCE",
                "framerateConversionAlgorithm": "DUPLICATE_DROP",
                "gopBReference": "DISABLED",
                "gopClosedCadence": 0,
                "gopSize": 90,
                "gopSizeUnits": "FRAMES",
                "interlaceMode": "PROGRESSIVE",
                "maxBitrate": 5000000,
                "minIInterval": 0,
                "numberBFramesBetweenReferenceFrames": 2,
                "numberReferenceFrames": 3,
                "parControl": "INITIALIZE_FROM_SOURCE",
                "qualityTuningLevel": "SINGLE_PASS",
                "rateControlMode": "QVBR",
                "repeatPps": "DISABLED",
                "sceneChangeDetect": "ENABLED",
                "slices": 1,
                "slowPal": "DISABLED",
                "softness": 0,
                "spatialAdaptiveQuantization": "ENABLED",
                "syntax": "DEFAULT",
                "telecine": "NONE",
                "temporalAdaptiveQuantization": "ENABLED",
                "unregisteredSeiTimecode": "DISABLED"
              }
            },
            "colorMetadata": "INSERT",
            "dropFrameTimecode": "ENABLED",
            "respondToAfd": "NONE",
            "scalingBehavior": "DEFAULT",
            "sharpness": 50,
            "timecodeInsertion": "DISABLED"
          }
        }
      ]
    }
  ],
  "timecodeConfig": {
    "source": "ZEROBASED"
  }
}