ethaniel
Posts: 14
Joined: Sat Dec 16, 2017 9:26 am

ffmpeg usb microphone choppy/stuttering.

Thu Mar 29, 2018 3:26 pm

I use ffmpeg to broadcast a stream from an external encoder to youtube. I do not reencode the video (I use -vcodec copy), but I inject the audio from a USB microphone attached to the rpi3:

Code: Select all

ffmpeg -re -i http://192.168.13.11/0.flv \
  -thread_queue_size 50 \
  -f alsa -ac 1 -i hw:1 -acodec aac -ar 44100 -ab 128k -strict experimental \
  -vcodec copy \
  -map 0:v:0 -map 1:a:0 \
  -f flv rtmp://a.rtmp.youtube.com/live2/KEY
I've noticed that the audio is choppy, there is a stutter every second.
The live stream is here (it's live now):
https://www.youtube.com/watch?v=DpVqxBN6uW4

My load is normal:

Code: Select all

top - 22:27:07 up 6 min,  1 user,  load average: 0.57, 0.39, 0.18
Tasks: 113 total,   2 running,  70 sleeping,   0 stopped,   0 zombie
%Cpu(s): 11.5 us,  1.7 sy,  0.0 ni, 86.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :   766776 total,   552924 free,    64264 used,   149588 buff/cache
KiB Swap:   102396 total,   102396 free,        0 used.   633116 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
 1096 root      20   0  192088  36096  25444 R  47.1  4.7   1:12.25 ffmpeg
 
And there are no errors in the stream.

Perhaps someone have an idea how to fix this?
Thank you.

ethaniel
Posts: 14
Joined: Sat Dec 16, 2017 9:26 am

Re: ffmpeg usb microphone choppy/stuttering.

Thu Mar 29, 2018 7:26 pm

After looking around, I solved my own problem. And even removed some of the high pitches of the USB microphone.

Here's the command:

Code: Select all

rec -d -t wav - pitch -300 band 1.2k 1.5k | ffmpeg \
  -re -i http://192.168.13.2/0.flv \
  -thread_queue_size 50 \
  -ac 1 -i - -acodec aac -ar 44100 -ab 128k -strict experimental \
  -vcodec copy \
  -map 0:v:0 -map 1:a:0 \
  -f flv rtmp://a.rtmp.youtube.com/live2/KEY

Return to “Graphics, sound and multimedia”