Pregunta

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
¿Fue útil?

Solución

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".

Otros consejos

Opus by default attempts to make the best decision possible based on the current bitrate. The decision is made on the following table (20 ms frame size):

  • 8-12 kbit/s for NB speech,
  • 16-20 kbit/s for WB speech,
  • 28-40 kbit/s for FB speech,
  • 48-64 kbit/s for FB mono music, and
  • 64-128 kbit/s for FB stereo music.

This is because opus assume that, if the bitrate is too low, it cannot encode stereo with sufficient quality.

Actually the documentation says that it is possible to change the number of channels BUT it doesn't explain how. I'll take a look later anyway on how to do this.

You can find these informations on rfc6716

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top