Spaces:
Runtime error
Runtime error
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() |