{"record":{"id":"d2ed14cd532809ba","repo":"Yalantis/uCrop","slug":"load-video-file-s-no-video-reader-slots-ava","errorCode":null,"errorMessage":"load_video(): File '%s', no video reader slots available. You have to release some of your previously opened videos.","messagePattern":"load_video\\(\\): File '(.+?)', no video reader slots available\\. You have to release some of your previously opened videos\\.","errorType":"exception","errorClass":"CImgIOException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":67370,"sourceCode":"                       \"load_video() : File '%s', no opened video stream associated with filename found.\",\n                       cimglist_instance,filename);\n          else\n            cimg::warn(_cimglist_instance\n                       \"load_video() : No opened video stream found.\",\n                       cimglist_instance,filename);\n        if (!step_frame) return *this;\n      }\n\n      // Find empty slot for capturing video stream.\n      if (index<0) {\n        if (!filename)\n          throw CImgArgumentException(_cimglist_instance\n                                      \"load_video(): No already open video reader found. You must specify a \"\n                                      \"non-(null) filename argument for the first call.\",\n                                      cimglist_instance);\n        else { cimg::mutex(9); cimglist_for(filenames,l) if (!filenames[l]) { index = l; break; } cimg::mutex(9,0); }\n        if (index<0)\n          throw CImgIOException(_cimglist_instance\n                                \"load_video(): File '%s', no video reader slots available. \"\n                                \"You have to release some of your previously opened videos.\",\n                                cimglist_instance,filename);\n        cimg::mutex(9);\n        captures[index] = new cv::VideoCapture(filename);\n        positions[index] = 0;\n        if (!captures[index]->isOpened()) {\n          delete captures[index];\n          captures[index] = 0;\n          cimg::mutex(9,0);\n          cimg::fclose(cimg::fopen(filename,\"rb\")); // Check file availability\n          throw CImgIOException(_cimglist_instance\n                                \"load_video(): File '%s', unable to detect format of video file.\",\n                                cimglist_instance,filename);\n        }\n        CImg<charT>::string(filename).move_to(filenames[index]);\n        cimg::mutex(9,0);\n      }","sourceCodeStart":67352,"sourceCodeEnd":67388,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L67352-L67388","documentation":"CImg keeps a fixed-size pool of OpenCV cv::VideoCapture slots (internal captures[]/filenames[] arrays) for load_video(). This CImgIOException is thrown under mutex 9 when every slot is occupied and a new filename must be opened, i.e. no empty slot exists to host a new video reader.","triggerScenarios":"Calling load_video() with a new filename while all internal video-reader slots are already taken by previously opened videos that were never released.","commonSituations":"Batch-processing many video files by repeatedly calling load_video() with different filenames on the same CImgList instance without closing/releasing readers; long-running apps (like an Android image-crop pipeline) leaking capture slots.","solutions":["Release previously opened videos: assign an empty list (list.assign()) or destroy the CImgList instances holding open captures so their slots free up.","Process videos sequentially, closing/destroying each CImgList before opening the next file.","Raise the pool limit by increasing the internal cimg list of capture slots (recompile with a larger captures array) if many concurrent videos are truly required."],"exampleFix":"// before\nfor (const char* f : files) {\n  list.load_video(f); // slots exhaust after N videos -> throws\n}\n\n// after\nfor (const char* f : files) {\n  CImgList<unsigned char> list; // fresh instance per file\n  list.load_video(f);\n  // ... process ...\n} // destructor releases the capture slot","handlingStrategy":"try-catch","validationCode":"// track open videos yourself and release before opening new ones\nif (openVideoCount >= maxSlots) {\n  releaseOldestVideo(); // assign() empty list / destroy instance\n}","typeGuard":null,"tryCatchPattern":"try {\n  list.load_video(filename);\n} catch (CImgIOException&) {\n  list.assign(); // release slots\n  list.load_video(filename); // retry\n}","preventionTips":["Destroy or assign() empty every CImgList used for video loading before opening the next file.","Scope each video load in its own block so destructors free capture slots.","Never accumulate long-lived CImgLists of videos in a loop."],"tags":["cimg","opencv","video","resource-exhaustion","resource-leak"],"backgroundTag":"resource-exhausted","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"}