Skip to content

Instantly share code, notes, and snippets.

@Vigrond
Last active February 12, 2021 09:59
Show Gist options
  • Save Vigrond/074e9fabb44f1ece56fa73fab25808bd to your computer and use it in GitHub Desktop.
Save Vigrond/074e9fabb44f1ece56fa73fab25808bd to your computer and use it in GitHub Desktop.
Simple ffmpeg desktop audio sharing for Ubuntu
In this example, the client is Ubuntu, and the server is Windows. ffmpeg will need to be installed on both. Other scenarios will need a different command and understanding of ffmpeg.
On the "client", run the ffmpeg command:
`ffmpeg -re -f alsa -ac 2 -i default -fflags +genpts -vn -c:a pcm_s16be -sdp_file ~/sdp_stream.sdp -f rtp rtp://server:1234`
Where `server` is your barrier server IP address. This will stream desktop audio to the specified address
(If you use pulse instead of alsa, replace `-f alsa` with `-f pulse` )
It will output sdp_stream.sdp
```
SDP:
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 192.168.1.82
t=0 0
a=tool:libavformat 58.29.100
m=audio 1234 RTP/AVP 97
b=AS:1536
a=rtpmap:97 L16/48000/2
```
In my example the server is `192.168.1.82`
On the server machine (`192.168.1.82`), copy the SDP text above into a file `sdp_stream.sdp` and run the ffplay command:
`./ffplay -protocol_whitelist 'rtp,file,udp' .\sdp_stream.sdp`
Enjoy streamed uncompressed audio
for compressed, replace `-c:a pcm_s16b` with `-c:a libvorbis`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment