How to Process a Region of an Input File

Seek to a start time to create a trimmed cut

🚧

The Transcode API does not support this procedure. See the How to Trim a Media File guide using the Transcode API.

When dealing with large media files you may not want to process the entire file. You may only need a partial region of the file or you may want to preview small segments with different parameters to evaluate the sound of different settings. To enable these types of workflows, you can use the region parameter.

Media APIs such as the Media Enhance API and Media Analyze API can be used to process only a subsection of the entire content. To use region, add it as a parameter inside the input object and specify start and end times, which define the start and the end of the section you want to process in seconds.

❗️

Input Object

The input parameter is allowed to be either a string or an object. To specify a region for processing, you must use the object form.

See the following code example of how to use the region parameter in an enhance function:

import os
import requests
 
# Add your API token as an environmental variable or hard coded value.
api_token = os.getenv("DOLBYIO_API_TOKEN", "your_token_here")
 
body = {
  "input": {
    "url": "dlb://example/input.wav",
    "region": {   # Define region here
      "start": 0, # Start of the section to be processed in seconds
      "end": 30   # End of the section to be processed in seconds
    }
  },
  "output" : "dlb://example/output.wav"
}
url = "https://api.dolby.com/media/enhance"
headers = {
    "Authorization": "Bearer {0}".format(api_token),
    "Content-Type": "application/json",
    "Accept": "application/json"
}
 
response = requests.post(url, json=body, headers=headers)
response.raise_for_status()
json = response.json()
print(f"File uploaded successfully with the job id: {json['job_id']}")
import fetch from 'node-fetch';
 
// Add your API token as an environmental variable or hard coded value.  
const api_token = process.env.DOLBYIO_API_TOKEN || "your_token_here";

const options = {
  method: 'POST',
  headers: {
    "Authorization": `Bearer ${api_token}`,
    "Content-Type": "application/json",
    "Accept": "application/json"
  },
  body: JSON.stringify({
    input: {
      url: 'dlb://example/input.wav',
       
      region: {   // Define region here
        start: 0, // Start of the section to be processed in seconds
        end: 30   // End of the section to be processed in seconds
      }
    },
    output: 'dlb://example/output.wav'
  })
};
 
fetch('https://api.dolby.com/media/enhance', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));
# Add your API token as an environmental variable or hard coded value.
API_TOKEN=${DOLBYIO_API_TOKEN:-"your_token_here"}

curl --request POST \
     --url https://api.dolby.com/media/enhance \ 
     --header 'Accept: application/json' \
     --header 'Content-Type: application/json' \
     --header "Authorization: Bearer $API_TOKEN" \
     --data '
     {
     "input": {
          "url": "dlb://example/input.wav",
          "region": {
               "start": 0,
               "end": 30
          }
     }
     "output": "dlb://example/output.wav"
     }
     '

The above code will create an output of only the first thirty seconds of the file having been enhanced.