Сохранить видео файл Cv2 в другом месте - PullRequest
1 голос
/ 02 августа 2020
• 1000 1002 *

Ответы [ 2 ]

1 голос
/ 02 августа 2020
import os
your_path = "location where you want to save"
try:
    os.mkdir(your_path)
except:
    pass #directory already there
out = cv2.VideoWriter(your_path+'/output.avi',fourcc, 20.0, (640,480))
1 голос
/ 02 августа 2020
import cv2

cam = cv2.VideoCapture(0) # Começa a gravar
# out = cv2.VideoWriter('Teste.avi', -1, 20.0, (640, 480))
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('path//of//location//output.avi',fourcc, 20.0, (640,480))

while (cam.isOpened()):
    op,frame = cam.read()
    if (op == True):
        out.write(frame)
        cv2.imshow('frame',frame)
        if cv2.waitKey(1) & 0xFF == ord('x'):
            break

    else:
        break

cam.release()
out.release()
cv2.destroyAllWindows()

Если у вас есть сомнения, вы можете обратиться к документации .

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...