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()