Stream audio with pulseaudio

I use spotify now

So I have my music collection in my laptop hard drive, I wanna be able to play and control music everywhere.

For changing the current track, I use Emacs with emms and mpv, I don't have the need to use mpd to control to my music, I can just mosh to my machine and use emacsclient.

But how to hear the music? For me I use a solution based on pulseaudio and ffmpeg, it's a hack but it works for now.

The two machines are connected to a wireguard based VPN (did I mention how much I love wireguard?):

Sender part

So first I create a null sink called remote:

pactl load-module module-null-sink sink_name=remote

Then I stream audio using mp3lame codec to the other computer (btw data is pcms16le so if you want to transmit that good luck but that will need a lot of bandwidth)

(I don't have firewalls so this is easy)

ffmpeg -f pulse -i "remote.monitor" -acodec libmp3lame -ab 128k -ac 2 -f mp3 "udp://"

Then I change the output mpv to the new sink.

Receiver part

I just play the stuff using ffplay

ffplay -nodisp -ac 2 -bufsize 3000k -ab 128k -acodec mp3 -f mp3 -i "udp://localhost:1337"

Author: Mohamed Aziz Knani

Date: 2020-05-27 Wed 16:19

Emacs 25.2.2 (Org mode 9.3.6)


hacker emblem