{"record":{"id":"7b24bac64a4099b8","repo":"deepfakes/faceswap","slug":"the-chosen-action-requires-a-directory-as-its-inpu","errorCode":null,"errorMessage":"The chosen action requires a directory as its input, but you entered: {self.input.path}","messagePattern":"The chosen action requires a directory as its input, but you entered: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/effmpeg/effmpeg.py","lineNumber":184,"sourceCode":"                self.output = DataItem(path=self.__get_default_output())\n\n    def _set_ref_video(self) -> None:\n        \"\"\"Set :attr:`ref_vid` based on input arguments\"\"\"\n        if self.args.ref_vid is None or self.args.ref_vid == \"\":\n            self.args.ref_vid = None\n\n        self.ref_vid = DataItem(path=self.args.ref_vid)\n\n    def _check_inputs(self) -> None:\n        \"\"\"Validate provided arguments are valid\n\n        Raises\n        ------\n        ValueError\n            If provided arguments are not valid\n        \"\"\"\n        if self.args.action in self._actions_have_dir_input and not self.input.is_type(\"dir\"):\n            raise ValueError(\"The chosen action requires a directory as its input, but you \"\n                             f\"entered: {self.input.path}\")\n        if self.args.action in self._actions_have_vid_input and not self.input.is_type(\"vid\"):\n            raise ValueError(\"The chosen action requires a video as its input, but you entered: \"\n                             f\"{self.input.path}\")\n        if self.args.action in self._actions_have_dir_output and not self.output.is_type(\"dir\"):\n            raise ValueError(\"The chosen action requires a directory as its output, but you \"\n                             f\"entered: {self.output.path}\")\n        if self.args.action in self._actions_have_vid_output and not self.output.is_type(\"vid\"):\n            raise ValueError(\"The chosen action requires a video as its output, but you entered: \"\n                             f\"{self.output.path}\")\n\n        # Check that ref_vid is a video when it needs to be\n        if self.args.action in self._actions_req_ref_video:\n            if self.ref_vid.is_type(\"none\"):\n                raise ValueError(\"The file chosen as the reference video is not a video, either \"\n                                 f\"leave the field blank or type 'None': {self.ref_vid.path}\")\n        elif self.args.action in self._actions_can_use_ref_video:\n            if self.ref_vid.is_type(\"none\"):","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/deepfakes/faceswap/blob/f530cb7508ae670f6474f8a7d9c4df94705cf96b/tools/effmpeg/effmpeg.py#L166-L202","documentation":"EFFmpeg tool argument validation: the selected --action belongs to the set that consumes a directory as input (e.g. extract/mux from a folder of frames), but the given --input path is not a directory. Raised as ValueError from _check_inputs before any ffmpeg process starts.","triggerScenarios":"Running `python tools.py effmpeg -a extract -i video.mp4 ...` where 'extract' requires a dir input, or any dir-input action with a file/glob/nonexistent path classified as non-dir by DataItem.is_type('dir').","commonSituations":"Swapping -i and -o semantics; passing a video where a frames folder is expected; relative path resolving to a non-existent location so it fails the dir type check.","solutions":["Point --input at an existing directory of frames for directory-input actions.","If your source is a video, first run an action that converts video to frames (e.g. 'extract') with correct direction, or extract frames with the extract tool.","Run `python tools.py effmpeg -h` to confirm which type the chosen action expects for input/output."],"exampleFix":"# before\npython tools.py effmpeg -a extract -i video.mp4 -o frames/\n\n# after\npython tools.py effmpeg -a extract -i frames_dir/ -o output.avi   # dir-input action gets a directory","handlingStrategy":"validation","validationCode":"import os\n\ndef dir_input_ok(path: str) -> bool:\n    return os.path.isdir(path)","typeGuard":null,"tryCatchPattern":"try:\n    effmpeg._check_inputs()\nexcept ValueError as err:\n    print(\"Input type mismatch:\", err)\n    raise SystemExit(1)","preventionTips":["Build wrapper scripts per effmpeg action that hard-code the correct input/output types.","Run `python tools.py effmpeg -h` when unsure which side expects dir vs vid."],"tags":["faceswap","effmpeg","ffmpeg","input-validation","cli-arguments"],"backgroundTag":null,"analyzedSha":"f530cb7508ae670f6474f8a7d9c4df94705cf96b","analyzedAt":"2026-08-15T02:59:26.626Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}