I'm trying to produce low bitrate opus files with L/R stereo. What decides if opusenc
will use L/R stereo instead of joint stereo? Is there are flag I can pass? Is it related to bitrate?
opusenc input.wav output.opus //produces L/R stereo
opusenc input.wav output.opus --bitrate 8 //produces joint stereo
It looks like it is determined here:
if (st->force_channels!=OPUS_AUTO && st->channels == 2)
{
st->stream_channels = st->force_channels;
} else {
#ifdef FUZZING
/* Random mono/stereo decision */
if (st->channels == 2 && (rand()&0x1F)==0)
st->stream_channels = 3-st->stream_channels;
#else
/* Rate-dependent mono-stereo decision */
if (st->channels == 2)
{
opus_int32 stereo_threshold;
stereo_threshold = stereo_music_threshold + ((voice_est*voice_est*(stereo_voice_threshold-stereo_music_threshold))>>14);
if (st->stream_channels == 2)
stereo_threshold -= 4000;
else
stereo_threshold += 4000;
st->stream_channels = (equiv_rate > stereo_threshold) ? 2 : 1;
} else {
st->stream_channels = st->channels;
}
#endif
}
Just breifly reading through the opusenc source code, it looks like setting force_channels
to 2 on the struct OpusEncoder
will make it work. However, looking through the opusenc.c source code, no where is that field set. You could easily modify the source however to always force channels to be two. For the future, it looks like opus calls it "dual stereo" rather than "L/R stereo".