Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ugoira conversion fails due to missing ffmpeg path #1126

Closed
wmjdgla opened this issue Jun 2, 2022 · 1 comment
Closed

Ugoira conversion fails due to missing ffmpeg path #1126

wmjdgla opened this issue Jun 2, 2022 · 1 comment

Comments

@wmjdgla
Copy link
Contributor

wmjdgla commented Jun 2, 2022

cmd = f"ffmpeg -i {im_path} -pix_fmt {pix_fmt_nb_components[nb_channel]} {temp_name}"

As you can see, cmd is built using just "ffmpeg" without any path to it, vs here where it is dynamically resolved:

cmd = f"{ffmpeg} -y -safe 0 -i \"{d}/i.ffconcat\" -c:v {codec} {param} \"{tempname}\""

So when execution goes through L1167, the conversion fails and we get the following exception stack:

Traceback (most recent call last):
  File "c:\PixivUtil2\PixivImageHandler.py", line 333, in process_image
    PixivDownloadHandler.handle_ugoira(image, filename, config, notifier)
  File "c:\PixivUtil2\PixivDownloadHandler.py", line 384, in handle_ugoira
    PixivHelper.ugoira2gif(ugo_name,
  File "c:\PixivUtil2\PixivHelper.py", line 954, in ugoira2gif
    convert_ugoira(ugoira_file,
  File "c:\PixivUtil2\PixivHelper.py", line 1052, in convert_ugoira
    check_image_encoding(d)
  File "c:\PixivUtil2\PixivHelper.py", line 1145, in check_image_encoding
    re_encode_image(re_encode_channel, file)
  File "c:\PixivUtil2\PixivHelper.py", line 1170, in re_encode_image
    p = subprocess.Popen(ffmpeg_args, stderr=subprocess.PIPE)
  File "C:\Program Files\Python38\lib\subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Program Files\Python38\lib\subprocess.py", line 1307, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
  File "c:\Users\username\.vscode\extensions\ms-python.python-2021.10.1365161279\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydev_bundle\pydev_monkey.py", line 860, in new_CreateProcess
    return getattr(_subprocess, original_name)(app_name, cmd_line, *args)
FileNotFoundError: [WinError 2] The system cannot find the file specified

Which is expected since it cannot find ffmpeg.exe. Most ugoiras won't invoke re_encode_image which is missing the path, so the problem rarely shows up, if ever.

I fixed the problem by hardcoding my ffmpeg's path at L1167. I guess the proper way to fix this would probably be passing the path into the function as a parameter.

On a side note, the above exception would crash the program. Not sure whether it's meant to be the case.

@Nandaka
Copy link
Owner

Nandaka commented Jun 3, 2022

yes, you can replace it with _config.ffmpeg in L1167, so it resolved based on the config.ini

@Nandaka Nandaka closed this as completed in 5f53aeb Jun 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants