node.js – Getting error spawn ffmpeg ENOENT aws lambda
I have being trying to debug but to no avail, I’ve done everything on the internet.
I Used WSL (Ubuntu) – Error: spawn usr/bin/ffmpeg ENOENT.
I Used windows – Error: spawn path/to/ffmpeg.exe ENOENT.
I had to SAM deploy –guide and then added a lambda layer on aws console.
Moved Ffmpeg file to my project root folder also ENOENT.
Ffmpeg exists in those parts, “path/to/ffmpeg -version” prints version/other info.
I gave permissions using chmod +x, I used AI too.
3days of struggle
import { spawn } from 'child_process';
import ffmpeg from 'fluent-ffmpeg';
const isLocal = process.env.AWS_SAM_LOCAL; // Detect local SAM environment
const ffmpegPath = isLocal ? 'C:\\ProgramData\\chocolatey\\lib\\ffmpeg\\tools\\ffmpeg\\bin\\ffmpeg.exe' : '/opt/bin';
ffmpeg.setFfmpegPath(ffmpegPath);
const ffmpegArgs = [
'-i',
inputFilePath,
'-vf',
`crop=9/16*ih:ih:scale=1080:1920`,
'-c:v',
'libx264',
'-c:a',
'aac',
'-strict',
'experimental',
outputFilePath,
];
const ffmpegProcess = spawn(ffmpegPath, ffmpegArgs);
Read more here: Source link
