DrKLO/Telegram · error
Invalid path to YUV file!\n
Error message
Invalid path to YUV file!\n
What it means
yuvjpeg opens the YUV input via fopen(yuv_path, "r"). If fopen returns NULL it prints `Invalid path to YUV file!` and returns 1. This is an input-file open failure for the raw YUV source, independent of format checks that follow.
Source
Thrown at TMessagesProj/jni/mozjpeg/yuvjpeg.c:152
if (matches != 2) {
fprintf(stderr, "Invalid image size input!\n");
return 1;
}
if (luma_width <= 0 || luma_height <= 0) {
fprintf(stderr, "Invalid image size input!\n");
return 1;
}
chroma_width = (luma_width + 1) >> 1;
chroma_height = (luma_height + 1) >> 1;
/* Will check these for validity when opening via 'fopen'. */
yuv_path = argv[3];
jpg_path = argv[4];
yuv_fd = fopen(yuv_path, "r");
if (!yuv_fd) {
fprintf(stderr, "Invalid path to YUV file!\n");
return 1;
}
fseek(yuv_fd, 0, SEEK_END);
yuv_size = ftell(yuv_fd);
fseek(yuv_fd, 0, SEEK_SET);
/* Check that the file size matches 4:2:0 yuv. */
if (yuv_size !=
(size_t)luma_width*luma_height + 2*chroma_width*chroma_height) {
fclose(yuv_fd);
fprintf(stderr, "Unexpected input format!\n");
return 1;
}
yuv_buffer = malloc(yuv_size);
if (!yuv_buffer) {
fclose(yuv_fd);View on GitHub (pinned to 45ab8f4308)
Solutions
- Verify the YUV path is readable: `test -r <yuv_in>`.
- Use an absolute path and quote paths with spaces.
- Check permissions/SELinux context of the file.
- Confirm the file is a real raw YUV file, not a JPEG or container.
Example fix
// before yuvjpeg 90 512x512 frame.yuv out.jpg # frame.yuv missing // after yuvjpeg 90 512x512 /data/yuv/frame.yuv out.jpg
Defensive patterns
Strategy: validation
Validate before calling
#include <unistd.h>
/* YUV input must be readable */
if (access(yuv_path, R_OK) != 0) { /* report and do not invoke yuvjpeg */ } Prevention
- Check the YUV path is readable (test -r) before invoking.
- Use absolute, quoted paths.
- Confirm the file is raw YUV, not a JPEG/container.
When it happens
Trigger: Running `yuvjpeg <q> <size> <yuv_in> <jpg_out>` where <yuv_in> does not exist, is unreadable, or is not a regular file.
Common situations: Wrong path/extension, file on an unmounted volume, permission denied (common in the Android JNI/TMessagesProj context), or a path with spaces passed unquoted.
Related errors
- %s: can't open %s
- %s: can't open %s\n
- Required arguments:\n
- Invalid JPEG quality value!\n
- Invalid image size input!\n
AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14).
Data as JSON: /api/errors/87e38dd8febc122d.
Report an issue: GitHub.