I have a Node.js application deployed to a docker container with fluent-ffmpeg
, @ffmpeg-installer/ffmpeg
, and @ffprobe-installer/ffmprobe
.
Here is the fluent-ffmpeg
init script:
import ffmpeg = require('fluent-ffmpeg');
const ffmpegPath = require('@ffmpeg-installer/ffmpeg').path;
const ffprobePath = require('@ffprobe-installer/ffprobe').path;
ffmpeg.setFfmpegPath(ffmpegPath);
ffmpeg.setFfprobePath(ffprobePath);
export default ffmpeg;
This gets used to take a snapshot of a video and save that image to file:
ffmpeg('ism manifest here')
.inputOption(`-ss timestamp`)
.outputOptions([
'-vframes 1',
'-vf crop=640:230:320:490,eq=saturation=0:contrast=1000,negate'
])
.output('test.png')
.run();
Whenever any configuration of ffmpeg command is run, it nearly instantaneously fails with:
Error: ffmpeg was killed with signal SIGSEGV
at ChildProcess.<anonymous> (/app/node_modules/fluent-ffmpeg/lib/processor.js:180:22)
at ChildProcess.emit (node:events:517:28)
at Process.ChildProcess._handle.onexit (node:internal/child_process:292:12)
I have attempted to raise the memory and CPU usage limits of the server in the docker-compose file:
...
deploy:
resources:
limits:
cpus: '0.75'
memory: 2G
reservations:
cpus: '0.50'
memory: 1G
But nothing has worked. Running this on my local machine works just fine. Help?
UPDATE:
I just attempted running a small dockerized ffmpeg test script on its own in its own brand new container. Same issue. So, it doesn't seem to have anything to do with my server's configuration.
It seems that there's some sort of issue with using the binary provided by @ffmpeg-installer/ffmpeg
in Docker.
I instead went the route that I found elsewhere, which is to run
RUN apt-get install ffmpeg -y
in the dockerfile. This installs ffmpeg
and adds it to the Linux PATH, allowing it to be picked up by fluent-ffmpeg
automatically. Alternatively, you could also still run ffmpeg.setFfmpegPath('/usr/bin/ffmpeg');
manually.
ffmpeg
now works like a charm.