harry0703 / MoneyPrinterTurbo

利用AI大模型,一键生成高清短视频 Generate short videos with one click using AI LLM.
MIT License
16.46k stars 2.62k forks source link

根据您提供的错误日志,问题出现在使用 moviepy 库对视频进行尺寸调整时,具体是在调用 resize 方法时引发了 AttributeError 异常。这个异常是因为 PIL.Image 模块中没有找到 ANTIALIAS 属性。 #83

Closed FlowersWithoutMoon closed 6 months ago

FlowersWithoutMoon commented 6 months ago

运行提示如下: Current directory: D:\Software\Git\dates\MoneyPrinterTurbo\MoneyPrinterTurbo

You can now view your Streamlit app in your browser.

Local URL: http://localhost:8501 Network URL: (隐藏)

2024-03-28 09:42:20.032 | INFO | app.config.config::8 - load config from file: D:\Software\Git\dates\MoneyPrinterTurbo\MoneyPrinterTurbo/config.toml 2024-03-28 09:43:39 | INFO | "./app\services\llm.py:103": generate_script - subject: 火星 陨落日本的场面 2024-03-28 09:43:39 | DEBUG | "./app\services\llm.py:104": generate_script - prompt:

Role: Video Script Generator

Goals:

Generate a script for a video, depending on the subject of the video.

Constrains:

  1. the script is to be returned as a string with the specified number of paragraphs.

  2. do not under any circumstance reference this prompt in your response.

  3. get straight to the point, don't start with unnecessary things like, "welcome to this video".

  4. you must not include any type of markdown or formatting in the script, never use a title.

  5. only return the raw content of the script.

  6. do not include "voiceover", "narrator" or similar indicators of what should be spoken at the beginning of each paragraph or line.

  7. you must not mention the prompt, or anything about the script itself. also, never talk about the amount of paragraphs or lines. just write the script.

  8. respond in the same language as the video subject.

Initialization:

Goals:

Generate 5 search terms for stock videos, depending on the subject of a video.

Constrains:

  1. the search terms are to be returned as a json-array of strings.
  2. each search term should consist of 1-3 words, always add the main subject of the video.
  3. you must only return the json-array of strings. you must not return anything else. you must not return the script.
  4. the search terms must be related to the subject of the video.
  5. reply with english search terms only.

Output Example:

["search term 1", "search term 2", "search term 3","search term 4","search term 5"]

Context:

Video Subject

火星陨落日本的场面

Video Script

火星陨落日本的场景是一幕史诗般的天文现象,吸 引了全世界的目光。每当火星与地球距离接近时, 它会明亮地照亮夜空,成为天文爱好者和摄影师梦 寐以求的拍摄对象。在日本,这一景象尤为特别, 因为其独特的地理和文化背景为观测提供了完美的 舞台。从富士山到东京塔,火星的亮相为这些标志 性地点增添了一抹神秘色彩,使得这一天文事件不 仅仅是科学的展 示,同时也成为了文化的盛会。 2024-03-28 09:43:49 | INFO | "./app\services\llm.py:15": _generate_response - llm provider: openai 2024-03-28 09:43:53 | SUCCESS | "./app\services\llm.py:182": generate_terms - completed: ['Mars eclipse Japan', 'astronomical phenomenon', 'night sky Mars', 'Mars viewing Japan', 'iconic locations Mars'] 2024-03-28 09:44:24 | INFO | "./webui\Main.py:262": - 开始生成视频 2024-03-28 09:44:24 | INFO | "./app\services\task.py:41": start - start task: e85d935d-f409-4fc6-b126-88a179f78833 2024-03-28 09:44:24 | INFO | "./app\services\task.py:48": start -

generating video script

2024-03-28 09:44:24 | DEBUG | "./app\services\task.py:54": start - video script: 火星陨落日本的场景是一幕史诗般的天文现象,吸 引了全世界的目光。每当火星与地球距离接近时, 它会明亮地照亮夜空,成为天文爱好者和摄影师梦 寐以求的拍摄对象。在日本,这一景象尤为特别, 因为其独特的地理和文化背景为观测提供了完美的 舞台。从富士山到东京塔,火星的亮相为这些标志 性地点增添了一抹神秘色彩,使得这一天文事件不 仅仅是科学的展 示,同时也成为了文化的盛会。 2024-03-28 09:44:24 | INFO | "./app\services\task.py:56": start -

generating video terms

2024-03-28 09:44:24 | DEBUG | "./app\services\task.py:68": start - video terms: [ "Mars eclipse Japan", "astronomical phenomenon", "night sky Mars", "Mars viewing Japan", "iconic locations Mars" ] 2024-03-28 09:44:24 | INFO | "./app\services\task.py:79": start -

