DrKLO/Telegram · error
Error opening input file: %s\n
Error message
Error opening input file: %s\n
What it means
fopen(argv[argc-2], "r") on the input file returned NULL. The input file is expected to be a binary file containing length-prefixed Opus packets (4-byte big-endian length, 4-byte range-state, then payload bytes). A NULL return from fopen means the file does not exist, is not readable by the current user, or the path resolves to a directory.
Source
Thrown at TMessagesProj/jni/opus/src/repacketizer_demo.c:102
if(merge>48)
{
fprintf(stderr, "-merge parameter must be less than 48.\n");
return EXIT_FAILURE;
}
i++;
} else if (strcmp(argv[i], "-split")==0)
split = 1;
else
{
fprintf(stderr, "Unknown option: %s\n", argv[i]);
usage(argv[0]);
return EXIT_FAILURE;
}
}
fin = fopen(argv[argc-2], "r");
if(fin==NULL)
{
fprintf(stderr, "Error opening input file: %s\n", argv[argc-2]);
return EXIT_FAILURE;
}
fout = fopen(argv[argc-1], "w");
if(fout==NULL)
{
fprintf(stderr, "Error opening output file: %s\n", argv[argc-1]);
fclose(fin);
return EXIT_FAILURE;
}
rp = opus_repacketizer_create();
while (!eof)
{
int err;
int nb_packets=merge;
opus_repacketizer_init(rp);
for (i=0;i<nb_packets;i++)
{View on GitHub (pinned to 45ab8f4308)
Solutions
- Verify the input file exists and is readable: `ls -l <path>` or `test -r <path>`.
- Use an absolute path to avoid working-directory ambiguity.
- Quote paths containing spaces.
- Check that the file-generating step (e.g., opus_demo or a custom encoder) completed successfully before invoking repacketizer_demo.
Example fix
// before repacketizer_demo -merge 2 ./out/packets.oct /tmp/result.oct // after repacketizer_demo -merge 2 /abs/path/to/packets.oct /tmp/result.oct
Defensive patterns
Strategy: validation
Validate before calling
// Pre-check input file accessibility
#include <unistd.h>
if (access(argv[argc-2], R_OK) != 0) {
fprintf(stderr, "Input file not readable: %s\n", argv[argc-2]);
return EXIT_FAILURE;
} Prevention
- Use absolute paths for input files in scripts.
- Verify file existence with `test -f` or `access()` before invoking the tool.
- Check that the file-generating pipeline step succeeded.
When it happens
Trigger: Non-existent file path; permission denied (file owned by another user, no read permission); path is a directory; typo in filename; relative path resolved from the wrong working directory.
Common situations: Wrong working directory when using relative paths; file generated by a prior pipeline step that failed silently; NFS or mount issues; filename with spaces not properly quoted.
Related errors
- Error opening output file: %s\n
- Invalid payload length\n
- Error writing.\n
- %s: can't open %s
- %s: can't open %s\n
AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14).
Data as JSON: /api/errors/9eed3715588777f4.
Report an issue: GitHub.