Skip to content

Instantly share code, notes, and snippets.

@porjo
Last active March 28, 2024 21:01
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save porjo/5cce51d80b349b984d5e8c1c95066c1a to your computer and use it in GitHub Desktop.
Save porjo/5cce51d80b349b984d5e8c1c95066c1a to your computer and use it in GitHub Desktop.
Use Pulseaudio to stream audio file to network via RTP

RTP Server

Setup

pacmd load-module module-null-sink sink_name=rtp format=s16le channels=1 rate=16000
pacmd load-module module-rtp-send source=rtp.monitor

This sets up a multicast socket for RTP streams. When I tested this was 224.0.0.56:46136

Play + Listen to Audio

Pipe Audio File to RTP sink:

sox -e signed-integer -b 16 -r 16000 -c 1 <input filename> -t pulseaudio rtp

Receive Audio From RTP sink monitor:

parec -d rtp.monitor --rate=16000 --channels=1 | aplay -t raw -f S16_LE -r 16000

(for some reason using sox for playback I was getting glitchy audio with buffer underruns)

Diagnostics

Stop pulseaudio running

systemctl --user stop pulseaudio.socket
systemctl --user stop pulseaudio.service

Start in forground with debug output:

pulseaudio -vvvvv

RTP Client

TODO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment