How install FFMPEG on Netlify

the deployment of my site is not successful due to this error:

2:23:07 PM: Error writing templates: (more in DEBUG output)
2:23:07 PM: > Having trouble writing template: _site/blog/coordinate-di-latitudine-e-longitudine-nuovo-google-maps/index.html
2:23:07 PM: `TemplateWriterWriteError` was thrown
2:23:07 PM: > Command failed: ffmpeg -i src/site/images/google-maps-trovare-latitudine-con-un-clic.gif -movflags faststart -filter:v "scale=trunc(iw/2)*2:trunc(ih/2)*2" -pix_fmt yuv420p -y -loglevel error _site/images/google-maps-trovare-latitudine-con-un-clic.xform.mp4
2:23:07 PM: /bin/sh: 1: ffmpeg: not found
2:23:07 PM: `Error` was thrown:
2:23:07 PM:     Error: Command failed: ffmpeg -i src/site/images/google-maps-trovare-latitudine-con-un-clic.gif -movflags faststart -filter:v "scale=trunc(iw/2)*2:trunc(ih/2)*2" -pix_fmt yuv420p -y -loglevel error _site/images/google-maps-trovare-latitudine-con-un-clic.xform.mp4
2:23:07 PM:     /bin/sh: 1: ffmpeg: not found
2:23:07 PM:         at ChildProcess.exithandler (child_process.js:303:12)
2:23:07 PM:         at ChildProcess.emit (events.js:315:20)
2:23:07 PM:         at maybeClose (internal/child_process.js:1021:16)
2:23:07 PM:         at Socket.<anonymous> (internal/child_process.js:443:11)
2:23:07 PM:         at Socket.emit (events.js:315:20)
2:23:07 PM:         at Pipe.<anonymous> (net.js:674:12)

The problem apparently is that I have to install FFMPEG on the Netlify server. I read that I need to add the pre-compiled files to the repository and then launch the build. But I have no idea how.

Would anyone be kind enough to show me a step-by-step guide on how to do it?

Thank you

Hey @andrealeardini and welcome to Netlify Community!

I remember stumbling across this discussion a little while back. I don’t suppose this will help at all?

Hi @Pieparker,
thanks for the welcome. Unfortunately that thread only partially answers my problem. I tried to install the suggested package but the error remains. The answer marked as solution says what to do but not how. I would need instructions on how to do these steps.
Can you help me?

I believe I was the person who raised that issue.
You have to find an ffmpeg install for the Ubuntu Linux v 16.04 LTS using x86_64 architecture and place the binary wherever you want in your app. If you did a global install on a linux machine, you will find it in usr/bin/ffmpeg. You can use the ffmpeg by using the relative path to the ffmpeg binary and it will work. Some time has passed since I last tried this, so forgive me if I’m a little fuzzy on the details. Let me know if you’re still having issues!

1 Like

Someone reopened this issue recently:

1 Like

Hi @hideodaikoku,
I found the binary file and copied it to the repository root. I can’t use a relative path or modify the call to ffmpeg because it is made by a plugin. Do I need to add the local binary to the global PATH? Is there any way to install it without root permissions? Thank you for your support

I was unable to find a way to permanently set the path on Netlify. In the end I gave up and opted to change the plugin code. Thanks to the links published by @Pieparker and @hideodaikoku I managed to solve the problem.

These are the steps:

  1. copy a static builf of ffmpeg in the repository (/bin/ffmpeg-git-20200617-amd64-static) (see

  2. create a local copy of the package that uses ffmpeg (eleventy-plugin-local-respimg) in ./scr/eleventy-plugin-local-respimg

  3. modify eleventy.js to use the local copy
    const pluginLocalRespimg = require('./src/eleventy-plugin-local-respimg')

  4. The path is different if you execute the build on a local machine or on Eleventy. In the package.json set an enviroment variable in the build command for Netlify
    "netlify": "NODE_ENV=production npm run build",

  5. In the local copy of the plugin check for the NODE_ENV and build the path of ffmpeg. You should give the permission as executable with chmode.

    const isProduction = (process.env.NODE_ENV === ‘production’);
    const ffmpegPath = (isProduction === true) ? ‘/opt/build/repo/bin/ffmpeg-git-20200617-amd64-static/’ : ‘/bin/’;
    if (isProduction === true) {
    exec(‘chmod +x /opt/build/repo/bin/ffmpeg-git-20200617-amd64-static/ffmpeg’);
    exec(‘chmod +x /opt/build/repo/bin/ffmpeg-git-20200617-amd64-static/ffprobe’);
    exec(‘chmod +x /opt/build/repo/bin/ffmpeg-git-20200617-amd64-static/qt-faststart’);
    const command = `{ffmpegPath}ffmpeg -i {input} -movflags faststart -filter:v “scale=trunc(iw/2)*2:trunc(ih/2)*2” -pix_fmt yuv420p -y -loglevel error ${output}`;

I’m sorry for my bad English but I hope the steps are clear

1 Like

thanks for sharing your solution!

1 Like

Great! Glad you found a fix. I hope Netlify has a better solution for integrating ffmpeg in a later release

1 Like