while Condition1:
    frame = cv.RetrieveFrame(capture)
video_out = cv.CreateVideoWriter(output_filenameX, CV_FOURCC('M', 'J', 'P',
    'G'), capture.fps, frame.size(), 1)
cv.WriteFrame(video_out, frame)
while Condition2:
    frame = cv.RetrieveFrame(capture)
библиотека python для разделения видео