[FFmpeg-user] RTMP stream from digital mic : interruptions

Yannick Barbeaux ybarbeaux at gmail.com
Mon May 17 17:35:20 EEST 2021


Hello
I capture the audio from a digital mic (ICS-43434-FX) connected on the GPIO
of a Raspberry Pi and send the signal through a RTMP stream to a RTMP
server (node-media-server) running on a computer directly connected to the
Raspberry :

$ ffmpeg -ar 48000 -acodec pcm_s32le -ac 2 -f alsa -i
dsnoop:CARD=sndrpii2scard,DEV=0 -f flv rtmp://$SERVER_IP/live/rpi

it is working fine BUT there are multiple very short (~30-40ms)
interruptions (silences) in the audio signal.
During one test, I had one interruption every 30 seconds but during other
tests, those silences were randomly distributed, sometimes they appear
after 5 minutes or more.

Note that I have to use the dsnoop (alsa) virtual device because if I use
anything else (default, hw, plughw, sysdefault) the following error repeats
every 3~4 seconds :

[alsa @ 0x1dc4210] ALSA buffer xrun

That cause glitches in the audio signal.
That is another problem I face.

Any idea of the cause of the problems described?

More info on this issue, output of commands:

pi at raspberrypi:~$ arecord -L
null
    Discard all samples (playback) or generate zero samples (capture)
default:CARD=sndrpii2scard
    snd_rpi_i2s_card, simple-card_codec_link snd-soc-dummy-dai-0
    Default Audio Device
sysdefault:CARD=sndrpii2scard
    snd_rpi_i2s_card, simple-card_codec_link snd-soc-dummy-dai-0
    Default Audio Device
dmix:CARD=sndrpii2scard,DEV=0
    snd_rpi_i2s_card, simple-card_codec_link snd-soc-dummy-dai-0
    Direct sample mixing device
dsnoop:CARD=sndrpii2scard,DEV=0
    snd_rpi_i2s_card, simple-card_codec_link snd-soc-dummy-dai-0
    Direct sample snooping device
hw:CARD=sndrpii2scard,DEV=0
    snd_rpi_i2s_card, simple-card_codec_link snd-soc-dummy-dai-0
    Direct hardware device without any conversions
plughw:CARD=sndrpii2scard,DEV=0
    snd_rpi_i2s_card, simple-card_codec_link snd-soc-dummy-dai-0
    Hardware device with all software conversions

pi at raspberrypi:~$ ffmpeg -ar 48000 -acodec pcm_s32le -ac 2 -f alsa -i
dsnoop  -f flv rtmp://10.1.6.1/live/rpi
ffmpeg version 4.1.6-1~deb10u1+rpt1 Copyright (c) 2000-2020 the FFmpeg
developers
  built with gcc 8 (Raspbian 8.3.0-6+rpi1)
[...]
  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
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, alsa, from 'dsnoop':
  Duration: N/A, start: 1621261820.437978, bitrate: 3072 kb/s
    Stream #0:0: Audio: pcm_s32le, 48000 Hz, stereo, s32, 3072 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_s32le (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
Output #0, flv, to 'rtmp://10.1.6.1/live/rpi':
  Metadata:
    encoder         : Lavf58.20.100
    Stream #0:0: Audio: mp3 (libmp3lame) ([2][0][0][0] / 0x0002), 48000 Hz,
stereo, s32p
    Metadata:
      encoder         : Lavc58.35.100 libmp3lame
[out_0_0 @ 0x11a5e30] 100 buffers queued in out_0_0, something may be wrong.
[libmp3lame @ 0x11994b0] Queue input is backward in time
[flv @ 0x1198220] Non-monotonous DTS in output stream 0:0; previous: 160,
current: 121; changing to 160. This may result in incorrect timestamps in
the output file.
[flv @ 0x1198220] Non-monotonous DTS in output stream 0:0; previous: 160,
current: 145; changing to 160. This may result in incorrect timestamps in
the output file.
size=     955kB time=00:00:58.63 bitrate= 133.4kbits/s speed=   1x

The "Non-monotonous DTS in output stream" warnings appear only at the
beginning of the stream so I don't think this is the cause of the problem.

Thanks.

Yannick


More information about the ffmpeg-user mailing list