ffmpeg.js
ffmpeg.js copied to clipboard
"File Already Exists" error
(This project is awesome BTW)
Even when randomly generating a unique output file, there is the error:
File '/data/output0.20456638176621045.mp4' already exists. Overwrite ? [y/N] Not overwriting - exiting
Output file argument: `/data/output${Math.random()}.mp4`
Here's the full code:
let ffmpegFunc = require("ffmpeg.js/ffmpeg-mp4.js")
let ffmpeg = (...args)=>ffmpegFunc({
mounts: [{ type: "NODEFS", opts: {root: "."}, mountpoint: "/data" }],
arguments: [
"-noaccurate_seek", "-ss", "00:00:05.0",
"-i", "/data/test.mp4",
"-to", "00:00:15.0", "-c", "copy",
`/data/output${Math.random()}.mp4`
],
print: data=>console.log(data),
printErr: data=>console.error(data),
onExit: exitCode=>console.log(`FFMPEG exited with code ${exitCode}`),
})
Yes, it's a problem with NODEFS, I haven't find the reason yet. Use -y option as a workaround.
I was actually going to post the workaround, but you responded faster than I could type it! haha.
Adding "-y" does successfully creates the output video for me. Here's the code for reference for anyone else looking.
let ffmpegFunc = require("ffmpeg.js/ffmpeg-mp4.js")
let ffmpeg = (...args)=>ffmpegFunc({
mounts: [{ type: "NODEFS", opts: {root: "."}, mountpoint: "/data" }],
arguments: [
"-y",
"-noaccurate_seek", "-ss", "00:00:05.0",
"-i", "/data/test.mp4",
"-to", "00:00:15.0", "-c", "copy",
`/data/output${Math.random()}.mp4`
],
print: data=>console.log(data),
printErr: data=>console.error(data),
onExit: exitCode=>console.log(`FFMPEG exited with code ${exitCode}`),
})