{"record":{"id":"07e5ff7481bc26f4","repo":"deepfakes/faceswap","slug":"file-file-path-is-not-a-valid-video-file","errorCode":null,"errorMessage":"File '{file_path}' is not a valid video file","messagePattern":"File '(.+?)' is not a valid video file","errorType":"exception","errorClass":"FaceswapError","httpStatus":null,"severity":"error","filePath":"lib/video.py","lineNumber":88,"sourceCode":"    Parameters\n    ----------\n    file_path\n        The full path to the video file to validate\n\n    Returns\n    -------\n    The full expanded video file path\n\n    Raises\n    ------\n    FaceswapError\n        If the given video file is not valid\n    \"\"\"\n    file_path = os.path.expanduser(os.path.abspath(file_path))\n    if not os.path.isfile(file_path):\n        raise FaceswapError(f\"Video file '{file_path}' does not exist\")\n    if os.path.splitext(file_path)[-1].lower() not in VIDEO_EXTENSIONS:\n        raise FaceswapError(f\"File '{file_path}' is not a valid video file\")\n    return file_path\n\n\n# TODO look for instances of this and see if we can roll it into VideoInfo\ndef count_frames(filename, fast=False):\n    \"\"\" Count the number of frames in a video file\n\n    There is no guaranteed accurate way to get a count of video frames without iterating through\n    a video and decoding every frame.\n\n    :func:`count_frames` can return an accurate count (albeit fairly slowly) or a possibly less\n    accurate count, depending on the :attr:`fast` parameter. A progress bar is displayed.\n\n    Parameters\n    ----------\n    filename: str\n        Full path to the video to return the frame count from.\n    fast: bool, optional","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/deepfakes/faceswap/blob/f530cb7508ae670f6474f8a7d9c4df94705cf96b/lib/video.py#L70-L106","documentation":"Raised by validate_video_file() in lib/video.py when the file exists but its extension is not in VIDEO_EXTENSIONS. This is a format check on the container extension only (no probing of actual content), so renaming a non-video file to .mp4 will pass this check but fail later at decode time.","triggerScenarios":"Passing an existing file whose extension is not a recognized video container (e.g. .jpg, .bin, .txt) to a code path that requires a video file.","commonSituations":"Pointing a video-consuming job at a subtitle, image, archive, or temporary file; renamed files that lost their extension; output of another tool written with an unexpected extension.","solutions":["Confirm you passed a video container file (.mp4, .avi, .mkv, .mov, ...).","If the content is video in an odd container, remux it: ffmpeg -i input.xyz -c copy output.mp4.","If the content is images, pass the folder instead (that path does not go through validate_video_file)."],"exampleFix":"# before\nfaceswap extract -i frame_0001.jpg ...\n\n# after\nfaceswap extract -i frames_folder/ ...  # images go as a folder","handlingStrategy":"validation","validationCode":"from lib.video import VIDEO_EXTENSIONS\nimport os\nassert os.path.splitext(video_path)[-1].lower() in VIDEO_EXTENSIONS, \"not a video container\"","typeGuard":"def has_video_extension(path: str, exts: set[str]) -> bool:\n    return os.path.splitext(path)[-1].lower() in exts","tryCatchPattern":null,"preventionTips":["Feed image sequences as folders, never as individual files, to video-capable jobs.","Keep media files named with standard container extensions."],"tags":["faceswap","video","file-validation","cli"],"backgroundTag":null,"analyzedSha":"f530cb7508ae670f6474f8a7d9c4df94705cf96b","analyzedAt":"2026-08-15T02:59:26.626Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}