3

我正在构建一个使用模块 node-fluent-ffmpeg 的应用程序。https://github.com/schaermu/node-fluent-ffmpeg

我正在尝试将 ffmpeg 二进制文件与我的应用程序一起打包。我想这样做(尤其是在 Windows 上)用户不必手动安装 FFMPEG。

可悲的是,我尝试过的一切都会导致错误。我尝试了以下方法:

  ffmpeg.setFfmpegPath   : Gives an error saying setFfmpegPath is not a method

和:

  proc.setFfmpegPath    : Gives a createproces error.

看来我做错了什么。有人可以指出我的错误。非常感谢。

4

2 回答 2

7

我修复它!我不知道我必须在路径中包含二进制文件本身。所以我做了这样的事情:

  if(os.platform() === 'win32'){
     var ffmpegPath = './bin/ffmpeg/ffmpeg.exe'
 }else{
     var ffmpegPath = './bin/ffmpeg/ffmpeg'
 }

 proc = new ffmpeg({ source: movieUrl, nolog: true, timeout: FFMPEG_TIMEOUT })
 proc.setFfmpegPath(ffmpegPath)
 proc.addOptions(opts)
 proc.writeToStream(response, function(return_code, error){
于 2013-12-20T08:03:28.210 回答
2

就我而言,我已经下载了 npm i -S ffmpeg-binaries~,然后我将 process.env.FFMPEG_PATH 设置为“./node_modules/ffmpeg-binaries/bin/ffmpeg.exe”。这对我有用。

于 2018-09-02T17:46:26.757 回答