{"record":{"id":"df6e75fe80fc44e9","repo":"Yalantis/uCrop","slug":"load-yuv-frame-d-not-reached-since-only-u-fra","errorCode":null,"errorMessage":"load_yuv(): Frame %d not reached since only %u frames were found in file '%s'.","messagePattern":"load_yuv\\(\\): Frame (.+?) not reached since only %u frames were found in file '(.+?)'\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":67291,"sourceCode":"                *(ptrd2++) = V; *(ptrd2++) = V;\n              }\n              break;\n            default :\n              YUV.draw_image(0,0,0,1,UV);\n            }\n            if (yuv2rgb) YUV.YCbCrtoRGB();\n            insert(YUV);\n            if (nstep_frame>1) cimg::fseek(nfile,(uint64T)(nstep_frame - 1)*(size_x*size_y + size_x*size_y/2),SEEK_CUR);\n          }\n        }\n      }\n      if (is_empty())\n        throw CImgIOException(_cimglist_instance\n                              \"load_yuv() : Missing data in file '%s'.\",\n                              cimglist_instance,\n                              filename?filename:\"(FILE*)\");\n      if (stop_flag && nlast_frame!=~0U && frame!=nlast_frame)\n        cimg::warn(_cimglist_instance\n                   \"load_yuv(): Frame %d not reached since only %u frames were found in file '%s'.\",\n                   cimglist_instance,\n                   nlast_frame,frame - 1,filename?filename:\"(FILE*)\");\n\n      if (!file) cimg::fclose(nfile);\n      return *this;\n    }\n\n    //! Load an image from a video file, using OpenCV library.\n    /**\n      \\param filename Filename, as a C-string.\n      \\param first_frame Index of the first frame to read.\n      \\param last_frame Index of the last frame to read (can be higher than the actual number of frames, e.g. '~0U').\n      \\param step_frame Step value for frame reading.\n      \\note If step_frame==0, the current video stream is forced to be released (without any frames read).\n    **/\n    CImgList<T>& load_video(const char *const filename,\n                            const unsigned int first_frame=0, const unsigned int last_frame=~0U,","sourceCodeStart":67273,"sourceCodeEnd":67309,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L67273-L67309","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nframes.load_yuv(\"clip.yuv\", 0, 99);\n// after\nframes.load_yuv(\"clip.yuv\", 0, 99);\nif (frames.size() < 100) {\n  // only frames.size() frames were actually available\n}","handlingStrategy":"validation","validationCode":"long framesAvail = cimg::fsize(filename) / bytesPerFrame(w,h,chroma);\nunsigned last = std::min(99u, (unsigned)std::max(0L, framesAvail - 1));\nframes.load_yuv(filename, 0, last);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["cimg","video","truncated-file","yuv"],"backgroundTag":"file-read-failed","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}