2013-11-03 107 views
3

我在構建一個使用模塊node-fluent-ffmpeg的應用程序。 https://github.com/schaermu/node-fluent-ffmpegNodeJS:爲模塊Fluent-FFMPEG設置FFMPEG二進制文件的路徑

我試圖將ffmpeg二進制文件與我的應用程序一起打包。 我想這樣做(特別是在Windows上),用戶不必手動安裝FFMPEG。

可悲的是我試過的一切都會導致錯誤。我已經試過如下:

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

和:

proc.setFfmpegPath : Gives a createproces error. 

好像我做錯了什麼。有人能指出我的錯誤嗎? 非常感謝。

回答

5

我修好了! 我不知道我必須將二進制本身包含在路徑中。所以我做了這樣的事情:

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

一,還可以使用shelljs模塊,它將跨平臺工作。 ('''');' ' – KostasX

相關問題