Yalantis/uCrop · error · CImgIOException

load_video(): File '%s', no video reader slots available. Yo

Error message

load_video(): File '%s', no video reader slots available. You have to release some of your previously opened videos.

What it means

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.

Source

Thrown at ucrop/src/main/jni/CImg.h:67370

                       "load_video() : File '%s', no opened video stream associated with filename found.",
                       cimglist_instance,filename);
          else
            cimg::warn(_cimglist_instance
                       "load_video() : No opened video stream found.",
                       cimglist_instance,filename);
        if (!step_frame) return *this;
      }

      // Find empty slot for capturing video stream.
      if (index<0) {
        if (!filename)
          throw CImgArgumentException(_cimglist_instance
                                      "load_video(): No already open video reader found. You must specify a "
                                      "non-(null) filename argument for the first call.",
                                      cimglist_instance);
        else { cimg::mutex(9); cimglist_for(filenames,l) if (!filenames[l]) { index = l; break; } cimg::mutex(9,0); }
        if (index<0)
          throw CImgIOException(_cimglist_instance
                                "load_video(): File '%s', no video reader slots available. "
                                "You have to release some of your previously opened videos.",
                                cimglist_instance,filename);
        cimg::mutex(9);
        captures[index] = new cv::VideoCapture(filename);
        positions[index] = 0;
        if (!captures[index]->isOpened()) {
          delete captures[index];
          captures[index] = 0;
          cimg::mutex(9,0);
          cimg::fclose(cimg::fopen(filename,"rb")); // Check file availability
          throw CImgIOException(_cimglist_instance
                                "load_video(): File '%s', unable to detect format of video file.",
                                cimglist_instance,filename);
        }
        CImg<charT>::string(filename).move_to(filenames[index]);
        cimg::mutex(9,0);
      }

View on GitHub (pinned to f788b534b4)

Solutions

  1. Release previously opened videos: assign an empty list (list.assign()) or destroy the CImgList instances holding open captures so their slots free up.
  2. Process videos sequentially, closing/destroying each CImgList before opening the next file.
  3. 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.

Example fix

// before
for (const char* f : files) {
  list.load_video(f); // slots exhaust after N videos -> throws
}

// after
for (const char* f : files) {
  CImgList<unsigned char> list; // fresh instance per file
  list.load_video(f);
  // ... process ...
} // destructor releases the capture slot
Defensive patterns

Strategy: try-catch

Validate before calling

// track open videos yourself and release before opening new ones
if (openVideoCount >= maxSlots) {
  releaseOldestVideo(); // assign() empty list / destroy instance
}

Try / catch

try {
  list.load_video(filename);
} catch (CImgIOException&) {
  list.assign(); // release slots
  list.load_video(filename); // retry
}

Prevention

When it happens

Trigger: Calling load_video() with a new filename while all internal video-reader slots are already taken by previously opened videos that were never released.

Common situations: 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.

Related errors


AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08). Data as JSON: /api/errors/d2ed14cd532809ba. Report an issue: GitHub.