Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change mp3 file to wav file in node.js

I am trying to convert mp3 file to wav file but I am not getting idea how to do that, I tried using fluent-ffmpeg library but I don't know how to use that.

like image 518
Yatender Singh Avatar asked Oct 25 '16 06:10

Yatender Singh


1 Answers

I finally figured it out using 'fluent-ffmpeg' library. Here is my code.

const ffmpeg = require('fluent-ffmpeg');
let track = './source.mp3';//your path to source file

ffmpeg(track)
.toFormat('wav')
.on('error', (err) => {
    console.log('An error occurred: ' + err.message);
})
.on('progress', (progress) => {
    // console.log(JSON.stringify(progress));
    console.log('Processing: ' + progress.targetSize + ' KB converted');
})
.on('end', () => {
    console.log('Processing finished !');
})
.save('./hello.wav');//path where you want to save your file
like image 98
Yatender Singh Avatar answered Oct 14 '22 00:10

Yatender Singh