Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when setting ffmpeg path after successfully converting #1285

Open
3 tasks done
gsproston opened this issue Jun 30, 2024 · 0 comments · May be fixed by #1286
Open
3 tasks done

Crash when setting ffmpeg path after successfully converting #1285

gsproston opened this issue Jun 30, 2024 · 0 comments · May be fixed by #1286

Comments

@gsproston
Copy link

gsproston commented Jun 30, 2024

I'm seeing a program crash when converting with an invalid ffmpeg path after successfully converting a video with a valid path.

Version information

  • fluent-ffmpeg version: 2.1.3
  • ffmpeg version: 7.0.1-essentials_build-www.gyan.dev
  • OS: Windows 10 Home 22H2

Code to reproduce

var ffmpeg = require("fluent-ffmpeg");

const INPUT_PATH = "./input/SampleVideo_1280x720_1mb.mkv";
const OUTPUT_PATH = "./output/test.mp4";

// start by converting with a valid FFMPEG path
ffmpeg(INPUT_PATH)
  .output(OUTPUT_PATH)
  .on("start", function (cmdline) {
    console.log("Command line: " + cmdline);
  })
  .on("error", function (err, stdout, stderr) {
    console.log("An error happened: " + err.message);
    console.log("ffmpeg standard output:\n" + stdout);
    console.log("ffmpeg standard error:\n" + stderr);
  })
  .on("end", function () {
    console.log("Finished processing");

    // once the conversion has finished with the valid path
    // start converting with an invalid path
    ffmpeg(INPUT_PATH)
      .setFfmpegPath("bad-path")
      .output(OUTPUT_PATH)
      .on("start", function (cmdline) {
        console.log("Command line: " + cmdline);
      })
      .on("error", function (err, stdout, stderr) {
        console.log("An error happened: " + err.message);
        console.log("ffmpeg standard output:\n" + stdout);
        console.log("ffmpeg standard error:\n" + stderr);
      })
      .on("end", function () {
        console.log("Finished processing");
      })
      .run();
  })
  .run();

Expected results

I expect the conversion to fail, but to fail gracefully by calling the error callback and for the above code to then log the error.

Observed results

Instead the entire program crashes when the error occurs. I don't see the logged out error as expected. I instead see the following:

Exception has occurred: TypeError: Cannot read properties of undefined (reading 'get')
  at endCB (A:\Germingi\Documents\programming\test\fluent-ffmpeg-bug\node_modules\fluent-ffmpeg\lib\processor.js:543:37)
    at ChildProcess.<anonymous> (A:\Germingi\Documents\programming\test\fluent-ffmpeg-bug\node_modules\fluent-ffmpeg\lib\processor.js:157:9)
    at ChildProcess.emit (node:events:520:28)
    at ChildProcess._handle.onexit (node:internal/child_process:292:12)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

and the error message in the endCB function is "spawn bad-path ENOENT", which is expected.

From looking at the code, it might be necessary to clear the cache in capabilities.js when the ffmpeg path is changed.

Checklist

  • I have read the FAQ
  • I tried the same with command line ffmpeg and it works correctly (hint: if the problem also happens this way, this is an ffmpeg problem and you're not reporting it to the right place)
  • I have included full stderr/stdout output from ffmpeg
@gsproston gsproston linked a pull request Jun 30, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant