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

♀尐吖头ヾ 提交于 2021-02-06 20:17:13

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/40233300/how-to-change-mp3-file-to-wav-file-in-node-js

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!