【问题标题】:NodeJS: Set path to FFMPEG binaries for module Fluent-FFMPEGNodeJS:为模块 Fluent-FFMPEG 设置 FFMPEG 二进制文件的路径
【发布时间】:2013-11-14 04:47:07
【问题描述】:

我正在构建一个使用模块 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.

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

【问题讨论】:

    标签: node.js path ffmpeg binaries


    【解决方案1】:

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

      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){
    

    【讨论】:

    • 一、也可以使用shelljs模块,可以跨平台工作。 var shell = require('shelljs');var ffmpegPath = shell.which('ffmpeg');
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-09-28
      • 2018-01-22
      • 2020-04-26
      • 2017-12-27
      • 1970-01-01
      • 2017-02-20
      • 2020-10-20
      相关资源
      最近更新 更多