Linux ALSA capture device sharing

To split audio input device stream use dsnoop plugin from ALSA. Be sure to access dsnoop device simultanously, not dsnoop and physical device! This feature is not documented officially!

http://www.alsa-project.org/main/index.php/Asoundrc
http://jugglingcode.tumblr.com/post/106510471024/alsa-setting-up-dsnoop

FFMPEG dos not work with dsnoop device (official remark in source code). Use arecord and plain LAME codec instead.

Trying to use snoop device us pointless in case of BeagleBoneBlack. Suprisingly, two arecord instances are able to work with dsnoop device. But VLC or FFMPEG does not work, being unable to open device.

Working solution is going higher in software stack using shell and tee to named pipe.


!/bin/sh
/bin/su user -c "mkfifo `pwd`/myfifo"
/bin/su user -c "arecord -D hw:1,0 -f cd -t wav -c 1 | tee myfifo | lame -x -r - | mp3splt -f -t 30.0 m-" &
/bin/su root -c "killall vlca"
/bin/su user -c "vlca -vvv -I "dummy" stream://`pwd`/myfifo vlc://quit --sout \"#transcode{acodec=flac,ab=32}:standard{access=http,mux=ogg,dst=:8082}\"" &

Data flow is as follows:

– arecord processes raw microphone input into wav
– wav is being copied to a named pipe
– wav is being encoded by LAME
– LAME output is MP3
– MP3 will be splitted if size (duration) is greater than X
– named pipe is read by VLC via stream muxer and transcoded to FLAC over OGG container streamed via HTTP

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s