The HTML code is as follows, novice, may not be standard, still hope to give directions (comment better design) :
# coding: utf-8
The import OS
The import cv2
The import numpy as np
The import time
The from PIL import Image
Cap=cv2. VideoCapture (' E: \ \ 00 mp4) # is correct, no problem of
# Define the codec and create VideoWriter object
Fourcc=cv2. VideoWriter_fourcc (* 'XVID')
Out=cv2. VideoWriter (' output. Avi, fourcc, 20.0, (768432)) # each frame of video high 768 wide 432
Frames=[] # save every frame image collection
While (cap) isOpened ()) :
Ret, frame=cap. The read () # skip judgment, practice shows no effect
Frames. Append (frame)
If cv2. WaitKey (2)==27:
Break
# frames=array (frames)
For frame in frames:
Out. Write (frame) # write each frame to the output video file. The avi, but only 6 k, if he does not support continuous writing, he only kept a frame??
# release window
Cap. Release ()
Out. Release ()
Cv2. DestroyAllWindows ()
CodePudding user response:
Will * 'XVID' for 'X', 'V', 'I', 'D', and note if each file exists,