From da0ac0be79b3e5fcee42e5a8bbd74631ceeaecfb Mon Sep 17 00:00:00 2001 From: "WINDOWS\\admin" <1700712032@qq.com> Date: Mon, 30 Jun 2025 09:21:33 +0800 Subject: [PATCH] Fix filename length issue for long prompts: Limit prompt to 20 chars, remove special characters, replace spaces with underscores. Applied to generate_video.py and generate_video_df.py. Resolves issue with long prompts. --- generate_video.py | 4 +++- generate_video_df.py | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/generate_video.py b/generate_video.py index 61e1394..1a66f94 100644 --- a/generate_video.py +++ b/generate_video.py @@ -156,6 +156,8 @@ if local_rank == 0: current_time = time.strftime("%Y-%m-%d_%H-%M-%S", time.localtime()) - video_out_file = f"{args.prompt[:100].replace('/','')}_{args.seed}_{current_time}.mp4" + # Limit filename length and remove special characters + safe_prompt = args.prompt[:20].replace('/', '').replace('\\', '').replace(':', '').replace('*', '').replace('?', '').replace('"', '').replace('<', '').replace('>', '').replace('|', '').replace(' ', '_') + video_out_file = f"{safe_prompt}_{args.seed}_{current_time}.mp4" output_path = os.path.join(save_dir, video_out_file) imageio.mimwrite(output_path, video_frames, fps=args.fps, quality=8, output_params=["-loglevel", "error"]) diff --git a/generate_video_df.py b/generate_video_df.py index 990ef61..5684ebe 100644 --- a/generate_video_df.py +++ b/generate_video_df.py @@ -12,8 +12,8 @@ from skyreels_v2_infer.modules import download_model from skyreels_v2_infer.pipelines import PromptEnhancer from skyreels_v2_infer.pipelines.image2video_pipeline import resizecrop -from moviepy.editor import VideoFileClip - +#from moviepy.editor import VideoFileClip +from moviepy import * def get_video_num_frames_moviepy(video_path): with VideoFileClip(video_path) as clip: @@ -215,6 +215,8 @@ def get_video_num_frames_moviepy(video_path): if local_rank == 0: current_time = time.strftime("%Y-%m-%d_%H-%M-%S", time.localtime()) - video_out_file = f"{args.prompt[:100].replace('/','')}_{args.seed}_{current_time}.mp4" + # Limit filename length and remove special characters + safe_prompt = args.prompt[:20].replace('/', '').replace('\\', '').replace(':', '').replace('*', '').replace('?', '').replace('"', '').replace('<', '').replace('>', '').replace('|', '').replace(' ', '_') + video_out_file = f"{safe_prompt}_{args.seed}_{current_time}.mp4" output_path = os.path.join(save_dir, video_out_file) imageio.mimwrite(output_path, video_frames, fps=fps, quality=8, output_params=["-loglevel", "error"])