{"record":{"id":"51c4b34744fd27aa","repo":"deepfakes/faceswap","slug":"frame-ranges-specified-but-could-not-determine-fr","errorCode":null,"errorMessage":"Frame Ranges specified, but could not determine frame numbering from filenames","messagePattern":"Frame Ranges specified, but could not determine frame numbering from filenames","errorType":"exception","errorClass":"FaceswapError","httpStatus":null,"severity":"error","filePath":"scripts/convert.py","lineNumber":428,"sourceCode":"        Returns\n        A list of  frames to be processed, or ``None`` if the command line argument was not used\n        \"\"\"\n        if not self._args.frame_ranges:\n            logger.debug(\"No frame range set\")\n            return None\n\n        min_frame, max_frame = None, None\n        if self._images.is_video:\n            min_frame, max_frame = 1, self._images.count\n        else:\n            indices = [int(self._image_idx_re.findall(os.path.basename(filename))[0])\n                       for filename in self._images.file_list]\n            if indices:\n                min_frame, max_frame = min(indices), max(indices)\n        logger.debug(\"min_frame: %s, max_frame: %s\", min_frame, max_frame)\n\n        if min_frame is None or max_frame is None:\n            raise FaceswapError(\"Frame Ranges specified, but could not determine frame numbering \"\n                                \"from filenames\")\n\n        retval = []\n        for rng in self._args.frame_ranges:\n            if \"-\" not in rng:\n                raise FaceswapError(\"Frame Ranges not specified in the correct format\")\n            start, end = rng.split(\"-\")\n            retval.append((max(int(start), min_frame), min(int(end), max_frame)))\n        logger.debug(\"frame ranges: %s\", retval)\n        return retval\n\n    def _load_extractor(self) -> ExtractRunner[ExtractHandler] | None:\n        \"\"\"Load the CV2-DNN Face Extractor Chain.\n\n        For On-The-Fly conversion we use a CPU based extractor to avoid stacking the GPU.\n        Results are poor.\n\n        Returns","sourceCodeStart":410,"sourceCodeEnd":446,"githubUrl":"https://github.com/deepfakes/faceswap/blob/f530cb7508ae670f6474f8a7d9c4df94705cf96b/scripts/convert.py#L410-L446","documentation":"FaceswapError raised in Convert._get_frame_ranges when --frame-ranges is used with a frames-folder input whose filenames contain no recognizable index numbers. For videos, min/max come from the frame count; for folders, an _image_idx_re regex must find an integer in every basename. If no indices are found, min_frame/max_frame stay None and the range cannot be resolved.","triggerScenarios":"Running convert with --frame-ranges on an input folder of images whose names lack numeric parts (e.g. 'face_a.png', 'img.png'). The regex findall over each basename yields nothing so indices is empty.","commonSituations":"Frames extracted with custom renaming scripts, images gathered from mixed sources without numbering, or user assumes frame ranges apply to arbitrary image folders.","solutions":["Rename files to include a numeric frame index (e.g. 000001.png) matching your extractor's numbering pattern","Or drop --frame-ranges and convert all frames","Or convert from the source video directly, where numbering is inherent"],"exampleFix":"# before: folder has face_a.png, face_b.png -> error\npython faceswap.py convert -i /frames -m /models/m --frame-ranges 5-10\n\n# after (shell): rename with numeric indices\ncd /frames && i=1; for f in *.png; do mv \"$f\" \"$(printf '%06d.png' $i)\"; i=$((i+1)); done\npython faceswap.py convert -i /frames -m /models/m --frame-ranges 5-10","handlingStrategy":"validation","validationCode":"import os, re\nidx_re = re.compile(r\"\\d+\")  # mirror convert's numbering expectation\nif not images_obj.is_video and args.frame_ranges:\n    if not all(idx_re.search(os.path.basename(f)) for f in images_obj.file_list):\n        raise SystemExit(\"--frame-ranges needs numbered filenames; rename files or drop the flag\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the extractor's default zero-padded numbering when preparing frames folders","Avoid renaming scripts that strip numeric indices from frame filenames"],"tags":["faceswap","convert","frame-ranges","filenames"],"backgroundTag":null,"analyzedSha":"f530cb7508ae670f6474f8a7d9c4df94705cf96b","analyzedAt":"2026-08-15T02:59:26.626Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}