OpenCV has Python wrappers .
Since you're interested in IO video, check out the QueryFrame and its related features.
In the end, your code will look something like this (completely untested):
import cv capture = cv.CaptureFromFile(filename) while Condition1: # Need a frame to get the output video dimensions frame = cv.RetrieveFrame(capture) # Will return None if there are no frames # New video file video_out = cv.CreateVideoWriter(output_filenameX, CV_FOURCC('M','J','P','G'), capture.fps, frame.size(), 1) # Write the frames cv.WriteFrame(video_out, frame) while Condition2: frame = cv.RetrieveFrame(capture) # Will return None if there are no frames cv.WriteFrame(video_out, frame)
By the way, there are ways to do this without writing code .
misha
source share