Dolby.io Media Temporary Cloud Storage

Temporary and quick process to upload media while evaluating the Dolby.io Media APIs

📘

Dolby Media Input and Output Temporary Storage

The Media Input and Media Output APIs were created to help you build a prototype or proof of concept. Any data stored with Dolby.io is temporary and will be removed. For production use cases you should choose your preferred storage provider.

A few key points:

  • Temporary: The media you store with these APIs is temporary and will
    automatically be removed within 24 - 48 hours.

  • Secure: The media is stored in an isolated location that only you can access with your API token. It is encrypted at rest and while in transit with HTTPS. Access to the production system is controlled and audited to prevent unauthorized use.

Create and use a Dolby.io temporary storage location

The following steps illustrate the workflow.

  1. Create a Dolby.io temporary storage location with a pre-signed URL and upload your media.
    POST /media/input and PUT {PRE-SIGNED URL}
  2. Use your temporary storage with Media APIs.
  3. Create a pre-signed URL and download your media.
    POST /media/output and GET {PRE-SIGNED URL}

1. Create a Dolby.io temporary storage location with a pre-signed URL and upload your media

Create a pre-signed URL and temporary storage location with a POST /media/input request, and then upload your media with a PUT request to the pre-signed URL. You will use the Dolby.io temporary storage location in Media API requests.

Example temporary storage locations that you can create using standard alpha-numeric characters (must start with dlb://):

  • dlb://input.wav
  • dlb://output.wav
  • dlb://usr/home/media/in/foo.mp3
  • dlb://usr/home/media/out/foo.enhanced.mp3

❗️

File Naming Rules

Your file name should be between 3 and 63 characters in length. The name should only use letters (a-z), numbers (0-9), dots, and hyphens. Other special characters such as spaces, tabs, etc. are not recommended. Spaces are not allowed in file names as they can cause errors when loading files.

Code example

This example shows you how to create a temporary storage location with a pre-signed URL and upload your media.

import os
import requests
 
input_path = os.environ["INPUT_MEDIA_LOCAL_PATH"]
 
# Add your API token as an environmental variable or hard coded value.
api_token = os.getenv("DOLBYIO_API_TOKEN", "your_token_here")
 
url = "https://api.dolby.com/media/input"
headers = {
    "Authorization": "Bearer {0}".format(api_token),
    "Content-Type": "application/json",
    "Accept": "application/json"
}
 # Replace the url value with your Dolby.io temporary storage location that you want to create. 
body = {
    "url": "dlb://example/input.wav",
}
 
 # Create a pre-signed URL.
response = requests.post(url, json=body, headers=headers)
response.raise_for_status()
data = response.json()
presigned_url = data["url"]
print("Uploading {0} to {1}".format(input_path, presigned_url))
with open(input_path, "rb") as input_file:

# Upload your media.
    requests.put(presigned_url, data=input_file)
const fs = require('fs');
const axios = require('axios').default;
 
const file_path = process.env.INPUT_MEDIA_LOCAL_PATH;
 
// Add your API token as an environmental variable or hard coded value.  
const api_token = process.env.DOLBYIO_API_TOKEN || "your_token_here";  
 
// Create a pre-signed URL. 
const config = {
    method: 'post',
    url: 'https://api.dolby.com/media/input',
    headers: {
        "Authorization": `Bearer ${api_token}`,
        "Content-Type": "application/json",
        "Accept": "application/json"
    },
    // Replace the url value with your Dolby.io temporary storage location that you want to create.
    data: {
        url: 'dlb://example/input.wav'
    }
};
 
 // Upload your media.
axios(config)
    .then(function (response) {
        const upload_config = {
            method: 'put',
            url: response.data.url,
            data: fs.createReadStream(file_path),
            headers: {
                'Content-Type': 'application/octet-stream',
                'Content-Length': fs.statSync(file_path).size
            }
        };
        axios(upload_config)
            .then(function () {
                console.log("File uploaded")
            })
            .catch(function (error) {
                console.log(error);
            });
    })
    .catch(function (error) {
        console.log(error);
    });
# Add your API token as an environmental variable or hard coded value.
API_TOKEN=${DOLBYIO_API_TOKEN:-"your_token_here"}

# Create a pre-signed URL. 
curl  -X POST https://api.dolby.com/media/input \
      --header "Authorization: Bearer $API_TOKEN" \
     
     # Replace the url value with your Dolby.io temporary storage location that you want to create.
      --data '{
          "url": "dlb://example/input.wav"
          }'
&&
# Upload your media. 
curl  -X PUT $PRE_SIGNED_URL -T ./input.wav     

