How-to Enhance your Audio while Transcoding

Before you start

This guide assumes that you understand the basics of making a Transcode API request. We recommend completing the Getting Started with Transcoding Media guide first.

Enhance your audio while transcoding

If you are already familiar with our Enhance API for advanced audio processing to improve your speech quality and reduce background noise, this guide will walk you through how to apply the Enhance process in the same API call as your Transcode request. The audio enhancement applies to the input file and all output files will include the audio enhancement.

You can clean up user-generated content from any device, and convert it to a standard output file for consistent and reliable playback on a broad range of devices. And you can take longer-form content, such as a web conference or broadcast recording, and generate HLS and DASH adaptive bitrate streaming formats for smooth playback over the web. To learn more about the details of the Enhance feature that is included in the Transcode API, see the Enhance API guide.

Mobile device content

When your users record content on iPhones, Android Devices, in-browser, or even with professional cameras, you can end up with a variety of formats. Combine the process of normalizing the input files to a standard MP4 format while cleaning up the audio with the mobile_phone content type. Or you can adjust the individual settings of Enhance to get more control over how your audio is cleaned up.

By default, the Transcode API will output a highly compatible MP4 file in standard dynamic range (SDR). If you have a specific need to compress the file to a low bitrate, extract the audio, make multiple output formats, or generate a thumbnail image for your player, you can change the settings of the transcode output file(s).

Conference content

After your conference is recorded, you can prepare it for replay in an Adaptive Bitrate streaming format such as HLS for playback over the Internet while removing background noise, adjusting speech leveling, and more. You have the option of selecting an Enhance content type on the input file, such as conference, or adjust the individual settings to get more control over how audio enhancement is applied to your content.

Audio content types

The audio enhance feature includes content types, similar to presets, designed for specific scenarios. To learn more, see the How-to Improve Audio Quality by Content Type guide.

Code examples

Mobile device

This code example shows you how to optimize mobile device recorded audio while creating a standard compatible MP4 file. If your users are uploading .MOV files from iPhones, WebM files from browser recordings or Android devices, or other formats, this example will clean up the audio and normalize the output format. The audio enhance content type is set to mobile_phone.

import os

# The requests library must be installed before running this example.
import requests

# Add your API token as an environmental variable or hard coded value.
api_token = os.getenv("DOLBYIO_API_TOKEN", "your_token_here")

# Call the Transcode API endpoint.
url = "https://api.dolby.com/media/transcode"

headers = {
    "Authorization": "Bearer {0}".format(api_token),
    "Content-Type": "application/json",
    "Accept": "application/json"
}

# Before you run this example, update the paths and filenames to point to your media.
body = {
    "inputs": [
        {
            "source": "https://dolbyio-public.s3.amazonaws.com/transcode_enhance/input/airplane.original.mov",
            "processing": [{
                "kind": "enhance",
                "content": {
                    "type": "mobile_phone"
                }
            }]
        }
    ],
    "outputs": [
        {
            "kind": "mp4",
            "destination": "dlb://my-enhanced-output.mov"
        }
    ]
}

try:
    # Submit the request to the API.
    response = requests.post(url, json=body, headers=headers)

    # Raise an error if an HTTPError occurred.
    response.raise_for_status()

# Exception handling.
except requests.exceptions.HTTPError as e:
    raise Exception(response.text)

# Request was successful.
print(response.json()["job_id"])
// The Axios library must be installed before running this example.
const axios = require("axios");

// Add your API token as an environmental variable or hard coded value.
const api_token = process.env.DOLBYIO_API_TOKEN || "your_token_here";

// Before you run this example, update the paths and filenames to point to your media.
const config = {
  method: "post",
  url: "https://api.dolby.com/media/transcode",
  headers: {
    Authorization: `Bearer ${api_token}`,
    "Content-Type": "application/json",
    Accept: "application/json"
  },
  data: {
    inputs: [
      {
        source: "https://dolbyio-public.s3.amazonaws.com/transcode_enhance/input/airplane.original.mov",
        processing: [
          {
            kind: "enhance",
            content: {
              type: "mobile_phone"
            }
          }
        ]
      }
    ],
    outputs: [
      {
        kind: "mp4",
        destination: "dlb://my-enhanced-output.mov" 
      }
    ]
  }
};

