Summary
Inputs like inputFormat('lavfi') (used to feed testsrc=… or sine=… virtual sources to ffmpeg) fail with Input format lavfi is not available, even though ffmpeg -formats clearly lists lavfi. The cause is a 1-character mismatch in our formatRegexp — virtual / device demuxers are emitted with a 3-flag column (D d for "demux + device") instead of the standard 2-flag column (D ), and the regex only consumes 2 flags.
Upstream issues
Reproduction
import ffmpeg from "@modernized/fluent-ffmpeg";
ffmpeg()
.input("testsrc=duration=1:size=320x240:rate=30")
.inputFormat("lavfi")
.output("/tmp/out.mp4")
.on("error", (err) => console.error(err.message))
.run();
// → "Input format lavfi is not available"
ffmpeg -formats shows the row:
The d in column 3 marks the format as a "device". Our formatRegexp (lib/capabilities.ts:19):
const formatRegexp = /^\s*([D ])([E ])\s+([^ ]+)\s+(.*)$/;
expects exactly 2 flag columns, so the d is mis-aligned and the row is silently dropped from the parsed format table.
Fix plan
Allow an optional 3rd flag character (a d for device, or a space):
- const formatRegexp = /^\s*([D ])([E ])\s+([^ ]+)\s+(.*)$/;
+ const formatRegexp = /^\s*([D ])([E ])[d ]?\s+([^ ]+)\s+(.*)$/;
Behaviour-preserving: existing 2-flag rows still match (the [d ]? is optional), and 3-flag rows with d or space are accepted. The capture group indices for name (match[3]) and description (match[4]) are unchanged.
Test plan
A unit test fixture that feeds a captured ffmpeg -formats snapshot containing the D d lavfi … line into parseFormatsOutput and asserts formats.lavfi.canDemux === true.
Caveat
Our local _checkCapabilities then accepts lavfi as a valid input format. The actual virtual-source generation (testsrc=…) still flows through ffmpeg as before — no runtime behaviour beyond the cap check changes.
Summary
Inputs like
inputFormat('lavfi')(used to feedtestsrc=…orsine=…virtual sources to ffmpeg) fail withInput format lavfi is not available, even thoughffmpeg -formatsclearly listslavfi. The cause is a 1-character mismatch in ourformatRegexp— virtual / device demuxers are emitted with a 3-flag column (D dfor "demux + device") instead of the standard 2-flag column (D), and the regex only consumes 2 flags.Upstream issues
Reproduction
ffmpeg -formatsshows the row:The
din column 3 marks the format as a "device". OurformatRegexp(lib/capabilities.ts:19):expects exactly 2 flag columns, so the
dis mis-aligned and the row is silently dropped from the parsed format table.Fix plan
Allow an optional 3rd flag character (a
dfor device, or a space):Behaviour-preserving: existing 2-flag rows still match (the
[d ]?is optional), and 3-flag rows withdor space are accepted. The capture group indices forname(match[3]) anddescription(match[4]) are unchanged.Test plan
A unit test fixture that feeds a captured
ffmpeg -formatssnapshot containing theD d lavfi …line intoparseFormatsOutputand assertsformats.lavfi.canDemux === true.Caveat
Our local
_checkCapabilitiesthen acceptslavfias a valid input format. The actual virtual-source generation (testsrc=…) still flows through ffmpeg as before — no runtime behaviour beyond the cap check changes.