2. Use your temporary storage with Media APIs

The Dolby Media APIs can accept the Dolby.io temporary storage URL in the input or output requests.

Code example

This code example shows you how to retrieve your media from Dolby.io temporary storage and process it with the the Media Enhance API.

Use the Dolby.io temporary input URL that you created during step 1. The Dolby.io temporary output URL dlb://example/output.wav does not yet exist. Add the output URL in your request body, and it is created as a result of calling the Media Enhance API.

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")
 
# Replace the input value with your Dolby.io temporary storage location.
# Replace the output value with your Dolby.io temporary storage location and a different file name.
body = {
  "input" : "dlb://example/input.wav",
  "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()
print(response.json())
const axios = require("axios").default
 
// Add your API token as an environmental variable or hard coded value.  
const api_token = process.env.DOLBYIO_API_TOKEN || "your_token_here";  
 
const config = {
  method: "post",
  url: "https://api.dolby.com/media/enhance",
  headers: {
    "Authorization": `Bearer ${api_token}`,
    "Content-Type": "application/json",
    "Accept": "application/json"
  },

  // Replace the input value with your Dolby.io temporary storage location.
  // Replace the output value with your Dolby.io temporary storage location and a different file name.
  data: {
    input: "dlb://example/input.wav",
    output: "dlb://example/output.wav",
  },
}
 
axios(config)
  .then(function(response) {
    console.log(response.data.job_id)
  })
  .catch(function(error) {
    console.log(error)
  })
# Add your API token as an environmental variable or hard coded value.
API_TOKEN=${DOLBYIO_API_TOKEN:-"your_token_here"}

curl -X POST https://api.dolby.com/media/enhance \
     --header "Authorization: Bearer $API_TOKEN" \

     # Replace the input value with your Dolby.io temporary storage location.
     # Replace the output value with your Dolby.io temporary storage location and a different file name.
     --data '{
         "input": "dlb://example/input.wav",
         "output": "dlb://example/output.wav"
     }'

3. Create a pre-signed URL and download your media

Create a pre-signed URL with a POST /media/output request, and then download your media with a GET request to the pre-signed url.

Code example

This code example shows you how to create a pre-signed URL and download your media.

import os
import shutil
import requests

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

url = "https://api.dolby.io/v1/media/output"
headers = {
    "Authorization": "Bearer {0}".format(api_token),
    "Content-Type": "application/json",
    "Accept": "application/json"
}
# Replace the url value with your Dolby.io temporary storage output location. 
body = {
   "url": "dlb://out/example-enhanced.mp3",
}

# Create a pre-signed URL.
response = requests.post(url, json=body, headers=headers)
response.raise_for_status()
data = response.json()
presigned_url = data["url"]
# Download your media. 
with requests.get(presigned_url, stream=True) as response:
  response.raise_for_status()
  response.raw.decode_content = True
  print("Downloading from {0} into {1}".format(presigned_url, output_path))
  with open(output_path, "wb") as output_file:
    shutil.copyfileobj(response.raw, output_file)

const fs = require('fs');
const axios = require('axios').default;

const output_path = process.env.OUTPUT_MEDIA_LOCAL_PATH;

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

// Create a pre-signed URL.
const config = {
  method: 'post',
  url: 'https://api.dolby.io/v1/media/output',
  headers: {
    "Authorization": `Bearer ${api_token}`,
    "Content-Type": "application/json",
    "Accept": "application/json"
  },
  data: {
    url: 'dlb://out/example-enhanced.mp3'
  }
};

// Download your media file.
axios(config)
  .then(function (response) {
    const download_config = {
      method: 'get',
      url: response.data.url,
      responseType: 'stream',
    };
    axios(download_config)
      .then(function (response_data) {
        response_data.data.pipe(fs.createWriteStream(output_path));
      })
      .catch(function (error) {
        console.log(error);
       });
    })
    .catch(function (error) {
      console.log(error);
  });
# Add your API token as an environmental variable or hard coded value.
API_TOKEN=${DOLBYIO_API_TOKEN:-"your_token_here"}

# Create a pre-signed URL. 
curl -X POST "https://api.dolby.io/v1/media/output" \
     --header "Authorization: Bearer $API_TOKEN" \
     --data '{
         "url": "dlb://out/example-enhanced.mp3"
         }'
         
# Download your media.                   
curl "<pre-signed-url-returned-by-post-media-output>" \
      --output $OUTPUT_MEDIA_LOCAL_PATH

Troubleshooting

See Common Errors for help with debugging media input and output concerns.

API Reference

See the API Reference for more information on these services.