input_path = "input_video1.mp4" output_path = "output_video123.mp4"
cap = cv2.VideoCapture(input_path)
fps = cap.get(cv2.CAP_PROP_FPS) width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
fourcc = cv2.VideoWriter_fourcc(*'mp4v') out = cv2.VideoWriter(output_path, fourcc, fps, (width, height))
frame_count = 0 while cap.isOpened(): ret, frame = cap.read() if not ret: break
if frame_count % 4 == 0:
out.write(frame)
frame_count += 1
cap.release() out.release() cv2.destroyAllWindows()