-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d52e8ae
Showing
28 changed files
with
1,504 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
my-env.sh | ||
|
||
# Node | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
|
||
# Python | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
cover/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Copyright 2020 Dolby Laboratories | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
# Dolby.io Media Processing API Samples | ||
|
||
This repository contains a collection of samples for how to make | ||
API calls or create simple media workflows. | ||
|
||
Check the language specific README files for additional instructions. | ||
|
||
* [python/README.md](python/README.md) | ||
* [javascript/README.md](javascript/README.md) | ||
* [cURL/README.md](curl/README.md) | ||
|
||
## API Key | ||
|
||
If you don't have a developer account please visit the website and sign up to | ||
get an API Key. | ||
|
||
https://dolby.io | ||
|
||
## Environment Variables | ||
|
||
Most of these samples expect you to define environment variables so | ||
that you don't have to put your API Key into source code. To make this | ||
easier we've included an example `bash` script to initialize these | ||
variables. This is optional and just provided as a convenience. You can | ||
edit the samples to meet your needs. | ||
|
||
Recommended Workflow | ||
|
||
1. Copy "env.sh" to "my-env.sh" | ||
2. Replace variable with your API Key | ||
3. Execute ". my-env.sh" to initialize these variables into your environment | ||
|
||
If you are not using a `bash` shell you'll need to change this to be correct | ||
for your working environment. | ||
|
||
# Terms and Contributing | ||
|
||
See the [LICENSE](LICENSE) for details on terms of use as well as broader | ||
terms from Dolby.io. If you find any issues please create an issue in the | ||
GitHub repository. If you fork or want to contribute please contact us | ||
at [email protected] so that we can get a contributor agreement in place. Please | ||
reference this repository. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
# cURL | ||
|
||
cURL is a command line utility for making HTTP calls. | ||
|
||
Useful resources: | ||
|
||
- https://curl.haxx.se/docs/ | ||
|
||
The samples are for BASH when used with Mac OSX, Linux, or Windows PowerShell. You'll need to make some adjustments to quoting rules when using Windows Command Prompt. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
curl -X GET "https://api.dolby.com/media/analyze?job_id=$DOLBYIO_JOB_ID" \ | ||
--header "x-api-key: $DOLBYIO_API_KEY" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
curl -X POST "https://api.dolby.com/media/analyze" \ | ||
--header "x-api-key: $DOLBYIO_API_KEY" \ | ||
--data '{ | ||
"input": "dlb://in/example.mp3" | ||
}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
curl -X GET "https://api.dolby.com/media/enhance?job_id=$DOLBYIO_JOB_ID" \ | ||
--header "x-api-key: $DOLBYIO_API_KEY" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
curl -X POST "https://api.dolby.com/media/analyze" \ | ||
--header "x-api-key: $DOLBYIO_API_KEY" \ | ||
--data '{ | ||
"input": "dlb://in/example.mp3", | ||
"output": "dlb://out/example-enhanced.mp3" | ||
}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
# Environment variables are a convenient way to keep your | ||
# API key secret and out of your code. | ||
|
||
# Instructions: | ||
# 1. Copy this file to "my-env.sh" | ||
# 2. Execute ". my-env.sh" to initialize these into your environment | ||
# 3. Use other samples that will reference these variables | ||
|
||
export DOLBYIO_API_KEY='Dolby-io-api-key-goes-here' | ||
|
||
export INPUT_MEDIA_LOCAL_PATH=plane.mp3 | ||
export OUTPUT_MEDIA_LOCAL_PATH=plane_enhanced.mp3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
# JavaScript | ||
|
||
To run the Python samples you need to install a Node.js environment and install | ||
the libraries referenced in package.json | ||
|
||
You may find these resources helpful: | ||
|
||
* https://docs.npmjs.com/downloading-and-installing-node-js-and-npm | ||
|
||
Run `npm install` to get dependencies installed into your local environment | ||
to use these scripts. | ||
|
||
|
||
## API Calls | ||
|
||
This is a collection of short snippets that demonstrate get and post calls | ||
to each Media Processing API. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env node | ||
|
||
const axios = require('axios').default; | ||
|
||
const config = { | ||
method: 'get', | ||
url: 'https://api.dolby.com/media/analyze', | ||
headers: { | ||
'x-api-key': process.env.DOLBYIO_API_KEY, | ||
'Content-Type': 'application/json', | ||
'Accept': 'application/json' | ||
}, | ||
params: { | ||
job_id: process.env.DOLBYIO_JOB_ID | ||
} | ||
}; | ||
|
||
axios(config) | ||
.then(function (response) { | ||
console.log(JSON.stringify(response.data, null, 4)); | ||
}) | ||
.catch(function (error) { | ||
console.log(error); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env node | ||
|
||
const axios = require('axios').default; | ||
|
||
const config = { | ||
method: 'post', | ||
url: 'https://api.dolby.com/media/analyze', | ||
headers: { | ||
'x-api-key': process.env.DOLBYIO_API_KEY, | ||
'Content-Type': 'application/json', | ||
'Accept': 'application/json' | ||
}, | ||
data: { | ||
input: 'dlb://in/example.mp3' | ||
} | ||
}; | ||
|
||
axios(config) | ||
.then(function (response) { | ||
console.log(response.data.job_id); | ||
}) | ||
.catch(function (error) { | ||
console.log(error); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env node | ||
|
||
const axios = require('axios').default; | ||
|
||
const config = { | ||
method: 'get', | ||
url: 'https://api.dolby.com/media/enhance', | ||
headers: { | ||
'x-api-key': process.env.DOLBYIO_API_KEY, | ||
'Content-Type': 'application/json', | ||
'Accept': 'application/json' | ||
}, | ||
params: { | ||
job_id: process.env.DOLBYIO_JOB_ID | ||
} | ||
}; | ||
|
||
axios(config) | ||
.then(function (response) { | ||
console.log(JSON.stringify(response.data, null, 4)); | ||
}) | ||
.catch(function (error) { | ||
console.log(error); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env node | ||
|
||
const axios = require('axios').default; | ||
|
||
const config = { | ||
method: 'post', | ||
url: 'https://api.dolby.com/media/enhance', | ||
headers: { | ||
'x-api-key': process.env.DOLBYIO_API_KEY, | ||
'Content-Type': 'application/json', | ||
'Accept': 'application/json' | ||
}, | ||
data: { | ||
input: 'dlb://in/example.mp3', | ||
output: 'dlb://out/example-enhanced.mp3' | ||
} | ||
}; | ||
|
||
axios(config) | ||
.then(function (response) { | ||
console.log(response.data.job_id); | ||
}) | ||
.catch(function (error) { | ||
console.log(error); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env node | ||
|
||
const fs = require('fs'); | ||
const axios = require('axios').default; | ||
|
||
const file_path = process.env.INPUT_MEDIA_LOCAL_PATH; | ||
|
||
const config = { | ||
method: 'post', | ||
url: 'https://api.dolby.com/media/input', | ||
headers: { | ||
'x-api-key': process.env.DOLBYIO_API_KEY, | ||
'Content-Type': 'application/json', | ||
'Accept': 'application/json' | ||
}, | ||
data: { | ||
url: 'dlb://in/example.mp3' | ||
} | ||
}; | ||
|
||
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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env node | ||
|
||
const fs = require('fs'); | ||
const axios = require('axios').default; | ||
|
||
const output_path = process.env.OUTPUT_MEDIA_LOCAL_PATH; | ||
|
||
const config = { | ||
method: 'get', | ||
url: 'https://api.dolby.com/media/output', | ||
headers: { | ||
'x-api-key': process.env.DOLBYIO_API_KEY, | ||
'Content-Type': 'application/json', | ||
'Accept': 'application/json' | ||
}, | ||
responseType: 'stream', | ||
params: { | ||
url: 'dlb://out/example-enhanced.mp3' | ||
} | ||
}; | ||
|
||
axios(config) | ||
.then(function (response) { | ||
response.data.pipe(fs.createWriteStream(output_path)); | ||
response.data.on('error', function (error) { | ||
console.log(error); | ||
}); | ||
response.data.on('end', function () { | ||
console.log('File downloaded!'); | ||
}); | ||
}) | ||
.catch(function (error) { | ||
console.log(error); | ||
}); |
Oops, something went wrong.