{"record":{"id":"b7674528d304a4b7","repo":"Yalantis/uCrop","slug":"save-video-cannot-output-streamed-video-as-thi","errorCode":null,"errorMessage":"save_video(): Cannot output streamed video, as this requires features from the OpenCV library ('-Dcimg_use_opencv') must be defined).","messagePattern":"save_video\\(\\): Cannot output streamed video, as this requires features from the OpenCV library \\('-Dcimg_use_opencv'\\) must be defined\\)\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":68540,"sourceCode":"          _data[l].save_gzip_external(nfilename);\n        }\n      }\n      return *this;\n    }\n\n    //! Save image sequence (using the OpenCV library when available).\n    /**\n       \\param filename Filename to write data to.\n       \\param fps Number of frames per second.\n       \\param codec Type of compression (See http://www.fourcc.org/codecs.php to see available codecs).\n       \\param keep_open Tells if the video writer associated to the specified filename\n       must be kept open or not (to allow frames to be added in the same file afterwards).\n    **/\n    const CImgList<T>& save_video(const char *const filename, const unsigned int fps=25,\n                                  const char *codec=0, const bool keep_open=false) const {\n#ifndef cimg_use_opencv\n      cimg::unused(codec,keep_open);\n      if (keep_open) cimg::warn(_cimglist_instance\n                                \"save_video(): Cannot output streamed video, as this requires features from the \"\n                                \"OpenCV library ('-Dcimg_use_opencv') must be defined).\",\n                                cimglist_instance);\n      if (!is_empty()) return save_ffmpeg_external(filename,fps);\n      return *this;\n#else\n      try {\n        static cv::VideoWriter *writers[32] = {};\n        static CImgList<charT> filenames(32);\n        static CImg<intT> sizes(32,2,1,1,0);\n        static int last_used_index = -1;\n\n        // Detect if a video writer already exists for the specified filename.\n        cimg::mutex(9);\n        int index = -1;\n        if (filename) {\n          if (last_used_index>=0 && !std::strcmp(filename,filenames[last_used_index])) {\n            index = last_used_index;","sourceCodeStart":68522,"sourceCodeEnd":68558,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L68522-L68558","documentation":"CImgList<T>::save_video() with keep_open=true requires OpenCV streaming features. In builds without cimg_use_opencv, the call warns that streamed (kept-open) video output is unavailable, then falls back to saving via an external ffmpeg process for the non-empty case.","triggerScenarios":"Calling save_video(filename, fps, codec, keep_open=true) on a build compiled without cimg_use_opencv; the warning fires only when keep_open is true, otherwise it silently saves via ffmpeg_external.","commonSituations":"Expecting incremental/streamed video writing (e.g. appending frames over time) on a plain CImg+ffmpeg build; CI or Android NDK builds where OpenCV was not linked; copying code that was written against an OpenCV-enabled CImg build.","solutions":["Rebuild with cimg_use_opencv defined and link OpenCV (imgcodecs/videoio) to enable streamed output","Set keep_open=false and save the complete list in one call (still uses external ffmpeg)","Ensure the external ffmpeg binary is on PATH since the fallback path shells out to it","Restructure code to accumulate frames and write once at the end"],"exampleFix":"// before\nframes.save_video(\"out.mp4\", 30, nullptr, true); // warns, streaming unsupported\n// after\n#ifdef cimg_use_opencv\nframes.save_video(\"out.mp4\", 30, nullptr, true);\n#else\nframes.save_video(\"out.mp4\", 30, nullptr, false); // one-shot external ffmpeg\n#endif","handlingStrategy":"fallback","validationCode":"#ifdef cimg_use_opencv\nframes.save_video(\"out.mp4\", fps, nullptr, true);\n#else\nif (std::system(\"command -v ffmpeg >/dev/null\") == 0)\n  frames.save_video(\"out.mp4\", fps, nullptr, false);\n#endif","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Link OpenCV (cimg_use_opencv) if streamed writing is required","Avoid keep_open=true on non-OpenCV builds","Verify external ffmpeg is installed for the fallback path"],"tags":["cimg","opencv","video","feature-not-enabled"],"backgroundTag":"feature-not-enabled","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}