6

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.

Tomasz Bawor
  • 1,447
  • 15
  • 40
  • You've already done the work... you have the codec right there... just decode and play. What specifically are you asking? – Brad May 08 '17 at 23:19
  • I am looking for a way to listen to encoded bytes. I do not want to wrap it in some files. Just want to push the bytes into a file and use some tool (that I am not aware of) to listen to it. – Tomasz Bawor May 09 '17 at 09:12
  • Some tool like VLC? Or, in your application? – Brad May 09 '17 at 17:47
  • Tool like VLC or Audacity. I am able to listen to raw in Audacity by opening file and passing stream parameteres. I am unable to do that in opus. – Tomasz Bawor May 10 '17 at 07:43

1 Answers1

3

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>
onkkno
  • 655
  • 6
  • 16
  • Thank you, I will definitely try this! – Tomasz Bawor May 10 '17 at 13:00
  • @TomaszBawor I have the same requirement as yours & tried the same as mentioned above. Say (opusdec.exe --force-wav OpusEncoded.opus - | "%PROGRAMFILES%\VideoLAN\VLC\vlc" Decoding complete. This doesn't look like a Opus file). Getting this outcome. Am I missing something? Any help would be appreciated. – Arjun Natarajan Sep 22 '22 at 11:33