Yalantis/uCrop · warning
load_yuv(): Frame not reached since only %u frames were…
Error message
load_yuv(): Frame %d not reached since only %u frames were found in file '%s'.
What it means
CImgList<T>::load_yuv() warns when the requested frame number could not be reached because the raw YUV file contained fewer frames than requested. The load returns whatever frames were found instead of the full requested range, so downstream code operating on the expected frame count will misbehave.
Solutions
- Compute expected frame count from file size and image dimensions before loading, and clamp nlast_frame
- Verify the file is complete (re-download/re-copy if truncated)
- Double-check the width/height/chroma-subsampling arguments; wrong values change the frames-per-file calculation
- Check the returned list size after load and handle the short read instead of assuming N frames
Example fix
// before
frames.load_yuv("clip.yuv", 0, 99);
// after
frames.load_yuv("clip.yuv", 0, 99);
if (frames.size() < 100) {
// only frames.size() frames were actually available
} Defensive patterns
Strategy: validation
Validate before calling
long framesAvail = cimg::fsize(filename) / bytesPerFrame(w,h,chroma); unsigned last = std::min(99u, (unsigned)std::max(0L, framesAvail - 1)); frames.load_yuv(filename, 0, last);
Prevention
- Compute frame count from file size and dimensions before loading
- Verify file integrity (no truncation) before load
- Check list.size() after load instead of assuming requested frames
When it happens
Trigger: Calling load_yuv(filename, nlast_frame=N) (or first/step variants) on a file whose size in bytes yields fewer than N+1 frames for the given width/height/chroma subsampling; requesting frame N with stop_flag set from a truncated or mis-sized file.
Common situations: Truncated or incompletely transferred .y4m/.yuv raw files; wrong width/height/chroma parameters so the computed frame count is smaller than expected; concatenating clips and assuming frame counts.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- cimg::fread(): Only %lu/%lu elements could be read from…
- load_analyze(): Cannot read header (of size %u) in file
- load_ffmpeg_external(): Failed to open file
- load_ffmpeg_external(): Specified filename is (null) or…
- load_jpeg(): Incomplete data in file
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/df6e75fe80fc44e9.
Report an issue: GitHub.
Appendix: source
Thrown at ucrop/src/main/jni/CImg.h:67291
*(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').
\param step_frame Step value for frame reading.
\note If step_frame==0, the current video stream is forced to be released (without any frames read).
**/
CImgList<T>& load_video(const char *const filename,
const unsigned int first_frame=0, const unsigned int last_frame=~0U,View on GitHub (pinned to f788b534b4)