HALU-HAL's picture
update files
6ed89af
raw
history blame
2.05 kB
from PIL import Image, ImageFilter
import random
import os
from pathlib import Path
import cv2
import numpy as np
from modules.utils import v_image_blurred_utils
from modules.BlurredBackgroundEmbedder import BlurredBackgroundEmbedder
from modules.FrameVideoCreator import FrameVideoCreator
from modules.Transition.VideoMergerWithSmoothTransition import VideoMergerWithSmoothTransition
class VideoProcessingPipeline:
def __init__(self, image_folder: str):
"""
VideoProcessingPipeline ใ‚ฏใƒฉใ‚นใฎๅˆๆœŸๅŒ–้–ขๆ•ฐ
ๅผ•ๆ•ฐ:
- image_folder: ็”ปๅƒใŒๆ ผ็ดใ•ใ‚Œใฆใ„ใ‚‹ใƒ•ใ‚ฉใƒซใƒ€ใฎใƒ‘ใ‚น
"""
self.image_folder = image_folder
self.blurred_folder = f"{image_folder}_Blurred"
self.video_folder = f"{self.blurred_folder}_mov"
self.final_folder = f"{self.video_folder}_Final"
def process_images(self):
"""
็”ปๅƒใฎใƒ–ใƒฉใƒผๅ‡ฆ็†ใ‚’ๅฎŸ่กŒ
"""
processor = BlurredBackgroundEmbedder(self.image_folder)
processor.process_all_images()
def create_videos_from_images(self):
"""
ใƒ–ใƒฉใƒผๅ‡ฆ็†ใ•ใ‚ŒใŸ็”ปๅƒใ‹ใ‚‰ๅ‹•็”ปใ‚’ไฝœๆˆ
"""
video_creator = FrameVideoCreator()
video_creator.process_folder(self.blurred_folder)
def merge_videos(self):
"""
็”Ÿๆˆใ•ใ‚ŒใŸๅ‹•็”ปใ‚’้€ฃ็ต
"""
os.makedirs(self.final_folder, exist_ok=True)
output_video_path = os.path.join(self.final_folder, "concatenated_video.mp4")
merger = VideoMergerWithSmoothTransition()
merger.merge_videos(self.video_folder, output_video_path)
def execute_pipeline(self):
"""
็”ปๅƒใฎๅ‡ฆ็†ใ€ๅ‹•็”ปใฎไฝœๆˆใ€ๅ‹•็”ปใฎ้€ฃ็ตใ‚’้ †็•ชใซๅฎŸ่กŒ
"""
self.process_images()
self.create_videos_from_images()
self.merge_videos()
print("Video processing completed!")
if __name__ == '__main__':
pipeline = VideoProcessingPipeline(r"image\The-Multifaceted-Dawn")
pipeline.execute_pipeline()