[FFmpeg-user] Stream microphone to speakers

Matteo Contrini matteo at contrini.it
Tue Aug 11 10:40:51 EEST 2020

On Fri, 7 Aug 2020, at 4:59 AM, Vi Rak wrote:
> Dear gentle experts,
> I'm working on the Karaoke project for both Android and iOS where a user
> could record their performances (their video and vocal) and I use FFmpeg
> for mixing music with their recordings. Anyway, I wish I could route/pipe
> user vocal at realtime (capture thru device microphone) to an output device
> (speaker) so the user could hear their voice at realtime applied with some
> level of echo (to produce an effect as if we were in classic karaoke room).
> Over weeks I have been struggling with searching the ways to implement that
> based on FFmpeg, but no luck. Please kindly help.
> Many thanks in advance.
> Virak

On Android, what you can do is create a Linux named pipe using a native library (which calls `mkfifo` and `fcntl`), then capture the raw audio samples with `AudioRecord`, and write them to the pipe. When you spawn ffmpeg you can pass the pipe path as the input, making sure to choose the correct audio input format (like s16le). I've done this in the past for video streaming so it should work for audio as well.


More information about the ffmpeg-user mailing list