Skip to content

a standalone API that processes and normalizes an MP3 for Alexa consumption, featuring cached responses, configurable options (e.g. bitrate, loudness normalization), along with sensible default settings.

Notifications You must be signed in to change notification settings

nramabad/aud.io

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aud.io

Run FFmpeg jobs on demand with aud.io! This project implements a plain Node.JS HTTP server hosted on Heroku Dynos. It accepts audio media in the form of download links or file streamed POSTed as a part of multipart form data (making it a convenient plugin API for frontend and backends alike). Response can be accepted as a JSON with a download URL or a file stream. Download URLs are provided courtesy a presigned AWS S3 file URL with default expiration. All requests are GZIP compressed and cached in S3, and all download URLs responses are GZIP compressed. The minimal NPM dependencies allows this project to be fast and relatively portable.

Design Logic Diagram

Design Logic Diagram

Input a download URL and stream out to an output file

curl https://aud-i0.herokuapp.com/?url=https%3A%2F%2Fwww.bensound.com%2Fbensound-music%2Fbensound-ukulele.mp3 >> normalized_audio.mp3

Input a download URL and receive a JSON w/ a presigned URL to download from S3

curl -X GET 'https://aud-i0.herokuapp.com/?url=https%3A%2F%2Fwww.bensound.com%2Fbensound-music%2Fbensound-slowmotion.mp3&presignRes=true'

Stream an input file and stream out to an output file

curl -X POST -H "Content-Type: multipart/form-data" -F "file=@./audio.mp3" -F "type=audio/mpeg" https://aud-i0.herokuapp.com >> normalized_audio.mp3

Stream an input file and receive a JSON w/ a presigned URL to download from S3

curl -X POST -H "Content-Type: multipart/form-data" -F "file=@./audio.mp3" -F "type=audio/mpeg" -F "presignRes=true" https://aud-i0.herokuapp.com

Input a download URL and stream out to an output file

curl -X POST -H "Content-Type: multipart/form-data" -F "url=https://www.bensound.com/bensound-music/bensound-hey.mp3" https://aud-i0.herokuapp.com >> normalized_audio.mp3

Input a download URL and receive a JSON w/ a presigned URL to download from S3

curl -X POST -H "Content-Type: multipart/form-data" -F "url=https://www.bensound.com/bensound-music/bensound-hey.mp3" -F "presignRes=true" https://aud-i0.herokuapp.com

Options / Arguments

All arguments accepted via query, params or body data. The following FFmpeg options are supported explicitly with equivalent plain-text key names:

input/inputUrl/url - Input download URL for audio file (REQUIRED if no file streamed as form POST data)
I/integratedLoudness - Integrated Loudness (default: -14)
TP/truePeak - Inter-sample peak (default: -3)
LRA/loudnessRange - Loudness Range from softest to loudest (default: 11)
af - audio filter (optional / default: loudnorm=I=${i}:TP=${tp}:LRA=${lra}:print_format=json)
bitRate - Audio Bit Rate (bits per unit time) (optional)
presignRes/presignResponse - returns pre-signed S3 download URL if equal to true (default: false - streams file to response)

Defaults based on normalization required for Amazon Alexa:
https://developer.amazon.com/en-US/docs/alexa/flashbriefing/normalizing-the-loudness-of-audio-content.html#additional-tools
Other FFmpeg options are implicitly supported by their key name as documented here:
https://ffmpeg.org/ffmpeg.html#toc-Options

Technologies

Node.JS (HTTP/HTTPS, crypto, stream, zlib), Heroku, AWS S3, FFmpeg

Dependencies

aws-sdk, busboy, @discordjs/opus, ffmpeg-static, loglevel, prism-media

About

a standalone API that processes and normalizes an MP3 for Alexa consumption, featuring cached responses, configurable options (e.g. bitrate, loudness normalization), along with sensible default settings.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published