Go代码创建含多MP3音轨与SRT字幕的HLS输出MediaConvert任务时遇400错误请求问题排查求助
I’ve dealt with plenty of these vague 400 errors from MediaConvert before—especially when working with external audio tracks and captions. Let’s walk through the most likely fixes to get your job running:
Fix the external audio selector type
YourENGandSPAaudio selectors useselectorType: "TRACK", but these are standalone MP3 files (not audio tracks embedded in the video input). For external audio files, MediaConvert expectsselectorType: "EXTERNAL_FILE"instead. UsingTRACKhere is probably confusing the service’s parser.Adjust caption destination settings for HLS
You’re trying to usedestinationType: "EMBEDDED"for captions in an HLS output, but HLS doesn’t support embedded captions the same way MP4 does. For HLS, you’ll need to switch to either:- Sidecar captions: This creates separate SRT files alongside your stream segments, which is widely supported:
"destinationSettings": { "destinationType": "SIDEcar", "sidecarSettings": { "sidecarType": "SRT" } } - Embedded SCTE-20 captions: If you need captions embedded directly in the stream, use
destinationType: "EMBEDDED_SCTE20"and ensure your HLS group settings are configured to handle it.
- Sidecar captions: This creates separate SRT files alongside your stream segments, which is widely supported:
Validate your clientRequestToken
TheclientRequestTokenneeds to be a unique, case-sensitive string (up to 64 characters). If you’re using placeholder text like"---", replace it with a valid UUID or unique identifier. MediaConvert uses this token to prevent duplicate jobs, so an invalid value can trigger a parsing error.Double-check enum values for typos
MediaConvert is strict about enum casing and values. A small typo can break the whole request:- Confirm
codecvalues like"AAC"and"H_264"are correctly cased (they’re case-sensitive) - Verify
defaultSelectionvalues ("DEFAULT"/"NOT_DEFAULT") are spelled correctly - Ensure numeric fields like
bitrateandsegmentLengthare actually numbers (not strings)
- Confirm
Test with a minimal working job
Strip your request down to the basics: just the video input, one internal audio track, no captions. If that succeeds, add back external audio first, then captions, one component at a time. This helps isolate exactly which part of your configuration is causing the parsing failure—critical when thesettingsValidationErrorsJsonBlobcomes back empty.Compare with a console-generated request
Build the exact same job manually in the AWS MediaConvert Console, then export the JSON request from the console. Compare it line-by-line with your generated JSON. The console’s output is a gold standard for valid configurations, and it’ll often catch subtle missing fields or incorrect structures your code might have missed.Verify JSON formatting
Even if your JSON looks correct, double-check for trailing commas, missing quotes, or mismatched brackets. A single tiny syntax error can lead to this vague "request could not be interpreted" message. Use a JSON linter to validate the entire payload before sending it.
内容的提问来源于stack exchange,提问作者Jayyrus

