DrKLO/Telegram · error
Failed to create the decoder: %s\n
Error message
Failed to create the decoder: %s\n
What it means
opus_custom_decoder_create(mode, channels, &err) set err non-zero — the decoder object could not be created. The encoder was created successfully and is implicitly leaked here (no opus_custom_encoder_destroy on this error path). Both file handles are closed.
Source
Thrown at TMessagesProj/jni/opus/celt/opus_custom_demo.c:115
if (!fout)
{
fprintf (stderr, "Could not open output file %s\n", argv[argc-1]);
fclose(fin);
return 1;
}
enc = opus_custom_encoder_create(mode, channels, &err);
if (err != 0)
{
fprintf(stderr, "Failed to create the encoder: %s\n", opus_strerror(err));
fclose(fin);
fclose(fout);
return 1;
}
dec = opus_custom_decoder_create(mode, channels, &err);
if (err != 0)
{
fprintf(stderr, "Failed to create the decoder: %s\n", opus_strerror(err));
fclose(fin);
fclose(fout);
return 1;
}
opus_custom_decoder_ctl(dec, OPUS_GET_LOOKAHEAD(&skip));
if (argc>7)
{
complexity=atoi(argv[5]);
opus_custom_encoder_ctl(enc,OPUS_SET_COMPLEXITY(complexity));
}
in = (opus_int16*)malloc(frame_size*channels*sizeof(opus_int16));
out = (opus_int16*)malloc(frame_size*channels*sizeof(opus_int16));
while (!feof(fin))
{
int ret;View on GitHub (pinned to 45ab8f4308)
Solutions
- Validate channels is 1 or 2 and matches what was used for the encoder.
- Inspect opus_strerror(err) for the concrete cause.
- Destroy the encoder (opus_custom_encoder_destroy(enc)) on this path to avoid a leak.
- Ensure adequate free memory for the decoder allocation.
Example fix
// before
dec = opus_custom_decoder_create(mode, channels, &err);
if (err != 0) { fprintf(stderr, "Failed to create the decoder: %s\n", opus_strerror(err)); fclose(fin); fclose(fout); return 1; }
// after: also free the encoder
dec = opus_custom_decoder_create(mode, channels, &err);
if (err != 0) { fprintf(stderr, "Failed to create the decoder: %s\n", opus_strerror(err)); opus_custom_encoder_destroy(enc); fclose(fin); fclose(fout); return 1; } Defensive patterns
Strategy: validation
Validate before calling
// Validate channels and destroy the encoder on failure.
if (channels != 1 && channels != 2) { fprintf(stderr, "channels must be 1 or 2\n"); return 1; }
dec = opus_custom_decoder_create(mode, channels, &err);
if (err != 0) { opus_custom_encoder_destroy(enc); fprintf(stderr, "Failed to create the decoder: %s\n", opus_strerror(err)); fclose(fin); fclose(fout); return 1; } Prevention
- Use the same channels value as the encoder.
- Call opus_custom_encoder_destroy(enc) on this error path to avoid a leak.
- Inspect opus_strerror(err) for the concrete cause.
When it happens
Trigger: err != OPUS_OK. Same shape as the encoder error: OPUS_BAD_ARG for invalid channels, or allocation failure. channels must match the encoder's channel count for the round-trip demo to be valid.
Common situations: channels mismatch with the mode; channels value 0 or >2 from a bad CLI arg; memory pressure; the mode parameters being incompatible with decoder construction.
Related errors
- Failed to create the encoder: %s\n
- opus_custom_decode() failed: %s\n
- Opus decoder does not support secure decode
- Invalid initialization data size
- Invalid pre-skip or seek pre-roll
AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14).
Data as JSON: /api/errors/62e471b577557d9a.
Report an issue: GitHub.