fluent-ffmpeg / node-fluent-ffmpeg

A fluent API to FFMPEG (http://www.ffmpeg.org)
MIT License
7.85k stars 874 forks source link

Strange behavior with dshow device #648

Open super-ienien opened 7 years ago

super-ienien commented 7 years ago

Hi,

On windows I'm having trouble with ffmpeg-fluent. When with ffmpef-fluent I try to use dshow capture device as input, ffmpeg tell me that it doesn't find this device. But when i run exactly the same command directly via command line it works...

dump of ffmpeg-fluent :

started : ffmpeg -vcodec rawvideo -f rawvideo -pix_fmt rgb32 -framerate 30 -s 1280x720 -rtbufsize 1500M -vsync 0 -fflags genpts -i pipe:0 -f dshow -i audio="virtual-audio-capturer" -acodec aac -b:a 128k -ac 1 -vcodec h264_nvenc -r 30 -preset fast -pix_fmt yuv420p -crf 20 -maxrate 4000k -bufsize 8000k -g 30 -flvflags no_duration_filesize -f mpegts udp://127.0.0.1:8888
Stderr output: ffmpeg version N-82966-g6993bb4 Copyright (c) 2000-2016 the FFmpeg developers
Stderr output:   built with gcc 5.4.0 (GCC)
Stderr output:   configuration: --enable-gpl --enable-version3 --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
Stderr output:   libavutil      55. 43.100 / 55. 43.100
Stderr output:   libavcodec     57. 70.100 / 57. 70.100
Stderr output:   libavformat    57. 61.100 / 57. 61.100
Stderr output:   libavdevice    57.  2.100 / 57.  2.100
Stderr output:   libavfilter     6. 68.100 /  6. 68.100
Stderr output:   libswscale      4.  3.101 /  4.  3.101
Stderr output:   libswresample   2.  4.100 /  2.  4.100
Stderr output:   libpostproc    54.  2.100 / 54.  2.100
Stderr output: Input #0, rawvideo, from 'pipe:0':
Stderr output:   Duration: N/A, start: 0.000000, bitrate: 884736 kb/s
Stderr output:     Stream #0:0: Video: rawvideo (BGRA / 0x41524742), bgra, 1280x720, 884736 kb/s, 30 tbr, 30 tbn, 30 tbc
Stderr output: [dshow @ 000000000070ac20] Could not find audio only device with name ["virtual-audio-capturer"] among source devices of type audio.
Stderr output: [dshow @ 000000000070ac20] Searching for audio device within video devices for "virtual-audio-capturer"
Stderr output: [dshow @ 000000000070ac20] Could not find audio only device with name ["virtual-audio-capturer"] among source devices of type video.
Stderr output: audio="virtual-audio-capturer": I/O error

Dump of cmd :

ffmpeg -vcodec rawvideo -f rawvideo -pix_fmt rgb32 -framerate 30 -s 1280x720 -rtbufsize 1500M -vsync 0 -fflags genpts -i pipe:0 -f dshow -i audio="virtual-audio-capturer" -acodec aac -b:a 128k -ac 1 -vcodec h264_nvenc -r 30 -preset fast -pix_fmt yuv420p -crf 20 -maxrate 4000k -bufsize 8000k -g 30 -flvflags no_duration_filesize -f mpegts udp://127.0.0.1:8888
ffmpeg version N-82966-g6993bb4 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.4.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
  libavutil      55. 43.100 / 55. 43.100
  libavcodec     57. 70.100 / 57. 70.100
  libavformat    57. 61.100 / 57. 61.100
  libavdevice    57.  2.100 / 57.  2.100
  libavfilter     6. 68.100 /  6. 68.100
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
Input #0, rawvideo, from 'pipe:0':
  Duration: N/A, bitrate: 884736 kb/s
    Stream #0:0: Video: rawvideo (BGRA / 0x41524742), bgra, 1280x720, 884736 kb/s, 30 tbr, 30 tbn, 30 tbc
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, dshow, from 'audio=virtual-audio-capturer':
  Duration: N/A, bitrate: N/A
    Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Using -vsync 0 and -r can produce invalid output files
Codec AVOption crf (Select the quality for constant quality mode) specified for output file #0 (udp://127.0.0.1:8888) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
Output #0, mpegts, to 'udp://127.0.0.1:8888':
  Metadata:
    encoder         : Lavf57.61.100
    Stream #0:0: Video: h264 (h264_nvenc) (Main), yuv420p, 1280x720, q=-1--1, 2000 kb/s, 30 fps, 90k tbn, 30 tbc
    Metadata:
      encoder         : Lavc57.70.100 h264_nvenc
    Side data:
      cpb: bitrate max/min/avg: 4000000/0/2000000 buffer size: 8000000 vbv_delay: -1
    Stream #0:1: Audio: aac (LC), 48000 Hz, mono, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc57.70.100 aac
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_nvenc))
  Stream #1:0 -> #0:1 (pcm_s16le (native) -> aac (native))
frame=    0 fps=0.0 q=0.0 Lsize=       0kB time=00:00:00.00 bitrate=N/A speed=N/A

If anybody has an idea of what's happening. It could be great !

Thanks

njoyard commented 7 years ago

Yep, that's a known issue. fluent-ffmpeg incorrectly interprets such inputs as files. I've started working on it a while ago but I didn't have time to finish yet.

super-ienien commented 7 years ago

Great !!!!!!!!!!!!! I will look if i can do something to help you.

shaunmw commented 6 years ago

Hey,

Did the ability to pick up devices ever get added?

I see the link njoyard put to a fix that scans the device output of ffmpeg but it doesn't look like it has been tested or merged.

Is this simply a syntax in the command string? ffplay will happily accept -i 'device name' -f 'dshow'. However, ffmpeg doesn't seem to accept it unless it is -f 'dshow' -i 'device name'

nathanbabcock commented 3 years ago

@njoyard was DirectShow device support ever added to the input() command? Would a PR be welcomed for this feature if I am able to create one?

nathanbabcock commented 3 years ago

Apologies, I found the problem when I tried to do it manually with child_process.spawn. My original attempt looked like this:

ffmpeg()
  .input('video="Virtual Camera"')

However, the double quotes were actually what was causing the error (this forum post tipped me off). Removing the quotes fixed it, both for child_process and for fluent-ffmpeg:

ffmpeg()
  .input('video=Virtual Camera')

So I can now confirm that fluent-ffmpeg does indeed work with directshow device input in 2021! šŸŽ‰

nathanbabcock commented 3 years ago

@super-ienien this likely also solves your original issue from way back in 2017! šŸ˜œ

cgtarmenta commented 3 years ago

And for anyone that came further, looking for the syntaxis to add video and audio device with Directshow ...

ffmpeg()
  .input('video=Virtual Camera:audio=Virtual Mic')

Many thanks to @nathanbabcock šŸ™ŒšŸ»

dyexlzc commented 4 months ago

thank you, this works for me