Spaces:
Runtime error
Runtime error
File size: 2,048 Bytes
6ed89af |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
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() |