{"record":{"id":"a150f6e583424911","repo":"DrKLO/Telegram","slug":"could-not-open-input-file-s-n","errorCode":null,"errorMessage":"Could not open input file %s\\n","messagePattern":"Could not open input file (.+?)\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"TMessagesProj/jni/opus/celt/opus_custom_demo.c","lineNumber":92,"sourceCode":"   if (mode == NULL)\n   {\n      fprintf(stderr, \"failed to create a mode\\n\");\n      return 1;\n   }\n\n   bytes_per_packet = atoi(argv[4]);\n   if (bytes_per_packet < 0 || bytes_per_packet > MAX_PACKET)\n   {\n      fprintf (stderr, \"bytes per packet must be between 0 and %d\\n\",\n                        MAX_PACKET);\n      return 1;\n   }\n\n   inFile = argv[argc-2];\n   fin = fopen(inFile, \"rb\");\n   if (!fin)\n   {\n      fprintf (stderr, \"Could not open input file %s\\n\", argv[argc-2]);\n      return 1;\n   }\n   outFile = argv[argc-1];\n   fout = fopen(outFile, \"wb+\");\n   if (!fout)\n   {\n      fprintf (stderr, \"Could not open output file %s\\n\", argv[argc-1]);\n      fclose(fin);\n      return 1;\n   }\n\n   enc = opus_custom_encoder_create(mode, channels, &err);\n   if (err != 0)\n   {\n      fprintf(stderr, \"Failed to create the encoder: %s\\n\", opus_strerror(err));\n      fclose(fin);\n      fclose(fout);\n      return 1;","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/jni/opus/celt/opus_custom_demo.c#L74-L110","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":"// before\n./test_opus_custom 48000 1 960 40 wrong_input_filename.sw output.sw\n\n// after\n./test_opus_custom 48000 1 960 40 /abs/path/input.sw output.sw","handlingStrategy":"validation","validationCode":"// Verify the input file exists and is readable before fopen.\nif (access(inFile, R_OK) != 0) {\n    fprintf(stderr, \"Input file not readable: %s\\n\", inFile);\n    return 1;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["io","file-read","opus","demo","cli","c"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}