用于分割视频的python库

pss*_*pss 9 python video

我需要按时间将大视频文件拆分成小块.请给我你的建议,如果你有一些关于图书馆使用的提示.谢谢.

mpe*_*kov 6

OpenCVPython包装器.

由于您对视频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)

顺便说一句,还有一些方法可以在不编写任何代码的情况下完成此操作.

  • 没问题。通常,通过接受答案(单击对勾符号)可以更好地做出诸如“谢谢,这就是我所需要的”之类的注释。很高兴您可以解决这个问题。欢迎使用stackoverflow。 (2认同)