A web service for converting audio files with ffmpeg
Node.js, Express, FFMPEG, Docker
Deployed dev branch on a $5 Digital Ocean droplet (1 GB Memory / 25 GB Disk / SFO2 - Ubuntu Docker 18.06.1ce3 on 18.04)
POST /mp3
- Convert audio file in request body to mp3 and return result for download
POST /m4a
- Convert audio file in request body to mp3 and return result for download
GET /
, GET /readme
- Web Service Readme
POST to /mp3 or /m4a using Postman or a Curl command:
Include audio file as binary in request body
Postman Ex:
https://www.dropbox.com/s/5exywmaj5o7cdn3/postMp3%20Postman%20Usage.png?dl=0
Curl Ex:
curl --request POST --data-binary "@file.wav" 127.0.0.1:3000/mp3 -o file.mp3
see test/curl_test.bash for an example use via bash script
Requires local Node and FFMPEG installation.
-
Install FFMPEG https://ffmpeg.org/download.html
-
Install node https://nodejs.org/en/download/ Using homebrew:
$ brew install node
Navigate to project directory and:
Install dependencies:
$ npm install
Start app:
$ node app.js
Run unit tests with Mocha:
$ npm run test
or
$ ./node_modules/.bin/mocha
Requires Docker
Install Docker
https://www.docker.com
Build Docker Image from Dockerfile with a set image tag. ex: bm/ffmpeg
$ docker build -t <image>/<tag> .
Launch Docker Container from Docker Image, exposing port 49160
$ docker run -p 49160:3000 -d '<image>'/'<tag>'
docker-compose up -d --build
docker ps # note <CONTAINER ID>
# enter bash prompt for docker container
docker exec -it <CONTAINER ID> /bin/bash
vi README.md # edit file in vi, ex. README.md
$ - local machine
# - ssh-ed machine
I am using a 4GB RAM, 2 vCPU Droplet for test deployments I use the Digital Ocean Docker App Preset Droplet
Create your Droplet
SSH into your Droplet
$ ssh root@<droplet-ip>
Clone this repo
# git clone https://github.com/benmangold/ffmpeg-service.git
# cd ffmpeg-service
Build Docker Image from Dockerfile with a set image tag. ex: bm/ffmpeg
# docker build -t <image>/<tag> .
Launch Docker Container from Docker Image, exposing port 49160
# docker run -p 3000:3000 -d '<image>'/'<tag>'