pozitronik / sinner

Sinner: Sinner Is NoN Exactly Roop
GNU Affero General Public License v3.0
75 stars 9 forks source link

[DEV] Check, if program gracefully degrade to cv2 if there's no ffmpeg found #88

Open alexjolig opened 1 year ago

alexjolig commented 1 year ago

I tired following command to do a face swap video:

python sin.py --source="sources/foo.jpeg" --target="sources/johndoe.mov" --frame-processor FaceSwapper FaceEnhancer --output="resources/foo_bar.mp4" --many-faces --execution-provider=cpu --execution-threads=8

But I encountered the following error:

FileNotFoundError: [Errno 2] No such file or directory: 'ffprobe'

Am I missing a package or something?

Here's the full stack trace:

Traceback (most recent call last):
  File "/projects/sinner/sinner/validators/DefaultValidator.py", line 16, in validate
    value = validation_value.fget(validated_object)  # type: ignore[misc]
  File "/projects/sinner/sinner/handlers/frame/FFmpegVideoHandler.py", line 66, in fps
    output = subprocess.check_output(command).decode().strip().split('/')
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 421, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 503, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 971, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 1847, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ffprobe'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/projects/sinner/sin.py", line 55, in <module>
    Sin().run()
  File "/projects/sinner/sin.py", line 46, in run
    BatchProcessingCore(parameters=self.parameters).run()
  File "/projects/sinner/sinner/BatchProcessingCore.py", line 111, in run
    handler = self.suggest_handler(current_target_path, self.parameters)
  File "/projects/sinner/sinner/BatchProcessingCore.py", line 215, in suggest_handler
    return VideoHandler(target_path, parameters)
  File "/projects/sinner/sinner/handlers/frame/FFmpegVideoHandler.py", line 60, in __init__
    super().__init__(target_path, parameters)
  File "/projects/sinner/sinner/handlers/frame/BaseFrameHandler.py", line 43, in __init__
    super().__init__(parameters)
  File "/projects/sinner/sinner/validators/AttributeLoader.py", line 59, in __init__
    if not self.load(parameters):
  File "/projects/sinner/sinner/validators/AttributeLoader.py", line 84, in load
    if not self.validate():  # return values back
  File "/projects/sinner/sinner/validators/AttributeLoader.py", line 126, in validate
    for error in self.validate_attribute(attribute):
  File "/projects/sinner/sinner/validators/AttributeLoader.py", line 143, in validate_attribute
    error = validator.validate(self, attribute)
  File "/projects/sinner/sinner/validators/DefaultValidator.py", line 18, in validate
    raise ValidatorException(f'{type(exception).__name__} with message `{str(exception)}` when retrieve property value for {attribute} attribute', validated_object, self)
sinner.validators.ValidatorException.ValidatorException: DefaultValidator: FileNotFoundError with message `[Errno 2] No such file or directory: 'ffprobe'` when retrieve property value for output_fps attribute@VideoHandler
alexjolig commented 1 year ago

Ok, The problem was the ffmpeg was installed but not linked.

So I ran brew link ffmpeg and the error is gone now.

pozitronik commented 1 year ago

In fact, it can be an issue. If there's no ffmpeg installed, sinner should gracefully degrade to CV2. But I've never checked on this.