current position:Home>Opencv Python reads video, processes and saves it frame by frame

Opencv Python reads video, processes and saves it frame by frame

2022-02-01 20:39:53 aikutwo

1. Read video

image.png

2. Save the video

Mainly use this class

CV2.VideoWriter(videooutpath,fourcc, 20.0, (1280,960),True)

videooutpath Output file name

fourcc = CV2.VideoWriter_fourcc(*‘XVID’) Is to specify the encoder

20.0 Is the frame rate

(1280,960) It's video size

True It means color  

Encoder general : “DIVX"、”MJPG"、“XVID”、“X264"

Be careful : If it is MacBook If you open it, use .mp4 Format Fill in here *'mp4v', Otherwise, just change the file suffix to .mp4 Still can't open it

image.png

3. Frame by frame processing

With the first two foundations, it's very simple

image.png

The above is the whole content of this article , Using the method introduced in this paper, the conventional video can be saved frame by frame 、 Cutting and other operations , If you are interested in learning more programming skills, you can watch Teaching video Continue to learn ~

copyright notice
author[aikutwo],Please bring the original link to reprint, thank you.
https://en.pythonmana.com/2022/02/202202012039514686.html

Random recommended