Tôi có một mã như thế này:Python và OpenCV - Không thể ghi có thể đọc được các file video avi
import numpy as np
import cv2
cap = cv2.VideoCapture('C:/Users/Hilman/haatsu/drive_recorder/sample/3.mov')
# Define the codec and create VideoWriter object
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('output.avi', fourcc, 20.0, (640,480))
while(cap.isOpened()):
ret, frame = cap.read()
if ret==True:
frame = cv2.flip(frame,0)
# write the flipped frame
out.write(frame)
cv2.imshow('frame',frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
else:
break
# Release everything if job is finished
cap.release()
out.release()
cv2.destroyAllWindows()
Nhưng output.avi
không thể chơi.
Đã thử cũng thay đổi out = cv2.VideoWriter('output.avi', fourcc, 20.0, (640,480))
thành nội dung như thế này (theo đề xuất của một số người) out = cv2.VideoWriter('output.avi', -1, 20.0, (640,480))
. Nhưng khi tôi làm điều này, tôi nhận được thông báo này
OpenCV: FFMPEG: tag 0xffffffff/' ' is not found (format 'avi/AVI (Audio Video Interleaved)')'
.
Điều gì có thể là vấn đề? Tôi đang sử dụng Windows 10 bằng cách này.
OP đang sử dụng Windows 10. –
Có, bạn đã đề cập đến điều đó trong câu hỏi của bạn. Tôi đã hy vọng rằng điều này sẽ làm việc trên máy tính của bạn như nó trên tôi. –