简体   繁体   中英

Unable to save the video using opencv in videoWriter module in python

Below is the code snippet.

fourcc = cv2.VideoWriter_fourcc(*)
out = cv2.VideoWriter('/Users\Dell\Documents\GitHub\capstoneproject\ProjectS\sample\example_03.mp4',fourcc, 20.0, (640,480))

while(cap.isOpened()):
    ret, frame = cap.read()


        # write the flipped frame
    out.write(frame)

    cv2.imshow('frame',frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

in the above it is not able to save the video.

I think you forgot to provide the type of codec. The proper code should be.

fourcc = cv2.VideoWriter_fourcc(*'type of codec')

type of codec can be mp4, XVID etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM