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

Error: Input format lavfi is not available #1282

Open
3 tasks done
fa0311 opened this issue Jun 25, 2024 · 6 comments
Open
3 tasks done

Error: Input format lavfi is not available #1282

fa0311 opened this issue Jun 25, 2024 · 6 comments

Comments

@fa0311
Copy link

fa0311 commented Jun 25, 2024

Version information

  • fluent-ffmpeg version: 2.1.3
  • ffmpeg version: 7.0.1
  • OS: Windows

Code to reproduce

import { default as ffmpeg, default as ffprobe } from "fluent-ffmpeg";
const command = ffmpeg();
command.input("anullsrc=channel_layout=mono:sample_rate=44100");
command.inputFormat("lavfi");
command.addOption("-t", "20");
command.output("test.mp4")
command.run();

(note: if the problem only happens with some inputs, include a link to such an input file)

Expected results

Observed results

Error: Input format lavfi is not available

Temporary workaround

// TypeScript
const bypass = (command: ffmpeg.FfmpegCommand) => {
    const bk = command.availableFormats;
    command.availableFormats = (cb: (err: any, data: any) => void) => {
      bk.bind(command)((err, data) => {
        const lavfi = {
          canDemux: true,
          canMux: true,
          description: "Lavfi",
        };
        cb(err, { ...data, lavfi });
      });
    };
  }

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
@stepin
Copy link

stepin commented Oct 9, 2024

capabilities.js parses formats from ffmpeg -formats output. It uses regexp https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/blob/master/lib/capabilities.js#L18 :

var formatRegexp = /^\s*([D ])([E ])\s+([^ ]+)\s+(.*)$/;

So, it skips all device related formats including lavfi:

~$ ffmpeg -formats|egrep '[E ]d '
ffmpeg version 7.1 Copyright (c) 2000-2024 the FFmpeg developers
  built with Apple clang version 15.0.0 (clang-1500.3.9.4)
  configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/7.1 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags='-Wl,-ld_classic' --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libaribb24 --enable-libbluray --enable-libdav1d --enable-libharfbuzz --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-audiotoolbox --enable-neon
  libavutil      59. 39.100 / 59. 39.100
  libavcodec     61. 19.100 / 61. 19.100
  libavformat    61.  7.100 / 61.  7.100
  libavdevice    61.  3.100 / 61.  3.100
  libavfilter    10.  4.100 / 10.  4.100
  libswscale      8.  3.100 /  8.  3.100
  libswresample   5.  3.100 /  5.  3.100
  libpostproc    58.  3.100 / 58.  3.100
  Ed audiotoolbox    AudioToolbox output device
 D d avfoundation    AVFoundation input device
 D d lavfi           Libavfilter virtual input device
  Ed sdl,sdl2        SDL2 output device
 D d x11grab         X11 screen capture, using XCB

It's quite easy to fix regexp:

var formatRegexp = /^\s*([D ])([E ])([d ])\s+([^ ]+)\s+(.*)$/;

but I don't know idea behind current behaviour: if it's just a bug or way to filter out some formats.

PS. About workaround above: lavfi can demux but can't mux. So, it's better to use:

        const lavfi = {
          canDemux: true,
          canMux: false,
          description: "Libavfilter virtual input device",
        };

@stepin
Copy link

stepin commented Oct 9, 2024

Some more device formats (from Linux):

  • alsa
  • fbdev
  • oss
  • video4linux2
  • v4l2

@stepin
Copy link

stepin commented Oct 9, 2024

Looks like it's related to ffmpeg 7 changes and in latest release of this library there were try to fix but a bit incorrect (current code skips all device formats).

A better solution:
alexger@bca837e

And there is MR: #1276

@tokenosopher
Copy link

Can this be merged?

Looks like it's related to ffmpeg 7 changes and in latest release of this library there were try to fix but a bit incorrect (current code skips all device formats).

A better solution: alexger@bca837e

And there is MR: #1276

Can this be merged? This fixed my issue, which weirdly enough started sporadically

@JamieS1211
Copy link

Bypass worked for me but would be great if this could be merged and sort the issue out long term

@LorDisturbia
Copy link

The same problem prevents you from setting x11grab and pulse as inputs, but it can be fixed with the same workaround.

I'd love to see #1276 merged and released.

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

No branches or pull requests

5 participants