由于您对视频IO感兴趣,请查看QueryFrame及其相关功能.
最后,您的代码看起来像这样(完全未经测试):
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)
Run Code Online (Sandbox Code Playgroud)
顺便说一句,还有一些方法可以在不编写任何代码的情况下完成此操作.
| 归档时间: |
|
| 查看次数: |
11017 次 |
| 最近记录: |