Yalantis/uCrop · error · CImgIOException
save_video(): File '%s', no video writer slots available. Yo
Error message
save_video(): File '%s', no video writer slots available. You have to release some of your previously opened videos.
What it means
save_video() keeps a fixed-size pool of concurrent cv::VideoWriter slots. When a new filename is given but every slot is occupied by an unreleased video, this IO exception is thrown telling you to release previously opened videos.
Source
Thrown at ucrop/src/main/jni/CImg.h:68574
if (filename) {
if (last_used_index>=0 && !std::strcmp(filename,filenames[last_used_index])) {
index = last_used_index;
} else cimglist_for(filenames,l) if (filenames[l] && !std::strcmp(filename,filenames[l])) {
index = l; break;
}
} else index = last_used_index;
cimg::mutex(9,0);
// Find empty slot for capturing video stream.
if (index<0) {
if (!filename)
throw CImgArgumentException(_cimglist_instance
"save_video(): No already open video writer 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
"save_video(): File '%s', no video writer slots available. "
"You have to release some of your previously opened videos.",
cimglist_instance,filename);
if (is_empty())
throw CImgInstanceException(_cimglist_instance
"save_video(): Instance list is empty.",
cimglist_instance);
const unsigned int W = _data?_data[0]._width:0, H = _data?_data[0]._height:0;
if (!W || !H)
throw CImgInstanceException(_cimglist_instance
"save_video(): Frame [0] is an empty image.",
cimglist_instance);
const char
*const _codec = codec && *codec?codec:"h264",
codec0 = cimg::uppercase(_codec[0]),
codec1 = _codec[0]?cimg::uppercase(_codec[1]):0,
codec2 = _codec[1]?cimg::uppercase(_codec[2]):0,
codec3 = _codec[2]?cimg::uppercase(_codec[3]):0;View on GitHub (pinned to f788b534b4)
Solutions
- Call close_save_video() (or pass filename and let slots free) for videos you no longer write
- Reduce the number of simultaneously open video outputs
- Reuse one output file instead of opening a new writer per segment
- Audit code paths for missing close_save_video() on error exits
Example fix
// before
for (cam : cams) frames_of(cam).save_video(name(cam)); // slots exhausted
// after
for (cam : cams) { frames_of(cam).save_video(name(cam)); frames_of(cam).close_save_video(); } Defensive patterns
Strategy: validation
Validate before calling
// C++ if (openVideoCount() >= kMaxWriters) close_oldest_video();
Try / catch
try { frames.save_video(fname, fps, codec); }
catch (CImgIOException& e) { frames.close_save_video(); frames.save_video(fname, fps, codec); } Prevention
- Close videos with close_save_video() as soon as recording ends
- Limit concurrent outputs to the slot pool size
- Audit error paths so writers are released on exceptions
- Reuse a single output file for segmented recording
When it happens
Trigger: Calling save_video() with a filename when writers[] has no free slot: more videos simultaneously open via save_video() than the pool size allows, without intervening close_save_video() calls.
Common situations: Long-running capture loops opening a new output file per camera/recording without closing finished ones; leaks of cv::VideoWriter slots across threads sharing mutex 9.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- load_video(): File '%s', no video reader slots available. Yo
- load_video() : File '%s', arguments 'first_frame', 'last_fra
- load_video(): No already open video reader found. You must s
- load_video(): File '%s', unable to detect format of video fi
- load_video(): File '%s', unable to locate frame %u.
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/83fefbfc8e22171b.
Report an issue: GitHub.