Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Listening to OPUS encoded stream

Currently, I am working on an application that is taking a stream of audio (RAW encoded bytes) and is applying some transformations to it (resampling, converting stereo to mono etc..). I have implemented encoding raw bytes using opus codec thanks to JNI but I have a little problem:

Is there a way to listen to opus encoded stream saved to a file? I am aware that if I add some file headers and do some additional operations I should be able to save it as OGG file, but I do not want to waste time implementing functionality just to listen audio in the test.

Ideally, I would like to find a tool that would be able to play such stream, like audacity is playing RAW (after adding encoding parameters of course).

Thank you.

like image 740
Tomasz Bawor Avatar asked Oct 18 '22 12:10

Tomasz Bawor


1 Answers

Did you try the opusdec utility from the OPUS tools package?

This utility should allow you to take opus stream and play it out as PCM encoded wav file which you should be able to pipe to a command-line .wav player and listen to it. No need for any implementation, just a shell command executed via Runtime.Exec(), Should do it

e.g. For a system with pulseaudio installed

yourstream.opus | padsp opusdec -

if no pulseaudio any wav player can use the wav stream output and play it. For e.g.

opusdec --force-wav yourinput.opus - | <YOUR WAV Stream Accepting Player>
like image 128
onkkno Avatar answered Oct 21 '22 03:10

onkkno