generating audio

2024-03-28 09:44:24 | INFO | "./app\services\voice.py:12": tts - start, voice name: zh-CN-XiaoxiaoNeural 2024-03-28 09:44:26 | INFO | "./app\services\voice.py:26": tts - completed, output file: .\storage\tasks\e85d935d-f409-4fc6-b126-88a179f78833\audio.mp3 2024-03-28 09:44:26 | INFO | "./app\services\task.py:94": start -

generating subtitle, provider: edge

2024-03-28 09:44:26 | INFO | "./app\services\task.py:117": start -

downloading videos

2024-03-28 09:44:26 | INFO | "./app\services\material.py:44": search_videos - searching videos: https://api.pexels.com/videos/search?query=Mars+eclipse+Japan&per_page=20&orientation=portrait, with proxies: {} 2024-03-28 09:44:27 | INFO | "./app\services\material.py:104": download_videos - found 17 videos for 'Mars eclipse Japan' 2024-03-28 09:44:27 | INFO | "./app\services\material.py:44": search_videos - searching videos: https://api.pexels.com/videos/search?query=astronomical+phenomenon&per_page=20&orientation=portrait, with proxies: {} 2024-03-28 09:44:28 | INFO | "./app\services\material.py:104": download_videos - found 6 videos for 'astronomical phenomenon' 2024-03-28 09:44:28 | INFO | "./app\services\material.py:44": search_videos - searching videos: https://api.pexels.com/videos/search?query=night+sky+Mars&per_page=20&orientation=portrait, with proxies: {} 2024-03-28 09:44:29 | INFO | "./app\services\material.py:104": download_videos - found 19 videos for 'night sky Mars' 2024-03-28 09:44:29 | INFO | "./app\services\material.py:44": search_videos - searching videos: https://api.pexels.com/videos/search?query=Mars+viewing+Japan&per_page=20&orientation=portrait, with proxies: {} 2024-03-28 09:44:31 | INFO | "./app\services\material.py:104": download_videos - found 14 videos for 'Mars viewing Japan' 2024-03-28 09:44:31 | INFO | "./app\services\material.py:44": search_videos - searching videos: https://api.pexels.com/videos/search?query=iconic+locations+Mars&per_page=20&orientation=portrait, with proxies: {} 2024-03-28 09:44:32 | INFO | "./app\services\material.py:104": download_videos - found 19 videos for 'iconic locations Mars' 2024-03-28 09:44:32 | INFO | "./app\services\material.py:112": download_videos - found total videos: 58, required duration: 37 seconds, found duration: 792.0 seconds 2024-03-28 09:44:32 | INFO | "./app\services\material.py:123": download_videos - downloading video: https://videos.pexels.com/video-files/7957512/7957512-hd_1080_1920_24fps.mp4 2024-03-28 09:44:35 | INFO | "./app\services\material.py:123": download_videos - downloading video: https://videos.pexels.com/video-files/7958544/7958544-hd_1080_1920_24fps.mp4 2024-03-28 09:44:37 | INFO | "./app\services\material.py:123": download_videos - downloading video: https://videos.pexels.com/video-files/7957505/7957505-hd_1080_1920_24fps.mp4 2024-03-28 09:44:39 | INFO | "./app\services\material.py:123": download_videos - downloading video: https://videos.pexels.com/video-files/8474606/8474606-hd_1080_1920_30fps.mp4 2024-03-28 09:44:41 | INFO | "./app\services\material.py:123": download_videos - downloading video: https://videos.pexels.com/video-files/8474604/8474604-hd_1080_1920_30fps.mp4 2024-03-28 09:44:43 | INFO | "./app\services\material.py:123": download_videos - downloading video: https://videos.pexels.com/video-files/5236699/5236699-hd_1080_1920_30fps.mp4 2024-03-28 09:44:45 | INFO | "./app\services\material.py:123": download_videos - downloading video: https://videos.pexels.com/video-files/8474624/8474624-hd_1080_1920_30fps.mp4 2024-03-28 09:44:48 | INFO | "./app\services\material.py:123": download_videos - downloading video: https://videos.pexels.com/video-files/5828443/5828443-hd_1080_1920_24fps.mp4 2024-03-28 09:44:50 | INFO | "./app\services\material.py:123": download_videos - downloading video: https://videos.pexels.com/video-files/6831465/6831465-hd_1080_1920_25fps.mp4 2024-03-28 09:44:53 | INFO | "./app\services\material.py:123": download_videos - downloading video: https://videos.pexels.com/video-files/8474652/8474652-hd_1080_1920_30fps.mp4 2024-03-28 09:44:54 | INFO | "./app\services\material.py:123": download_videos - downloading video: https://videos.pexels.com/video-files/17670609/17670609-hd_1080_1920_24fps.mp4 2024-03-28 09:44:56 | INFO | "./app\services\material.py:123": download_videos - downloading video: https://videos.pexels.com/video-files/7958755/7958755-hd_1080_1920_24fps.mp4 2024-03-28 09:44:58 | INFO | "./app\services\material.py:123": download_videos - downloading video: https://videos.pexels.com/video-files/7958071/7958071-hd_1080_1920_24fps.mp4 2024-03-28 09:45:00 | INFO | "./app\services\material.py:129": download_videos - total duration of downloaded videos: 39.0 seconds, skip downloading more 2024-03-28 09:45:00 | SUCCESS | "./app\services\material.py:133": download_videos - downloaded 13 videos 2024-03-28 09:45:00 | INFO | "./app\services\task.py:138": start -

