DrKLO/Telegram · warning

Usage: test_opus_custom <rate> <channels> <frame size> <byt

Error message

Usage: test_opus_custom <rate> <channels> <frame size>  <bytes per packet> [<complexity> [packet loss rate]] <input> <output>\n

What it means

Usage message from the opus_custom demo CLI. Printed when argc is not 7, 8, or 9 — i.e. the wrong number of command-line arguments. The expected form is: test_opus_custom <rate> <channels> <frame size> <bytes per packet> [<complexity> [packet loss rate]] <input> <output>.

Source

Thrown at TMessagesProj/jni/opus/celt/opus_custom_demo.c:64

   FILE *fin, *fout;
   OpusCustomMode *mode=NULL;
   OpusCustomEncoder *enc;
   OpusCustomDecoder *dec;
   int len;
   opus_int32 frame_size, channels, rate;
   int bytes_per_packet;
   unsigned char data[MAX_PACKET];
   int complexity;
#if !(defined (FIXED_POINT) && !defined(CUSTOM_MODES)) && defined(RESYNTH)
   int i;
   double rmsd = 0;
#endif
   int count = 0;
   opus_int32 skip;
   opus_int16 *in, *out;
   if (argc != 9 && argc != 8 && argc != 7)
   {
      fprintf (stderr, "Usage: test_opus_custom <rate> <channels> <frame size> "
               " <bytes per packet> [<complexity> [packet loss rate]] "
               "<input> <output>\n");
      return 1;
   }

   rate = (opus_int32)atol(argv[1]);
   channels = atoi(argv[2]);
   frame_size = atoi(argv[3]);
   mode = opus_custom_mode_create(rate, frame_size, NULL);
   if (mode == NULL)
   {
      fprintf(stderr, "failed to create a mode\n");
      return 1;
   }

   bytes_per_packet = atoi(argv[4]);
   if (bytes_per_packet < 0 || bytes_per_packet > MAX_PACKET)
   {

View on GitHub (pinned to 45ab8f4308)

Solutions

  1. Count arguments: provide exactly 7 (mandatory only), 8 (+complexity), or 9 (+complexity and packet loss rate).
  2. Ensure input and output file paths are the last two arguments.
  3. Quote shell variables so empty values don't reduce argc.

Example fix

// before
./test_opus_custom 48000 1 960 input.sw

// after (7 mandatory args: rate channels frame_size bytes_per_packet input output)
./test_opus_custom 48000 1 960 40 input.sw output.sw
Defensive patterns

Strategy: validation

Validate before calling

// Validate argc before using any argv slot.
if (argc != 7 && argc != 8 && argc != 9) {
    fprintf(stderr, "Usage: test_opus_custom <rate> <channels> <frame size>"
            " <bytes per packet> [<complexity> [packet loss rate]] <input> <output>\n");
    return 1;
}

Prevention

When it happens

Trigger: Invoking the demo binary with fewer than 7 or more than 9 arguments. The two trailing positional args are always input and output files; the optional bracketed ones are complexity (argv[5]) and packet loss rate (argv[argc-3]).

Common situations: Missing the output file path; forgetting the bytes-per-packet argument; copy-pasting a command from a different opus tool's syntax; running the demo in a script with an unquoted empty variable that collapses argument count.

Related errors


AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14). Data as JSON: /api/errors/e1e366d05c843341. Report an issue: GitHub.