“Grabar video con Python” Código de respuesta

Grabar video con Python

import cv2 # make sure you have open-cv installed
# credit to http://www.learningaboutelectronics.com
# slightly edited by WoefulDeveloper (me)

cap = cv2.VideoCapture(1)

width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
video_speed = 50 # higher number means faster frame rate
video_name = "Video.mp4"
writer = cv2.VideoWriter(video_name,cv2.VideoWriter_fourcc(*'DIVX'), video_speed, (width,height))

while True:
    ret,frame = cap.read()
    writer.write(frame)
    cv2.imshow('frame', frame) # not necessary you can comment this out
    if cv2.waitKey(1) & 0xFF == 27: # waits for the "esc" key to stop the video
        break

cap.release()
writer.release()
cv2.destroyAllWindows()
WoefulDeveloper

Python Video reproducido

<!DOCTYPE html>
<html>
<head>
  <title>Video Example</title>
</head>
<body>
  <h2>Serving video files from Flask template</h2>
  <video width="320" height="240" controls>
    <source src={{ url_for('static', filename="demo.mp4") }} type="video/mp4">
    Your browser does not support the video tag.
  </video>
</body>
</html>
Nagaraj

Respuestas similares a “Grabar video con Python”

Preguntas similares a “Grabar video con Python”

Más respuestas relacionadas con “Grabar video con Python” en Python

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código