import cv2 # 读取原始的 mp4 文件 input_video_path = 'C:\\Users\\liangchengming5\\PycharmProjects\\pythonProject\\Car_and_person.mp4' cap = cv2.VideoCapture(input_video_path) # 设置输出视频的参数 output_video_path = 'car_and_person_output_640.mp4' fourcc = cv2.VideoWriter_fourcc(*'avc1') # 使用 H.264 编码器 out = cv2.VideoWriter(output_video_path, fourcc, 25.0, (640, 480)) # 分辨率设为 640x480 while cap.isOpened(): ret, frame = cap.read() if not ret: break # 改变帧的分辨率为 640x480 frame_resized = cv2.resize(frame, (640, 480)) # 写入新视频 out.write(frame_resized) cap.release() out.release()
调节mp4文件分辨率
最新推荐文章于 2024-08-24 22:14:07 发布