如何在相对较短的时间内在 OpenCV 中编辑 python 中的视频?

How to edit videos in python in OpenCV in relatively short time?

所以我正在做这样的事情:

fourcc = cv2.VideoWriter_fourcc(*'avi')
source = cv2.VideoCapture('video.avi')
 while(source.isOpened()):
     ret, frame = source.read()
     if(type(frame) != type(None)):
         for line in frame:
             for pixel in line:
                  someedit()

我遇到的问题是,5 秒的 300:400 视频需要大约 5 分钟,即使 someedit() 是像像素 [0]+1 这样的基本内容。 python 做这样的事情通常会变慢,还是有解决方法?

#import deps
import cv2                                                                                                                                                                   
import numpy as np                                                                                                                                                            
#read the video
source = cv2.VideoCapture('videoPath')  
# flag                                                                                                                          
ret = True                                                                                                                                                                    
# iterate through all the frames if the video clip present
while(source.isOpened() and ret):                                                                                                                                                 
    #read the frame
    ret, frame = source.read()                                                                                                                                                    
    #check for flag
    if(ret):       
        # add 1 to 0th channel                                                                                                                                                                   
        frame[:, :, 0] = 1 + frame[:, :, 0]                                                                                                                                   
print("Done")