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