I'm trying to convert an mp4 video to mp3 with node's fluent-ffmpeg module. Here is my code:
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'
)
On running it, I get the following error:
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)
Any ideas?
Solution:
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
the spawn system call ends with error ENOENT if the program cannot be found. In this case, ffmpeg
is not found, so you have to tell it where it is:
proc = new ffmpeg({source:mp4})
.setFfmpegPath("wherever ffmpeg is installed ") <-- this is the new line
.toFormat('mp3')
.saveToFile(mp3, (stdout, stderr)->
return console.log stderr if err?
return console.log 'done'
)
More info is available in a related issue