Skip to content

Instantly share code, notes, and snippets.

@jan4984
Last active October 18, 2021 21:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jan4984/f1919b163346cda63809bbbb72298e98 to your computer and use it in GitHub Desktop.
Save jan4984/f1919b163346cda63809bbbb72298e98 to your computer and use it in GitHub Desktop.
audio over tcp with pulseaudio and ffmpeg

linux(WSL)

  • 永久启用pulseaudio

/etc/pulse/client.conf

autospawn = yes

/etc/pulse/daemon.conf

exit-idle-time = -1
  • 配置网络端口和音频格式

外部通过网卡从172.21.202.184:13333读即能拿到linux播放的内容音频,往172.202.184:13333写就能模拟linux录音的音频。

/etc/pulse/default.pa:

load-module module-simple-protocol-tcp record=true playback=true rate=16000 format=s16le channels=1 port=13333 listen=172.21.202.184
  • 启动
pulseaudio --start

windows

  • 启动录音
ffmpeg -list_devices true -f dshow -i dummy
ffmpeg -f dshow -i audio="@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave_{A25C4F73-B8E6-441F-B4EC-4021BFA88535}" -ac 1 -ar 16000 -f s16le tcp://172.21.202.184:13333
  • 启动播放
ffplay -ac 1 -ar 16000 -f s16le tcp://172.21.202.184:13333
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment