Uncaught NodeError TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string.

Author: xuguanqunCreated Mar 12, 2022Updated Feb 18, 2025
javascript
const ffmpegStatic = require("ffmpeg-static");
const ffprobeStatic = require("ffprobe-static");
const fluentffmpeg = require("fluent-ffmpeg");

const ffmpeg = new fluentffmpeg();

ffmpeg.setFfmpegPath(ffmpegStatic);
ffmpeg.setFfprobePath(ffprobeStatic);
// ffmpeg.setFlvtoolPath();

const iptpath = "D:\\1.mkv";
const optpath = "D:\\2.mp4";

ffmpeg.addInput(iptpath);
ffmpeg.output(optpath);

ffmpeg.ffprobe((err, metadata) => {
  console.log(err, metadata);
});

error:

Uncaught NodeError TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string. Received an instance of Object
    at NodeError (internal/errors.js:279:9)
    at validateString (internal/validators.js:124:11)
    at normalizeSpawnArguments (child_process.js:509:3)
    at spawn (child_process.js:665:13)
    at spawnWithSignal (child_process.js:871:17)
    at <anonymous> ([c:\Users\Administrator\Desktop\fluent-ffmpeg\node_modules\fluent-ffmpeg\lib\ffprobe.js:155:21]())
    at proto._getFfprobePath ([c:\Users\Administrator\Desktop\fluent-ffmpeg\node_modules\fluent-ffmpeg\lib\capabilities.js:144:14]())
    at proto.ffprobe ([c:\Users\Administrator\Desktop\fluent-ffmpeg\node_modules\fluent-ffmpeg\lib\ffprobe.js:141:10]())
    at <anonymous> ([c:\Users\Administrator\Desktop\fluent-ffmpeg\index.js:17:8]())
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Module._load (internal/modules/cjs/loader.js:778:12)
    at executeUserEntryPoint (internal/modules/run_main.js:76:12)
    at <anonymous> (internal/main/run_main_module.js:17:47)

Source: fluent-ffmpeg/node-fluent-ffmpeg