// Submit the request.
axios(config)
  .then(function (response) {
    // Log the successful "job_id" returned from the API.
    console.log(response.data.job_id);
  })
  .catch(function (error) {
    // If there was an error, log the error.
    console.log(error);
  });
#!/bin/bash

# Add your API token as an environmental variable or hard coded value.
API_TOKEN=${DOLBYIO_API_TOKEN:-"your_token_here"}

# Before you run this example, update the paths and filenames to point to your media.
curl -X POST "https://api.dolby.com/media/transcode" \
    --header "Authorization: Bearer $API_TOKEN" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data '{
        "inputs": [
            {
                "source": "https://dolbyio-public.s3.amazonaws.com/transcode_enhance/input/airplane.original.mov",
                "processing": [{
                    "kind": "enhance",
                    "content": {
                        "type": "mobile_phone"
                    }
                }]
            }
        ],
        "outputs": [
            {
                "kind": "mp4",
                "destination": "dlb://my-enhanced-output.mov" 
            }
        ]
    }'

Conference

This code example shows you how to optimize a conference recording for streaming. The audio enhance content type is set to conference.

import os

# The requests library must be installed before running this example.
import requests

# Add your API token as an environmental variable or hard coded value.
api_token = os.getenv("DOLBYIO_API_TOKEN", "your_token_here")

# Call the Transcode API endpoint.
url = "https://api.dolby.com/media/transcode"

headers = {
    "Authorization": "Bearer {0}".format(api_token),
    "Content-Type": "application/json",
    "Accept": "application/json"
}

# Before you run this example, update the paths and filenames to point to your media.
body = {
    "inputs": [
        {
            "source": "https://dolbyio.s3-us-west-1.amazonaws.com/public/shelby/indoors.original.mp4",
            "processing": [
                {
                    "kind": "enhance",
                    "content": {
                        "type": "conference"
                    }
                }
            ]
        }
    ],
    "outputs": [
        {
            "kind": "mp4",
            "destination": {
                "ref": "my-output-bucket",
                "filename": "video-1080.mp4"
            },
            "audio": "remove",
            "video": {
                "height": 1080,
                "bitrate_mode": "vbr",
                "bitrate_kb": 6000
            }
        },
        {
            "kind": "mp4",
            "destination": {
                "ref": "my-output-bucket",
                "filename": "video-720.mp4"
            },
            "audio": "remove",
            "video": {
                "height": 720,
                "bitrate_mode": "vbr",
                "bitrate_kb": 3000
            }
        },
        {
            "kind": "mp4",
            "destination": {
                "ref": "my-output-bucket",
                "filename": "video-480.mp4"
            },
            "audio": "remove",
            "video": {
                "height": 480,
                "bitrate_mode": "vbr",
                "bitrate_kb": 1000
            }
        },
        {
            "kind": "mp4",
            "destination": {
                "ref": "my-output-bucket",
                "filename": "audio-128k.mp4"
            },
            "audio": [
                {
                    "bitrate_kb": 128
                }
            ],
            "video": "remove"
        },
        {
            "kind": "hls",
            "destination": {
                "ref": "my-output-bucket",
                "filename": "master_manifest.m3u8"
            }
        }
    ],
    "storage": [
        {
            "id": "my-output-bucket",
            "bucket": {
                "url": "s3://my-output-bucket/output",
                "auth": {
                    "key": "AKIASZXXXXXXXXYLWWUHQ",
                    "secret": "kjYK54XXXXXXXXXZtKFySioE+3"
                }
            }
        }
    ]
}

try:
    # Submit the request to the API.
    response = requests.post(url, json=body, headers=headers)

    # Raise an error if an HTTPError occurred.
    response.raise_for_status()

# Exception handling.
except requests.exceptions.HTTPError as e:
    raise Exception(response.text)

# Request was successful.
print(response.json()["job_id"])
// The Axios library must be installed before running this example.
const axios = require("axios");

// Add your API token as an environmental variable or hard coded value.
const api_token = process.env.DOLBYIO_API_TOKEN || "your_token_here";

// Before you run this example, update the paths and filenames to point to your media.
const config = {
  method: "post",
  url: "https://api.dolby.com/media/transcode",
  headers: {
    Authorization: `Bearer ${api_token}`,
    "Content-Type": "application/json",
    Accept: "application/json"
  },
  data: {
    inputs: [
      {
        source: "https://dolbyio.s3-us-west-1.amazonaws.com/public/shelby/indoors.original.mp4",
        processing: [
          {
            kind: "enhance",
            content: {
              type: "conference"
            }
          }
        ]
      }
    ],
    "outputs": [
        {
            "kind": "mp4",
            "destination": {
                "ref": "my-output-bucket",
                "filename": "video-1080.mp4"
            },
            "audio": "remove",
            "video": {
                "height": 1080,
                "bitrate_mode": "vbr",
                "bitrate_kb": 6000
            }
        },
        {
            "kind": "mp4",
            "destination": {
                "ref": "my-output-bucket",
                "filename": "video-720.mp4"
            },
            "audio": "remove",
            "video": {
                "height": 720,
                "bitrate_mode": "vbr",
                "bitrate_kb": 3000
            }
        },
        {
            "kind": "mp4",
            "destination": {
                "ref": "my-output-bucket",
                "filename": "video-480.mp4"
            },
            "audio": "remove",
            "video": {
                "height": 480,
                "bitrate_mode": "vbr",
                "bitrate_kb": 1000
            }
        },
        {
            "kind": "mp4",
            "destination": {
                "ref": "my-output-bucket",
                "filename": "audio-128k.mp4"
            },
            "audio": [
                {
                    "bitrate_kb": 128
                }
            ],
            "video": "remove"
        },
        {
            "kind": "hls",
            "destination": {
                "ref": "my-output-bucket",
                "filename": "master_manifest.m3u8"
            }
        }
    ],
    storage: [
      {
        id: "my-output-bucket",
        bucket: {
          url: "s3://my-output-bucket/output",
          auth: {
            key: "AKIASZXXXXXXXXYLWWUHQ",
            secret: "kjYK54XXXXXXXXXZtKFySioE+3"
          }
        }
      }
    ]
  }
}

// Submit the request.
axios(config)
  .then(function (response) {
    // Log the successful "job_id" returned from the API.
    console.log(response.data.job_id);
  })
  .catch(function (error) {
    // If there was an error, log the error.
    console.log(error);
  });
#!/bin/bash

# Add your API token as an environmental variable or hard coded value.
API_TOKEN=${DOLBYIO_API_TOKEN:-"your_token_here"}

# Before you run this example, update the paths and filenames to point to your media.
curl -X POST "https://api.dolby.com/media/transcode" \
    --header "Authorization: Bearer $API_TOKEN" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data '{
    "inputs": [
        {
            "source": "https://dolbyio.s3-us-west-1.amazonaws.com/public/shelby/indoors.original.mp4",
            "processing": [
                {
                    "kind": "enhance",
                    "content": {
                        "type": "conference"
                    }
                }
            ]
        }
    ],
    "outputs": [
        {
            "kind": "mp4",
            "destination": {
                "ref": "my-output-bucket",
                "filename": "video-1080.mp4"
            },
            "audio": "remove",
            "video": {
                "height": 1080,
                "bitrate_mode": "vbr",
                "bitrate_kb": 6000
            }
        },
        {
            "kind": "mp4",
            "destination": {
                "ref": "my-output-bucket",
                "filename": "video-720.mp4"
            },
            "audio": "remove",
            "video": {
                "height": 720,
                "bitrate_mode": "vbr",
                "bitrate_kb": 3000
            }
        },
        {
            "kind": "mp4",
            "destination": {
                "ref": "my-output-bucket",
                "filename": "video-480.mp4"
            },
            "audio": "remove",
            "video": {
                "height": 480,
                "bitrate_mode": "vbr",
                "bitrate_kb": 1000
            }
        },
        {
            "kind": "mp4",
            "destination": {
                "ref": "my-output-bucket",
                "filename": "audio-128k.mp4"
            },
            "audio": [
                {
                    "bitrate_kb": 128
                }
            ],
            "video": "remove"
        },
        {
            "kind": "hls",
            "destination": {
                "ref": "my-output-bucket",
                "filename": "master_manifest.m3u8"
            }
        }
    ],
    "storage": [
        {
            "id": "my-output-bucket",
            "bucket": {
                "url": "s3://my-output-bucket/output",
                "auth": {
                    "key": "AKIASZXXXXXXXXYLWWUHQ",
                    "secret": "kjYK54XXXXXXXXXZtKFySioE+3"
                }
            }
        }
    ]
}'

Learn more