Node.js Express FFMPEG Mp3 Pitch and Tempo Changer Web App Deployed to Heroku Full Project 2020

You are currently viewing Node.js Express FFMPEG Mp3 Pitch and Tempo Changer Web App Deployed to Heroku Full Project 2020

 

 

 

Live Demo

 

You can see the live demo of the app right here

 

Get Started

 

In order to get started you need to install these dependencies which are listed below

 

npm init -y

 

npm i express

 

npm i multer

 

npm i nodemon

 

 

Now make the entry level file index.js and start a simple express server on port 3000 like this

 

 

 

 

Now we will load the index.html for our user so that it can interact with the application. Copy paste the code inside the index.html file

 

 

index.html

 

 

 

 

 

Creating Uploads Folder Dynamically

 

 

Now we will create the folders dynamically where we will store the mp3 files which will be processed by ffmpeg and then it will be converted to a pitched file

 

 

 

 

 

Here for the very first time the node.js application loads it will check the condition if the folder public doesn’t exist then it will create this folder and also it will create the uploads folder inside the public folder as a subdirectory.

 

 

 

Setting Public Folder as Static

 

 

Now in this block of code we will set the public folder as static so that it can store the mp3 files

 

 

 

 

 

Loading the BodyParser Middleware

 

 

BodyParser middleware is very much necessary for this application as we will processing the form data which is submitted by the user inside the index.html file. So for that you need to copy paste the below code inside index.js

 

 

 

 

 

Uploading Mp3 Files to Server Using Multer

 

 

Now the comes the most important part of the application we need to first of all upload the mp3 to the uploads folder before we can process them. So for this we will be using a famous library of node called multer to do this task. Copy paste this block of code to upload files inside node.

 

 

 

 

 

 

Changing Pitch and Tempo of Mp3

 

 

Now we will do the fun part of the application after we upload the mp3 files on the server. We will issue a simple shell command inside our node.js application using a built in library of node called as child_process. So in this block of code we will use a special ffmpeg command which will carry out this process for us automatically. All this code will be put inside the post request which the user makes inside the index.html form.

 

 

 

 

 

DOWNLOAD SOURCE CODE

 

Leave a Reply