combining video: 1 => .\storage\tasks\e85d935d-f409-4fc6-b126-88a179f78833\combined-1.mp4

2024-03-28 09:45:00 | INFO | "./app\services\video.py:39": combine_videos - max duration of audio: 37.15 seconds 2024-03-28 09:45:00 | INFO | "./app\services\video.py:43": combine_videos - each clip will be maximum 3 seconds long 2024-03-28 09:45:04 | INFO | "./app\services\video.py:83": combine_videos - resizing video to 1080 x 1920 2024-03-28 09:45:04.428 Uncaught app exception Traceback (most recent call last): File "D:\Software\Anaconda\Lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 542, in _run_script exec(code, module.dict) File "D:\Software\Git\dates\MoneyPrinterTurbo\MoneyPrinterTurbo\webui\Main.py", line 264, in tm.start(task_id=task_id, params=cfg) File "D:\Software\Git\dates\MoneyPrinterTurbo\MoneyPrinterTurbo\app\services\task.py", line 139, in start video.combine_videos(combined_video_path=combined_video_path, File "D:\Software\Git\dates\MoneyPrinterTurbo\MoneyPrinterTurbo\app\services\video.py", line 84, in combine_videos clip = clip.resize((video_width, video_height)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Software\Anaconda\Lib\site-packages\moviepy\video\fx\resize.py", line 165, in resize newclip = clip.fl_image(fl) ^^^^^^^^^^^^^^^^^ File "D:\Software\Anaconda\Lib\site-packages\moviepy\video\VideoClip.py", line 576, in fl_image return self.fl(lambda gf, t: image_func(gf(t)), apply_to) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Software\Anaconda\Lib\site-packages\moviepy\Clip.py", line 141, in fl newclip = self.set_make_frame(lambda t: fun(self.get_frame, t)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 2, in set_make_frame File "D:\Software\Anaconda\Lib\site-packages\moviepy\decorators.py", line 15, in outplace f(newclip, *a, *k) File "D:\Software\Anaconda\Lib\site-packages\moviepy\video\VideoClip.py", line 740, in set_make_frame self.size = self.get_frame(0).shape[:2][::-1] ^^^^^^^^^^^^^^^^^ File "", line 2, in get_frame File "D:\Software\Anaconda\Lib\site-packages\moviepy\decorators.py", line 89, in wrapper return f(new_a, **new_kw) ^^^^^^^^^^^^^^^^^^^ File "D:\Software\Anaconda\Lib\site-packages\moviepy\Clip.py", line 98, in get_frame return self.make_frame(t) ^^^^^^^^^^^^^^^^^^ File "D:\Software\Anaconda\Lib\site-packages\moviepy\Clip.py", line 141, in newclip = self.set_make_frame(lambda t: fun(self.get_frame, t)) ^^^^^^^^^^^^^^^^^^^^^^ File "D:\Software\Anaconda\Lib\site-packages\moviepy\video\VideoClip.py", line 576, in return self.fl(lambda gf, t: image_func(gf(t)), apply_to) ^^^^^^^^^^^^^^^^^ File "D:\Software\Anaconda\Lib\site-packages\moviepy\video\fx\resize.py", line 163, in fl return resizer(pic.astype("uint8"), newsize) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Software\Anaconda\Lib\site-packages\moviepy\video\fx\resize.py", line 37, in resizer resized_pil = pilim.resize(newsize[::-1], Image.ANTIALIAS)

^^^^^^^^^^^^^^^ AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS'

harry0703 commented 6 months ago

试试降级 Pillow 的版本看看

pip uninstall Pillow
pip install Pillow==9.5.0
FlowersWithoutMoon commented 6 months ago

这个方法可以,谢谢

试试降级 Pillow 的版本看看

pip uninstall Pillow
pip install Pillow==9.5.0