“Rekam video dengan Python” Kode Jawaban

Rekam video dengan 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

Putar video Python

<!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

Jawaban yang mirip dengan “Rekam video dengan Python”

Pertanyaan yang mirip dengan “Rekam video dengan Python”

Lebih banyak jawaban terkait untuk “Rekam video dengan Python” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya