PC & IT SUPPORT MADE EASY FORUM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Node.js FFMPEG Project to Add 3D & 8D Effect to Audio MP3 File Using apulsator Filter in Express

Go down

Node.js FFMPEG Project to Add 3D & 8D Effect to Audio MP3 File Using apulsator Filter in Express Empty Node.js FFMPEG Project to Add 3D & 8D Effect to Audio MP3 File Using apulsator Filter in Express

Post by jamied_uk 22nd June 2022, 11:43




ffmpeg -i input.mp3 -af apulsator=hz=0.125 out.mp3
Code:
npm init -y
 
 
Code:
npm i express multer
 
 
Code:
index.js
 
 






const express = require('express')
const app = express()
const multer = require('multer')
var path = require('path')
const bodyparser = require('body-parser')
const {exec} = require('child_process')
const port = 5000
app.use(bodyparser.urlencoded({extended:false}))
app.use(bodyparser.json())
 
app.get('/', (req, res) => {
    res.sendFile(__dirname + "/index.html")
})
 
var storage = multer.diskStorage({
    destination: function (req, file, cb) {
        cb(null, 'uploads')
    },
    filename: function (req, file, cb) {
        cb(null, Date.now() + path.extname(file.originalname)) //Appending extension
    }
})
let outputfile
 
var upload = multer({ storage: storage }).single('file');
 
app.post('/applyaudiofilter', (req, res) => {
  upload(req,res,(err) => {
    if(err){
        console.log("error takes place in uploading file")
    }else{
        outputfile = Date.now() + "output.mp3"
        console.log(req.file.path)
 
        exec(`ffmpeg -i ${req.file.path} -af apulsator=hz=0.125 ${outputfile}`,(err,stdout,stderr) => {
            if(err){
                console.log(err)
                console.log("error in processing file")
            }else{
                // download the file in the browser
                console.log(stdout)
                res.download(outputfile,(err) => {
 
                })
            }
        })
    }
  })
})
 
app.listen(port)
 
 
Code:
index.html
 
 









    
    
    
    Document


    

        
        
    


 
 
Before executing the project make sure that you create the
Code:
uploads
folder where the audio files will get uploaded
 
Now you run the node.js project
 
Code:
node index.js


From codingshiksha.com/javascript/node-js-ffmpeg-project-to-add-3d-8d-effect-to-audio-mp3-file-using-apulsator-filter-in-express
jamied_uk
jamied_uk
Admin

Posts : 3053
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum