일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- keras
- FIle
- shakeratos
- object detection
- dlib
- download
- colab
- Windows 10
- raspberry pi
- face_recognition
- 딥러닝
- CUDA
- urllib
- python
- Deep Learning
- error
- python3
- dataset
- TensorFlow
- Anaconda
- pyTorch
- Jupyter notebook
- colaboratory
- gpu memory
- windows
- YouTube 8M
- linux
- ubuntu
- ppc64le
- install
- Today
- Total
Shakerato
cv2.VideoWriter always saves 5.55kb(5.5kb) video file (not working) 본문
cv2.VideoWriter always saves 5.55kb(5.5kb) video file (not working)
Shakeratto 2019. 6. 10. 15:34The reason why cv2.2VdeoWriter can't save the video content with correct code is the output video's width, height size is different with input video's width, height size.
You need to match them using below code.
import cv2 cap = cv2.VideoCapture('input.mp4')
vid_width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) vid_height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
fourcc = cv2.VideoWriter_fourcc(*'XVID') out = cv2.VideoWriter('output.avi', fourcc, 20.0, (vid_width, vid_height))
while(cap.isOpened()): ret,frame = cap.read() if ret is False: break
# Image Processing
out.write(frame) cv2.imshow('frame', frame)
k = cv2.waitKey(50) & 0xff if k == 27: # Escape (ESC) break
cap.release() out.release() cv2.destroyAllWindows() |