{"record":{"id":"2f064474a0f4e272","repo":"Yalantis/uCrop","slug":"load-yuv-missing-data-in-file-s","errorCode":null,"errorMessage":"load_yuv() : Missing data in file '%s'.","messagePattern":"load_yuv\\(\\) : Missing data in file '(.+?)'\\.","errorType":"exception","errorClass":"CImgIOException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":67286,"sourceCode":"              break;\n            case 422 :\n              cimg_forXY(UV,x,y) {\n                const ucharT U = *(ptrs1++), V = *(ptrs2++);\n                *(ptrd1++) = U; *(ptrd1++) = U;\n                *(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').","sourceCodeStart":67268,"sourceCodeEnd":67304,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L67268-L67304","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nimgs.load_yuv(\"broken.yuv\", 1920, 1080, 420, 0, 10); // file is 500 KB < 1 frame (3.1 MB)\n// after\n// re-export: ffmpeg -i in.mp4 -pix_fmt yuv420p -f rawvideo full.yuv\nimgs.load_yuv(\"full.yuv\", 1920, 1080, 420, 0, ~0U);","handlingStrategy":"validation","validationCode":"uint64_t frameSize = (uint64_t)w*h + 2*((uint64_t)(w/cfx)*(h/cfy));\nif (fileSize(path) < frameSize) { /* file truncated/empty - abort or re-fetch */ }","typeGuard":null,"tryCatchPattern":"try { imgs.load_yuv(path, w, h, cs); }\ncatch (CImgIOException& e) { fprintf(stderr, \"no readable frames (truncated/wrong format): %s\\n\", e.what()); }","preventionTips":["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"],"tags":["cimg","yuv","file-io","empty-result","video-loading"],"backgroundTag":"empty-result-set","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}