Why is AWS MediaConverter validation failing?

783 views Asked by At

I am trying to set up wav -> mp3 conversion through AWS, I've followed documentation closely but I can't find anything about the problem I am facing so hoping someone can help here. Here is my code to start a conversion on AWS:

$job_settings = '{
        "TimecodeConfig": {
          "Source": "ZEROBASED"
        },
        "OutputGroups": [
          {
            "Name": "File Group",
            "Outputs": [
              {
                "ContainerSettings": {
                  "Container": "RAW"
                },
                "AudioDescriptions": [
                  {
                    "AudioTypeControl": "FOLLOW_INPUT",
                    "AudioSourceName": "Audio Selector 1",
                    "CodecSettings": {
                      "Codec": "MP3",
                      "Mp3Settings": {
                        "Bitrate": 192000,
                        "Channels": 2,
                        "RateControlMode": "CBR",
                        "SampleRate": 48000
                      }
                    },
                    "LanguageCodeControl": "FOLLOW_INPUT"
                  }
                ]
              }
            ],
            "OutputGroupSettings": {
              "Type": "FILE_GROUP_SETTINGS",
              "FileGroupSettings": {
                "Destination": "{DESTINATION}"
              }
            }
          }
        ],
        "AdAvailOffset": 0,
        "Inputs": [
          {
            "AudioSelectors": {
              "Audio Selector 1": {
                "Tracks": [
                  1
                ],
                "Offset": 0,
                "DefaultSelection": "DEFAULT",
                "SelectorType": "TRACK",
                "ProgramSelection": 1
              }
            },
            "FilterEnable": "AUTO",
            "PsiControl": "USE_PSI",
            "FilterStrength": 0,
            "DeblockFilter": "DISABLED",
            "DenoiseFilter": "DISABLED",
            "InputScanType": "AUTO",
            "TimecodeSource": "ZEROBASED",
            "FileInput": "{INPUT}"
          }
        ]
      }';
   //Job starts here
   $job_settings = json_decode($job_settings, true);
   $convert_client = new MediaConvertClient(array(
        'version' => '2017-08-29',
        'region' => $this->login_details->region,
        'credentials' => $this->credentials
    ));
    
    try {
        $res = $convert_client->describeEndpoints([]);
    } catch(AwsException $e) {
        //echo $e->getMessage();
        return null;
    }
    
    //print_r($res);
    
    $single_endpoint = $res['Endpoints'][0]['Url'];
    $convert_client = new MediaConvertClient(array(
        'version' => '2017-08-29',
        'region' => $this->login_details->region,
        'credentials' => $this->credentials,
        'endpoint' => $single_endpoint
    ));
    $res = $client->createJob(array(
            "Role" => "arn:aws:iam::{$this->login_details->account_number}:role/MediaConvert_Default_Role",
            "Settings" => $job_settings,
            "Queue" => "arn:aws:mediaconvert:{$this->login_details->region}:{$this->login_details->account_number}:queues/Default"
        ));

I grabbed the JSON by creating a conversion job on AWS Console and copying the JSON of the job, the destination and input tags are replaced in the json before decoding to assoc array however I am getting an error of the following:

Error executing "CreateJob" on "aws_url"; AWS HTTP error: Client error: POST aws_url resulted in a 400 Bad Request response: { "errorType": "BadRequestException", "httpStatus" : 400, "requestId" : "-----------", (truncated...) BadRequestException (client): /outputGroups/0/outputs/0/audioDescriptions/0/codecSettings: Should match exactly one schema defined in "oneOf" | /outputGroups/0/outputs/0/audioDescriptions/0/codecSettings: Should have at least 2 properties | /outputGroups/0/outputs/0/audioDescriptions/0/codecSettings/codec: Should be equal to one of the allowed values in ["PASSTHROUGH","OPUS","VORBIS"]

This is using aws-3.93.3 PHP SDK. Any idea why this happens? Of course the job runs perfectly fine if ran through console.

1

There are 1 answers

1
peterxz On BEST ANSWER

Actually I just found what I suspected was the case; this version of the library does not yet support MP3 ingestion as outlined here:

https://github.com/aws/aws-sdk-php/blob/master/CHANGELOG.md

Updating to the newest version solved this issue.