利用 AI 大模型和自动化工作流,根据主题或关键词一键生成高清短视频。Generate HD short videos from a topic or keyword with an automated AI workflow.
Python ai-video-generatorcontent-creationffmpeginstagram-reelsllmpythonshort-videosubtitlestext-to-speechtiktokvideo-automationvideo-workflowworkflow-automationyoutube-shorts
added validation for video file using moviepy to ensure video file is valid before processing.
harrya8d208bdc34a
diff --git a/app/services/material.py b/app/services/material.pyindex 0f16a2e7..e2a65cc6 100644--- a/app/services/material.py+++ b/app/services/material.py@@ -5,6 +5,7 @@ from urllib.parse import urlencodeimport requestsfrom typing import Listfrom loguru import logger+from moviepy.video.io.VideoFileClip import VideoFileClipfrom app.config import configfrom app.models.schema import VideoAspect, VideoConcatMode, MaterialInfo@@ -105,7 +106,19 @@ def save_video(video_url: str, save_dir: str = "") -> str:f.write(requests.get(video_url, proxies=proxies, verify=False, timeout=(60, 240)).content)if os.path.exists(video_path) and os.path.getsize(video_path) > 0:- return video_path+ try:+ clip = VideoFileClip(video_path)+ duration = clip.duration+ fps = clip.fps+ clip.close()+ if duration > 0 and fps > 0:+ return video_path+ except Exception as e:+ try:+ os.remove(video_path)+ except Exception as e:+ pass+ logger.warning(f"invalid video file: {video_path} => {str(e)}")return ""