Search code examples
virtualboxubuntu-14.04vlccodecopus

Convert PCM file decoded with opus_demo to WAV


I downloaded the Opus codec from their git repo, ran ./autogen.sh, ./configure, make, and then encoded a sample file from the opus examples page with ./opus_demo -e voip 48000 1 8000 -cbr -bandwidth NB -complexity 0 -forcemono speech_orig.wav speech_encoded.bit.

I then tried to decode it with ./opus_demo -d 48000 1 speech_encoded.bit speech_48khz.wav. When I try to play it back with VLC, it doesn't play it (it shows as playing for less than a second with no sound/feedback).

I am running Ubuntu 14.04 32-bit on a virtual machine (VirtualBox). The only link I found that was even remotely related to my problem is this, which relates to something else than the opus_demo file.

This is the output from opus_demo shell commands:

$ ./opus_demo -e voip 48000 1 8000 -cbr -bandwidth NB -complexity 0 -forcemono speech_orig.wav speech_encoded.bit
libopus 1.1.1-beta-38-gfc0276f
Encoding 48000 Hz input at 8.000 kb/s in narrowband with 960-sample frames.
average bitrate:               8.000 kb/s
maximum bitrate:               8.000 kb/s
active bitrate:                8.000 kb/s
bitrate standard deviation:    0.000 kb/s
$ ./opus_demo -d 48000 1 speech_encoded.bit  speech_48khz.wav
libopus 1.1.1-beta-38-gfc0276f
Decoding with 48000 Hz output (1 channels)
average bitrate:               8.000 kb/s
maximum bitrate:               8.000 kb/s
bitrate standard deviation:    0.000 kb/s

Thanks in advance for any help!


Solution

  • Solved it! Posting what I did for future readers, in case someone has the same problem.

    The problem was that the files I was passing into the encoder (opus_demo -e) were .wav files. The encoder strictly requires .pcm files, and the decoder strictly outputs .pcm files. In order to convert .wav files to .pcm files, I downloaded ffmpeg for windows, and ran the following commands:

    To convert a .wav file into a .pcm file:

    ffmpeg -i input.wav -f s16le -acodec output.pcm

    To convert a .pcm file into a .wav file:

    ffmpeg -f s16le -ar 48k -ac 1 -i input.pcm output.wav