{"record":{"id":"3d45c1a74be458dd","repo":"Yalantis/uCrop","slug":"save-ffmpeg-external-specified-filename-is-nul","errorCode":null,"errorMessage":"save_ffmpeg_external(): Specified filename is (null).","messagePattern":"save_ffmpeg_external\\(\\): Specified filename is \\(null\\)\\.","errorType":"exception","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":63641,"sourceCode":"      return *this;\n    }\n\n    //! Save volumetric image as a video, using ffmpeg external binary.\n    /**\n       \\param filename Filename, as a C-string.\n       \\param fps Video framerate.\n       \\param codec Video codec, as a C-string.\n       \\param bitrate Video bitrate.\n       \\note\n       - Each slice of the instance image is considered to be a single frame of the output video file.\n       - This method uses \\c ffmpeg, an external executable binary provided by\n         <a href=\"http://www.ffmpeg.org\">FFmpeg</a>.\n       It must be installed for the method to succeed.\n    **/\n    const CImg<T>& save_ffmpeg_external(const char *const filename, const unsigned int fps=25,\n                                        const char *const codec=0, const unsigned int bitrate=2048) const {\n      if (!filename)\n        throw CImgArgumentException(_cimg_instance\n                                    \"save_ffmpeg_external(): Specified filename is (null).\",\n                                    cimg_instance);\n      if (is_empty()) { cimg::fempty(0,filename); return *this; }\n\n      CImgList<T> list;\n      get_split('z').move_to(list);\n      list.save_ffmpeg_external(filename,fps,codec,bitrate);\n      return *this;\n    }\n\n    //! Save image using gzip external binary.\n    /**\n       \\param filename Filename, as a C-string.\n       \\note This method uses \\c gzip, an external executable binary provided by\n         <a href=\"//http://www.gzip.org\">gzip</a>.\n       It must be installed for the method to succeed.\n    **/\n    const CImg<T>& save_gzip_external(const char *const filename) const {","sourceCodeStart":63623,"sourceCodeEnd":63659,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L63623-L63659","documentation":"save_ffmpeg_external() encodes the image/video by shelling out to an installed ffmpeg binary, so it requires a real output filename. It throws CImgArgumentException when the filename is null. Note ffmpeg is external: it must be on PATH (cimg::ffmpeg_path()) for the call to succeed at all.","triggerScenarios":"Calling save_ffmpeg_external() with the default/NULL filename, or passing a null char* produced by earlier code.","commonSituations":"Filename composed from environment/config that was absent; calling the method on systems where the path variable was never allocated; test harnesses invoking it without arguments.","solutions":["Pass a non-null filename with an appropriate extension/codec, e.g. img.save_ffmpeg_external(\"out.avi\",25,\"mpeg2\",2048).","Guard: if (!fname) use a default path before calling.","If you don't need ffmpeg, choose an internally implemented format instead."],"exampleFix":"// before\nimg.save_ffmpeg_external(fname); // fname may be NULL\n// after\nif (!fname) fname = \"video.avi\";\nimg.save_ffmpeg_external(fname, 25, \"mpeg2\", 2048);","handlingStrategy":"validation","validationCode":"if (!fname || !*fname) fname = \"video.avi\";\n// optionally: ensure ffmpeg exists\nif (std::system(\"ffmpeg -version > /dev/null 2>&1\") != 0) { /* handle absence */ }\nimg.save_ffmpeg_external(fname, 25, \"mpeg2\", 2048);","typeGuard":"bool validOutputFile(const char *p) { return p != nullptr && p[0] != '\\0'; }","tryCatchPattern":"try { img.save_ffmpeg_external(path.c_str()); }\ncatch (cimg_library::CImgArgumentException &e) { std::fprintf(stderr, \"ffmpeg save: %s\\n\", e.what()); }\ncatch (cimg_library::CImgIOException &e) { std::fprintf(stderr, \"ffmpeg failed (installed?): %s\\n\", e.what()); }","preventionTips":["Never call external-tool savers with a null filename.","Check ffmpeg availability once at startup if the feature is optional.","Catch both argument and IO exceptions around external saves."],"tags":["cimg","null-argument","ffmpeg","external-tool","video"],"backgroundTag":"null-argument","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"}