fluent-ffmpeg / node-fluent-ffmpeg

A fluent API to FFMPEG (http://www.ffmpeg.org)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

when done exporting with audio, there was an error and it won't work

MapidsFanAnimator opened this issue · comments

Version information

  • fluent-ffmpeg version: 2.1.2
  • ffmpeg version: 6.0
  • OS: Windows 11

Code to reproduce

here is the code that I entered v

const audios = await Movie.getAudio(req.body.id);
	let complexFilterString = "";
	for (const i in audios) {
	const audio = audios[i];
	const baseDuration = audio.stop - audio.start;
	const duration = Math.max(baseDuration, audio.trimEnd) - audio.trimStart;
	console.log(duration, baseDuration)
	ok.input(audio.filepath);
	ok.addInputOptions("-t", frameToSec(duration));
	complexFilterString += `[${i}:a]adelay=` + frameToSec(audio.start - 0) * 1e3 + `[audio${i}];`
	 }
	ok
		.complexFilter(complexFilterString + `${audios.map((_, i) => `[audio${i}]`).join("")}amerge[a]`)
		.videoCodec("libx264")
	    .audioCodec("aac")
		.outputOptions("-map", "[0:v]")
		.outputOptions("-map", "[a]")
		.outputOptions("-framerate", "23.97")
		.outputOptions("-r", "23.97")
		.output(path.join(base, "output.mp4"))
		.run();
});

and here's the error
Error: ffmpeg exited with code 1: Stream specifier ':a' in filtergraph description [0:a]adelay=41.71881518564873[audio0];[audio0]amerge[a] matches no streams.

even when I tried fixing it like added 1:a or something, it still show up an error, how do you fix it?