Submitting a Composition

In the previous topic you submitted a job to a composition in an existing template. This is the easiest way to submit many different input files to the same composition.

Alternatively you can submit a job that includes both the input files and a composition. This method allows the composition to change based on the properties of the input (formats, audio channels, etc.).

For example the following command submits a job with a composition:

curl --location --request POST 'https://api.cloud.telestream.net/transform/v1.0/factories/FACTORY_ID/jobs' \
--header 'X-Api-Key: tcs_YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
  "composition": {
    "input": {
      "container": [
        {
          "name": "input1",
          "video": [
            {
              "name": "v1"
            }
          ],
          "audio": [
            {
              "name": "a1"
            }
          ]
        }
      ]
    },
    "output": {
      "container": [
        {
          "name": "output1",
          "type": "mp4 ",
          "video": [
            {
              "route": {
                "name": "v1"
              }
            }
          ],
          "audio": [
            {
              "route": {
                "name": "a1"
              }
            }
          ]
        }
      ]
    }
  },
  "inputs": {
    "input1": {
      "url": "https://mydomain.com/input.mov"
    }
  },
  "outputs": {
    "output1": {
      "path_format": "output.mp4"
    }
  }
}'

Alternatively you may submit a composition from a file in YAML format. The following example submits a composition from a local file called composition-file.yaml.

curl -X POST -H 'X-Api-Key: tcs_YOUR_API_KEY' -H "Content-Type: text/yaml" https://api.cloud.telestream.net/transform/v1.0/factories/FACTORY_ID/jobs --data-binary @composition-file.yaml

If the request is successful the response will contain the validated composition and the job ID as shown below.

{
  "account_id": "YOUR_ACCOUNT_ID",
  "created_at": "2020-11-13T16:19:40.710859104Z",
  "updated_at": "2020-11-13T16:19:40.710859104Z",
  "factory_id": "FACTORY_ID",
  "id": "JOB_ID",
  "inputs": {
    "input1": {
      "path": "",
      "store_id": "",
      "url": "https://mydomain.com/input.mov"
    }
  },
  "outputs": {
    "output1": {
      "path_format": "output.mp4",
      "files": null,
      "store_id": "ta01b8b399eef3f24e719d652f7e9104"
    }
  },
  "processing_duration": null,
  "processing_progress": 0,
  "queued_duration": null,
  "composition": {
    "input": {
      "container": [
        {
          "name": "input1",
          "video": [
            {
              "name": "v1"
            }
          ],
          "audio": [
            {
              "name": "a1"
            }
          ],
          "subtitle": null
        }
      ],
      "reference": "input"
    },
    "output": {
      "container": [
        {
          "name": "output1",
          "type": "mp4 ",
          "video": [
            {
              "route": {
                "name": "v1"
              }
            }
          ],
          "audio": [
            {
              "route": {
                "name": "a1"
              }
            }
          ]
        }
      ]
    }
  },
  "status": "queued",
  "uploading_duration": null,
  "uploading_progress": 0
}

Use the following command to monitor the progress of the job.

curl --header 'X-Api-Key: tcs_YOUR_API_KEY' 'https://api.cloud.telestream.net/transcode/v1.0/factories/FACTORY_ID/jobs/JOB_ID'