I'm using a library called 'fluent-ffmpeg' on my Nodejs server that makes it easier to use an audio/video editing tool called FFmpeg, which is downloaded locally on my computer.
When running on my computer, I point fluent-ffmpeg to the local executable files of FFmpeg and FFprobe on my computer, like so:
import ffmpeg from "fluent-ffmpeg";
// When running locally, set FFmpeg and FFprobe path to the local executable files
ffmpeg.setFfmpegPath("C:/Program Files/FFMPEG/ffmpeg.exe");
ffmpeg.setFfprobePath("C:/Program Files/FFMPEG/ffprobe.exe");
When deploying to Heroku, I must use an FFmpeg 'buildpack'.
I've tried two:
Neither have worked for me. Whenever I use an FFmpeg command, I get the following error in my heroku logs:
2021-07-24T15:22:52.970990+00:00 app[web.1]: code: 'ENOENT',
2021-07-24T15:22:52.970990+00:00 app[web.1]: syscall: 'spawn C:/Program Files/FFMPEG/',
2021-07-24T15:22:52.970990+00:00 app[web.1]: path: 'C:/Program Files/FFMPEG/',
2021-07-24T15:22:52.970991+00:00 app[web.1]: spawnargs: [
2021-07-24T15:22:52.970991+00:00 app[web.1]: '-show_streams',
2021-07-24T15:22:52.970991+00:00 app[web.1]: '-show_format',
2021-07-24T15:22:52.970992+00:00 app[web.1]: 'temp/cf3b5f1ae270df824921364573a4366b'
2021-07-24T15:22:52.970992+00:00 app[web.1]: ]
2021-07-24T15:22:52.970992+00:00 app[web.1]: }
How can I go about using fluent-ffmpeg in my Nodejs server when deploying to Heroku?
Thank you for the help in advance!
I wasn't able to get it working with fluent-ffmpeg, but using the buildpack:
https://github.com/jonathanong/heroku-buildpack-ffmpeg-latest
I was able to work with using 'exec' commands in place of fluent-ffmpeg. It requires you to write out ffmpeg commands like you would in the command prompt.
For example:
import { exec } from "child_process";
exec(`ffmpeg -f concat -safe 0 -i ${filesListPath} -c copy ${mergedFilePath}`, async (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
//Do stuff to handle error
}
else {
//Do stuff to handle success