【问题标题】:How to change mp3 file to wav file in node.js如何在 node.js 中将 mp3 文件更改为 wav 文件
【发布时间】:2017-03-07 02:37:18
【问题描述】:

我正在尝试将 mp3 文件转换为 wav 文件,但我不知道该怎么做,我尝试使用 fluent-ffmpeg 库但我不知道如何使用它。

【问题讨论】:

    标签: fluent-ffmpeg


    【解决方案1】:

    我终于用 'fluent-ffmpeg' 库弄明白了。这是我的代码。

    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
    

    【讨论】:

    • 我收到错误:An error occurred: Cannot find ffmpeg.
    • var ffmpeg = require('fluent-ffmpeg'); 没有错误。只有在我使用时才会出错。
    • 确保 ffmpeg 已安装在系统中并且可以从任何地方执行,第二件事是确保项目中也安装了“fluent-ffmpeg”npm 包。
    • 两者都重新安装。我还在系统环境变量中添加了路径(对于 ffmpeg)。现在我收到错误:` ENOENTspawn C:\ffmpeg\bin\ffmpeg.exe at exports._errnoException (util.js:1022:11) at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32 ) 在 onErrorNT (internal/child_process.js:359:16)`
    • ok 做一件事,只是去控制台并尝试执行一些 ffmpeg 命令。无论你告诉它应该做什么工作,或者如果你能告诉我你的来源,那么我可以解决问题。
    猜你喜欢
    • 1970-01-01
    • 2011-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-09
    • 2013-07-12
    相关资源
    最近更新 更多