fluent-ffmpeg / node-fluent-ffmpeg

A fluent API to FFMPEG (http://www.ffmpeg.org)
MIT License
7.85k stars 874 forks source link

ReferenceError: `__dirname` is not defined #1283

Open Stadly opened 3 months ago

Stadly commented 3 months ago

I cannot use fluent-ffmpeg in the production build of my SvelteKit app. It works in dev mode, and also in preview mode, but in the final production build, any call to ffmpeg results in a ReferenceError: __dirname is not defined. I guess it is an issue with ESM vs CommonJS.

Version information

Code to reproduce

import ffmpeg from "fluent-ffmpeg";
ffmpeg();

(note: if the problem only happens with some inputs, include a link to such an input file)

Expected results

No errors

Observed results

ReferenceError: __dirname is not defined
    at new FfmpegCommand (file:///app/build/server/chunks/index-D6fKiITG.js:5210:69)
    at FfmpegCommand (file:///app/build/server/chunks/index-D6fKiITG.js:5178:13)
    at file:///app/build/server/chunks/0-DGpjmR_G.js:15:8
    at file:///app/build/server/chunks/server-DbC9RgP-.js:13:32
    at load_server_data (file:///app/build/server/chunks/index-B8KRwtQw.js:1464:42)
    at file:///app/build/server/chunks/index-B8KRwtQw.js:2947:24

Checklist