簡體   English   中英

NodeJS:為模塊Fluent-FFMPEG設置FFMPEG二進制文件的路徑

[英]NodeJS: Set path to FFMPEG binaries for module Fluent-FFMPEG

我正在構建一個使用模塊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.

看來我做錯了什么。 有人可以指出我的錯誤。 非常感謝。

我修理它! 我不知道我必須在路徑中包含二進制文件。 所以我做了這樣的事情:

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

在我的情況下,我已經下載了npm i -S ffmpeg-binaries~然后我將process.env.FFMPEG_PATH設置為'./node_modules/ffmpeg-binaries/bin/ffmpeg.exe'。 這對我有用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM