output_dir = "/content/drive/MyDrive/crop_monitoring_project/videos/"
# Set the video parameters
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
frame_shape = cv2.imread(test_data_path_list[0]).shape # 저장할 프레임의 크기는 인풋 이미지의 사이즈로
video_height = frame_shape[0]
video_width = frame_shape[1]
frame_rate = 2
# Create the video writer
out = cv2.VideoWriter("file_path/file_name.mp4", fourcc, frame_rate, (video_width, video_height))
# Create frames to saving video
for i in range(len(test_data_path_list)):
file_path = test_data_path_list[i]
frame = cv2.imread(file_path)
# Add the image to the video
out.write(frame)
# Release the video writer
out.release()
Reference
https://github.com/ContinuumIO/anaconda-issues/issues/223
opencv - not writing output with cv2.VideoWriter.write · Issue #223 · ContinuumIO/anaconda-issues
OpenCV is not writing to output video files with cv2.VideoWriter.write. I only get an empty video file (8 KB) and no error messages. Where is the problem? Thanks a lot! I am running 2.7.8 |Anaconda...
github.com
728x90
'Computer Vision' 카테고리의 다른 글
[Object Tracking] SORT(Simple Online and Realtime Tracking) 논문 정리 (0) | 2023.03.13 |
---|---|
[CV] Histogram of Oriented Gradients (0) | 2023.02.23 |
[OpenCV] cv2.VideoCapture() RTSP Frame이 준비될때까지 기다리기(feat. chatGPT) (0) | 2022.12.22 |
[Python / OpenCV] M1 Mac / VScode / opencv 설치하기 (0) | 2022.06.03 |