티스토리 뷰

SWDesk

[Python4Video] ExtractOutlinefromVideo()

bizmaker 2023. 12. 6. 18:15
Parameter Description Remarks
SourceVideoPath    
MovingOutline "Y" "Y", None
OutputVideoPath    
OutlineColor [0, 255, 255] [R, G, B]

 

def Test_ExtractOutlinefromVideo():
    param1 = {
        'SourceVideoPath': "./DanceVideos/Dance132.mp4",
        'MovingOutline': "Y",
        'OutputVideoPath': "./VideoOutput/Test001.mp4",
        'OutlineColor': [0, 255, 255]
    }

    videoClass.ExtractOutlinefromVideo(param1)
    def ExtractOutlinefromVideo(self, paramIn):
        # paramIn : {'SourceVideoPath', 'OutlineColor', 'MovingOutline', 'TransparentOption', 'OutputVideoPath'}
        print("Starting ...... ExtractOutlinefromVideo()")

        sourceVideoPath = paramIn.get('SourceVideoPath')
        movingOutline = paramIn.get('MovingOutline')
        outPath = paramIn.get('OutputVideoPath')
        if not outPath: outPath = self.OutputFolder + "/Video" + bTime.GetDateString() + "_" + str(random.randint(2000, 3000)) + ".mp4"

        outlineColor = paramIn.get('OutlineColor') # [255, 0, 0]
        self.OutlineColor = outlineColor

        # Load the video
        clip = VideoFileClip(sourceVideoPath)
##        audio = AudioFileClip(sourceVideoPath)

        # Initialize the previous frame
        prev_frame = None
        self.prevFrame = None

        # Apply the function to each frame of the video
        if movingOutline: outline_clip = clip.fl_image(lambda image: self.ExtractMovingOutline(image, ))
        else: outline_clip = clip.fl_image(lambda image: self.ExtractOutline(image, ))
        outline_clip = outline_clip.without_audio()

        # Write the result to a file
##        outline_clip = outline_clip.set_audio(audio)
        outline_clip.write_videofile(outPath, codec='libx264')

        return outPath

 

 

 

 

 

반응형

'SWDesk' 카테고리의 다른 글

[Python] Methods for 'List'  (0) 2023.12.16
[Python] Serial 통신 예제  (0) 2023.12.14
[Python] 오디오 파일의 재생 속도 연장(재생시간 축소)  (0) 2023.11.24
[Python] Convert mp3 to wav  (0) 2023.11.23
[Python] Frequency Shift  (0) 2023.11.23