DrKLO/Telegram · error
Error opening '%s'.\n
Error message
Error opening '%s'.\n
What it means
fopen(_argv[1], "rb") for the first input file (fin1) returned NULL. opus_compare cannot open the first .sw file for reading and exits before touching the second file.
Source
Thrown at TMessagesProj/jni/opus/src/opus_compare.c:221
rate=atoi(_argv[2]);
if(rate!=8000&&rate!=12000&&rate!=16000&&rate!=24000&&rate!=48000){
fprintf(stderr,
"Sampling rate must be 8000, 12000, 16000, 24000, or 48000\n");
return EXIT_FAILURE;
}
downsample=48000/rate;
switch(rate){
case 8000:ybands=13;break;
case 12000:ybands=15;break;
case 16000:ybands=17;break;
case 24000:ybands=19;break;
}
yfreqs=NFREQS/downsample;
_argv+=2;
}
fin1=fopen(_argv[1],"rb");
if(fin1==NULL){
fprintf(stderr,"Error opening '%s'.\n",_argv[1]);
return EXIT_FAILURE;
}
fin2=fopen(_argv[2],"rb");
if(fin2==NULL){
fprintf(stderr,"Error opening '%s'.\n",_argv[2]);
fclose(fin1);
return EXIT_FAILURE;
}
/*Read in the data and allocate scratch space.*/
xlength=read_pcm16(&x,fin1,2);
if(nchannels==1){
for(xi=0;xi<xlength;xi++)x[xi]=.5*(x[2*xi]+x[2*xi+1]);
}
fclose(fin1);
ylength=read_pcm16(&y,fin2,nchannels);
fclose(fin2);
if(xlength!=ylength*downsample){
fprintf(stderr,"Sample counts do not match (%lu!=%lu).\n",View on GitHub (pinned to 45ab8f4308)
Solutions
- Verify the first file path exists and is readable (access/stat).
- Use an absolute path.
- Make sure flags (-s, -r rate) come before the two file paths so _argv[1] lands on the actual file.
Example fix
// before ./opus_compare -r 48000 missing1.sw file2.sw // after ./opus_compare -r 48000 /abs/path/file1.sw file2.sw
Defensive patterns
Strategy: validation
Validate before calling
// Check the first file is readable before fopen.
if (access(_argv[1], R_OK) != 0) {
fprintf(stderr, "Error opening '%s'.\n", _argv[1]);
return EXIT_FAILURE;
} Prevention
- Use absolute paths for the first file.
- Put -s/-r flags before the files so _argv[1] is the real filename.
- Confirm the file exists with stat/access before running.
When it happens
Trigger: The first file path does not exist, is unreadable, or is a directory. After optional -s/-r parsing, _argv[1] is the first non-option argument (the first .sw file).
Common situations: Typo in filename; wrong working directory; file needs a permission not granted; the -s/-r flags consumed the real filename because of misordered arguments.
Related errors
- Could not open input file %s\n
- Could not open output file %s\n
- Usage: %s [-s] [-r rate2] <file1.sw> <file2.sw>\n
- Error reading yuv file\n
- Usage: test_opus_custom <rate> <channels> <frame size> <byt
AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14).
Data as JSON: /api/errors/09bccb6d7d10f172.
Report an issue: GitHub.