MoneyPrinterTurbo icon indicating copy to clipboard operation
MoneyPrinterTurbo copied to clipboard

提示没装 ImageMagick

Open heihei180 opened this issue 9 months ago • 5 comments

您好,我已经安装了 ImageMagick , 并且在config.toml 中配置了 imagemagick_path = "C:\\Program Files (x86)\\ImageMagick-7.1.1-Q16\\magick.exe" 但是我发现一个问题,每次启动程序后,这行代码imagemagick_path = "C:\\Program Files (x86)\\ImageMagick-7.1.1-Q16\\magick.exe" 就会被自动删除。 然后我生成视频的时候,会报下面的问题,搜索了issue,没找到原因是为什么,您能帮忙解答一下吗?谢谢!

image

heihei180 avatar May 14 '24 14:05 heihei180

这是 控制台的报错信息

## combining video: 1 => .\storage\tasks\4b001ee5-840d-41b7-84e6-91d61b4c9961\combined-1.mp4
2024-05-14 22:31:22 | INFO | "./app\services\video.py:40": combine_videos - max duration of audio: 21.34 seconds
2024-05-14 22:31:22 | INFO | "./app\services\video.py:44": combine_videos - each clip will be maximum 3 seconds long
2024-05-14 22:31:24 | INFO | "./app\services\video.py:106": combine_videos - writing
2024-05-14 22:32:09 | SUCCESS | "./app\services\video.py:116": combine_videos - completed
2024-05-14 22:32:09 | INFO | "./app\services\task.py:171": start - 

## generating video: 1 => .\storage\tasks\4b001ee5-840d-41b7-84e6-91d61b4c9961\final-1.mp4
2024-05-14 22:32:09 | INFO | "./app\services\video.py:187": generate_video - start, video size: 1080 x 1920
2024-05-14 22:32:09 | INFO | "./app\services\video.py:188": generate_video -   ① video: .\storage\tasks\4b001ee5-840d-41b7-84e6-91d61b4c9961\combined-1.mp4
2024-05-14 22:32:09 | INFO | "./app\services\video.py:189": generate_video -   ② audio: .\storage\tasks\4b001ee5-840d-41b7-84e6-91d61b4c9961\audio.mp3
2024-05-14 22:32:09 | INFO | "./app\services\video.py:190": generate_video -   ③ subtitle: .\storage\tasks\4b001ee5-840d-41b7-84e6-91d61b4c9961\subtitle.srt
2024-05-14 22:32:09 | INFO | "./app\services\video.py:191": generate_video -   ④ output: .\storage\tasks\4b001ee5-840d-41b7-84e6-91d61b4c9961\final-1.mp4
2024-05-14 22:32:09 | INFO | "./app\services\video.py:206": generate_video - using font: D:/code/py/MoneyPrinterTurbo/resource/fonts/MicrosoftYaHeiBold.ttc
2024-05-14 22:32:09.991 Uncaught app exception
Traceback (most recent call last):
  File "D:\tools\anaconda3\envs\MoneyPrinterTurbo\lib\site-packages\moviepy\video\VideoClip.py", line 1262, in __init__
    subprocess_call(cmd, logger=None)
  File "D:\tools\anaconda3\envs\MoneyPrinterTurbo\lib\site-packages\moviepy\tools.py", line 35, in subprocess_call
    proc = sp.Popen(cmd, **popen_params)
  File "D:\tools\anaconda3\envs\MoneyPrinterTurbo\lib\subprocess.py", line 971, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "D:\tools\anaconda3\envs\MoneyPrinterTurbo\lib\subprocess.py", line 1456, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] 系统找不到指定的文件。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\tools\anaconda3\envs\MoneyPrinterTurbo\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 584, in _run_script
    exec(code, module.__dict__)
  File "D:\code\py\MoneyPrinterTurbo\webui\Main.py", line 567, in <module>
    result = tm.start(task_id=task_id, params=params)
  File "D:\code\py\MoneyPrinterTurbo\app\services\task.py", line 173, in start
    video.generate_video(video_path=combined_video_path,
  File "D:\code\py\MoneyPrinterTurbo\app\services\video.py", line 242, in generate_video
    sub = SubtitlesClip(subtitles=subtitle_path, encoding='utf-8')
  File "D:\tools\anaconda3\envs\MoneyPrinterTurbo\lib\site-packages\moviepy\video\tools\subtitles.py", line 104, in __init__
    hasmask = bool(self.make_textclip("T").mask)
  File "D:\tools\anaconda3\envs\MoneyPrinterTurbo\lib\site-packages\moviepy\video\tools\subtitles.py", line 58, in make_textclip
    return TextClip(
  File "<decorator-gen-84>", line 2, in __init__
  File "D:\tools\anaconda3\envs\MoneyPrinterTurbo\lib\site-packages\moviepy\decorators.py", line 89, in wrapper
    return f(*new_a, **new_kw)
  File "D:\tools\anaconda3\envs\MoneyPrinterTurbo\lib\site-packages\moviepy\video\VideoClip.py", line 1272, in __init__
    raise IOError(error)
OSError: MoviePy Error: creation of None failed because of the following error:

[WinError 2] 系统找不到指定的文件。.

.This error can be due to the fact that ImageMagick is not installed on your computer, or (for Windows users) that you didn't specify the path to the ImageMagick binary. Check the docume
ntation.



heihei180 avatar May 14 '24 14:05 heihei180

# imagemagick_path = "C:\\Program Files (x86)\\ImageMagick-7.1.1-Q16\\magick.exe"
# 你要把配置文件前面的 `#` 去掉
imagemagick_path = "C:\\Program Files (x86)\\ImageMagick-7.1.1-Q16\\magick.exe"

你看看是不是没有去掉配置文件中的注释?

harry0703 avatar May 15 '24 02:05 harry0703

感谢你的回复,我的配置是这样的,但是启动之后, imagemagick_path = "C:\\Program Files (x86)\\ImageMagick-7.1.1-Q16\\magick.exe"

这一行代码就会自动消失,不知道为什么? image

heihei180 avatar May 15 '24 12:05 heihei180

我没法复现这个问题,你先更新代码看看。也可以直接把这个配置写死在代码里面试试

# app/config/config.py
imagemagick_path = app.get("imagemagick_path", "")
if imagemagick_path and os.path.isfile(imagemagick_path):
    os.environ["IMAGEMAGICK_BINARY"] = imagemagick_path

harry0703 avatar May 16 '24 01:05 harry0703

我没法复现这个问题,你先更新代码看看。也可以直接把这个配置写死在代码里面试试

# app/config/config.py
imagemagick_path = app.get("imagemagick_path", "")
if imagemagick_path and os.path.isfile(imagemagick_path):
    os.environ["IMAGEMAGICK_BINARY"] = imagemagick_path

感谢回复,我晚上回去更新下试试。

其实这块代码我简单调试了一下,他是可以获取到这个配置,并且也成功赋值给 os.environ["IMAGEMAGICK_BINARY"] 但是不知道为什么,我放行代码,直接运行之后,就会将配置文件重写。。丢失这个配置,所以想问项目现在有这个机制吗?格式化或重写配置文件?

如果没有 的话,等周末我读一下代码,看下具体原因与你反馈。 谢谢!

heihei180 avatar May 16 '24 03:05 heihei180