我正在尝试使用节点的 fluent-ffmpeg 模块将 mp4 视频转换为 mp3。这是我的代码:
ffmpeg = require 'fluent-ffmpeg'
mp4 = '/Users/jashua/Desktop/video.mp4'
mp3 = '/Users/jashua/Desktop/audio.mp3'
proc = new ffmpeg({source:mp4})
.toFormat('mp3')
.setFfMpegPath('/Applications/ffmpeg')
.saveToFile(mp3, (stdout, stderr)->
return console.log stderr if err?
return console.log 'done'
)
在运行它时,我收到以下错误:
TypeError: Cannot call method 'saveToFile' of undefined
at Object.<anonymous> (/Users/jashua/Desktop/ytdl.coffee:10:12, <js>:18:60)
at Object.<anonymous> (/Users/jashua/Desktop/ytdl.coffee:1:1, <js>:25:4)
at Module._compile (module.js:456:26)
有任何想法吗?
解决方案:
proc = new ffmpeg({source:mp4})
proc.setFfMpegPath('/Applications/ffmpeg')
proc.saveToFile(mp3, (stdout, stderr)->
return console.log stderr if err?
return console.log 'done'
)
enter code here