일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- error
- pyTorch
- YouTube 8M
- Deep Learning
- dlib
- Jupyter notebook
- windows
- colaboratory
- shakeratos
- ubuntu
- colab
- download
- TensorFlow
- linux
- raspberry pi
- install
- CUDA
- python
- Anaconda
- urllib
- Windows 10
- 딥러닝
- ppc64le
- object detection
- face_recognition
- python3
- FIle
- keras
- dataset
- gpu memory
- 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() |