2

I've been through many stackoverflow pages and forums trying to find the answer I want. I created a virtual microphone and I'm trying to pipe to it some wav sounds created using FFMPEG.

When I want to pipe a keyboard noise I pipe the sound to my virtual sound capture device like this:

ffmpeg -fflags +discardcorrupt -i <Keyboard sound Path> -f s16le -ar 44100 -ac 1 - > /tmp/gapFakeMic

And when I want to pipe some synthetized voice sound using Espeak to my virtual microphone, I do this:

espeak -vbrazil-mbrola-4 <some random text> --stdout | ffmpeg -fflags +discardcorrupt -i pipe:0 -f s16le -ar 44100 -ac 1 - > /tmp/gapFakeMic

The problem is my capture device doesn't record the sound like a normal recorder that still records even when there's no sound being transmited to it. So I'm trying to append the silence to the wav which is being created while my application is running. Always when I try to send the silence to buffer, FFMPEG returns the following response:

[NULL @ 0x5579f7921a00] Unable to find a suitable output format for 'pipe:'

FFMPEG is a powerful tool but its documentation lacks to be useful for newbies like me. So, I'd appreciate if anyone could answer this or at least give me any direction or some resource where I could find a way of achieving this.

EDIT:

Here's how I'm producing the silence to my virtual microphone:

ffmpeg -f lavfi -i anullsrc=channel_layout=mono:sample_rate=44100 -t <Time in seconds> - > /tmp/gapFakeMic

Here's the full log:

ffmpeg version 4.1.6-1~deb10u1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --prefix=/usr --extra-version='1~deb10u1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared

  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100

Input #0, lavfi, from 'anullsrc=channel_layout=mono:sample_rate=44100':
  Duration: N/A, start: 0.000000, bitrate: 352 kb/s
    Stream #0:0: Audio: pcm_u8, 44100 Hz, mono, u8, 352 kb/s

[NULL @ 0x560516626f40] Unable to find a suitable output format for 'pipe:'
pipe:: Invalid argument

EDIT 2:

After Gyan provided a solution in the comments the error above doesn't show anymore but my result audio is being broken and doesn't come out as expected. Now the command that generates and appends the silent audio is like this:

ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -t <Time in seconds> -f s16le - > /tmp/gapFakeMic

Edit 3:

I've made some changes to the command I'm using to pipe silence to the virtual mic. I think the pipe is breaking because of some incompatibility in audio formats. I hope I can find a solution in the next few days. After every little change I realize some improvements. Now I can hear the silence between the keys sounds but it isn't recording all the audios I'm passing to it. Here's how the command is now:

ffmpeg -f lavfi -i anullsrc=channel_layout=mono:sample_rate=44100 -t <Time in seconds> -f s16le -ar 44100 -ac 1 - > /home/icaroerasmo/gapFakeMic`

I also realized that when I pipe the sound to a pipe file created inside my home folder the audio quality improves.

Edit 4:

After all this struggle it's clear now that the named pipe is breaking in the second time it's called. I've already googled how to flush a named pipe but I didn't find anything that worked.

Ícaro Erasmo
  • 125
  • 1
  • 9

0 Answers0