DrKLO/Telegram · error
Could not open input file %s\n
Error message
Could not open input file %s\n
What it means
fopen(inFile, "rb") returned NULL — the input PCM (.sw) file cannot be opened for reading. inFile is argv[argc-2], the second-to-last argument. The demo exits with return 1.
Source
Thrown at TMessagesProj/jni/opus/celt/opus_custom_demo.c:92
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)
{
fprintf (stderr, "bytes per packet must be between 0 and %d\n",
MAX_PACKET);
return 1;
}
inFile = argv[argc-2];
fin = fopen(inFile, "rb");
if (!fin)
{
fprintf (stderr, "Could not open input file %s\n", argv[argc-2]);
return 1;
}
outFile = argv[argc-1];
fout = fopen(outFile, "wb+");
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;View on GitHub (pinned to 45ab8f4308)
Solutions
- Verify the input file exists and is readable: check argv[argc-2], run stat/access on it.
- Use an absolute path to avoid working-directory confusion.
- Confirm argument order: input is the second-to-last arg, output is the last.
- Ensure the file is raw PCM16 .sw, not a .wav with a header (which would misalign samples).
Example fix
// before ./test_opus_custom 48000 1 960 40 wrong_input_filename.sw output.sw // after ./test_opus_custom 48000 1 960 40 /abs/path/input.sw output.sw
Defensive patterns
Strategy: validation
Validate before calling
// Verify the input file exists and is readable before fopen.
if (access(inFile, R_OK) != 0) {
fprintf(stderr, "Input file not readable: %s\n", inFile);
return 1;
} Prevention
- Use absolute paths to avoid working-directory issues.
- Confirm input is raw PCM16 .sw with no WAV header.
- Remember input is the second-to-last argument.
When it happens
Trigger: The input path does not exist, is not readable, or points to a directory. The file is expected to be raw little-endian 16-bit PCM (no header) of frame_size*channels samples per frame.
Common situations: Typo in the input filename; wrong working directory so the relative path misses; the file is on a path that needs a permission not granted; passing an output-first argument order.
Related errors
- Could not open output file %s\n
- Error opening '%s'.\n
- Usage: test_opus_custom <rate> <channels> <frame size> <byt
- Error reading yuv file\n
- Usage: %s [-s] [-r rate2] <file1.sw> <file2.sw>\n
AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14).
Data as JSON: /api/errors/a150f6e583424911.
Report an issue: GitHub.