0

How do I stream a lossless audio signal with 192000kHz over a UDP connection?

I want to stream 192kHz signals sampled on a raspberry 4 (hifiberry shield) over the connected network via UTP. Ideally, as raw bytes, because I'm running a custom program, which reads the raw input steam and then processes it afterwards. To test the Pi part I've tried to save the data on the PC with ffmpeg as wav file, but I have problems with it.

On the Pi I'm runnung: ffmpeg -f alsa -acodec pcm_s32le -ar 192000 -i hw:3 -f s32le -ar 192000 -acodec pcm_s32le udp://192.168.0.10:9999

With Wireshark I can see, that packages are sent over UDP. On the PC I'm running: ffmpeg -i udp://192.168.0.10:9999 -f s32le -bitexact -acodec pcm_s32le -ar 192000 "test.wav" but this only resulsts in an error message: Invalid data found when processing input.

What I tried before was to use mpegts instead s32le, but this seems only to be usable with a samplerate up to 48kHz.

Is there a way to stream raw 192kHz audio stream over UDP? And contains the stream some form of header, that I need to consider, when extracting and converting the received bytes into 32bit floats?

3
  • 192kHz 32-bit float is about 1.5MB/s, 12000kb/s Are you really sure that's what you need? What's your source material?
    – Tetsujin
    Commented Nov 6, 2022 at 15:12
  • Hi @Tetsujin, yeah, my goal is to have a system with distributed sensors, that broadcast their signals to a central (more powerful) pc, which can process the data in real time. Unfortunately, the signals aren't speech, but rather in a frequency range of about 50kHz, so we need the full 192kHz samplerate. Wifi was my favourite choice because I thought it was pretty easy to set up and I hoped the data rates would be sufficient.
    – kaulauer
    Commented Nov 6, 2022 at 16:45
  • Ah, OK. Ultrasonics are well outside my field [I'm a music sound engineer.] Maybe 24-bit would bring it down far enough? s24le [sorry, I said float before, but it was 32-bit signed, my bad]
    – Tetsujin
    Commented Nov 6, 2022 at 16:50

1 Answer 1

0

I've found an answer to the question. Problem was, that the sampling at 192kHz with the hifiberry over ffmpeg had issues with frame losses. This might be caused by a too small buffer, but ffmpeg doesn't let you configure the alsa buffer. At least I didn't know how.

The solution is to use arecord to sample the data and pipe it directly into ffmpeg to stream it over udp. Credits to this question where I modified the given code. For my application it results into: arecord -f S32_LE -r192000 -c2 -D hw:0 | ffmpeg -report -acodec pcm_s32le -i - -f f32le -ar 192000 -ac 2 -acodec pcm_f32le -flush_packets 0 udp://192.168.0.10:9999?pkt_size=4096

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .