Yalantis/uCrop · error · CImgIOException
load_yuv() : Missing data in file '%s'.
Error message
load_yuv() : Missing data in file '%s'.
What it means
load_yuv() reads frames until the end of the requested range or EOF; if after reading the list is still empty, no complete frame could be read at all. CImg throws CImgIOException indicating the file lacks the data for even one frame.
Source
Thrown at ucrop/src/main/jni/CImg.h:67286
break;
case 422 :
cimg_forXY(UV,x,y) {
const ucharT U = *(ptrs1++), V = *(ptrs2++);
*(ptrd1++) = U; *(ptrd1++) = U;
*(ptrd2++) = V; *(ptrd2++) = V;
}
break;
default :
YUV.draw_image(0,0,0,1,UV);
}
if (yuv2rgb) YUV.YCbCrtoRGB();
insert(YUV);
if (nstep_frame>1) cimg::fseek(nfile,(uint64T)(nstep_frame - 1)*(size_x*size_y + size_x*size_y/2),SEEK_CUR);
}
}
}
if (is_empty())
throw CImgIOException(_cimglist_instance
"load_yuv() : Missing data in file '%s'.",
cimglist_instance,
filename?filename:"(FILE*)");
if (stop_flag && nlast_frame!=~0U && frame!=nlast_frame)
cimg::warn(_cimglist_instance
"load_yuv(): Frame %d not reached since only %u frames were found in file '%s'.",
cimglist_instance,
nlast_frame,frame - 1,filename?filename:"(FILE*)");
if (!file) cimg::fclose(nfile);
return *this;
}
//! Load an image from a video file, using OpenCV library.
/**
\param filename Filename, as a C-string.
\param first_frame Index of the first frame to read.
\param last_frame Index of the last frame to read (can be higher than the actual number of frames, e.g. '~0U').View on GitHub (pinned to f788b534b4)
Solutions
- Check the file size is at least one frame (w*h*1.5 for 420, w*h*2 for 422, w*h*3 for 444) and re-obtain the file if truncated
- Verify size_x, size_y and chroma_subsampling match the stream exactly
- Start with range (0, ~0U) to test whether any frame is readable, then narrow the range
- Confirm the path points to the raw YUV data, not a container/metadata sidecar file
Example fix
// before
imgs.load_yuv("broken.yuv", 1920, 1080, 420, 0, 10); // file is 500 KB < 1 frame (3.1 MB)
// after
// re-export: ffmpeg -i in.mp4 -pix_fmt yuv420p -f rawvideo full.yuv
imgs.load_yuv("full.yuv", 1920, 1080, 420, 0, ~0U); Defensive patterns
Strategy: validation
Validate before calling
uint64_t frameSize = (uint64_t)w*h + 2*((uint64_t)(w/cfx)*(h/cfy));
if (fileSize(path) < frameSize) { /* file truncated/empty - abort or re-fetch */ } Try / catch
try { imgs.load_yuv(path, w, h, cs); }
catch (CImgIOException& e) { fprintf(stderr, "no readable frames (truncated/wrong format): %s\n", e.what()); } Prevention
- Check file size >= one frame before loading
- Verify checksums/sizes after transfers of raw video
- Keep dimensions+subsampling in a sidecar manifest and validate them against file size
When it happens
Trigger: load_yuv() on an empty or zero-byte file; a file smaller than one frame (size_x*size_y + chroma bytes); a first_frame..last_frame range whose data is absent (e.g. seeking near/past EOF but seek 'succeeds' at exact EOF); wrong dimensions/subsampling so the buffered read fails for every frame.
Common situations: Truncated or failed upload/download of the raw YUV file; misconfigured dimensions making one frame appear larger than the whole file; reading a still-recording/streaming file before data was flushed; pointing at a metadata or index file instead of the raw video.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- load_yuv(): File '%s' doesn't contain frame number %u.
- load_yuv(): Specified filename is (null).
- load_yuv(): Specified chroma subsampling %u is invalid, for
- load_yuv(): Specified dimensions (%u,%u) are invalid, for fi
- cimg::fopen(): Specified file path is (null).
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/2f064474a0f4e272.
Report an issue: GitHub.