LoginSignup
0
3

More than 3 years have passed since last update.

Pythonで動画再生する方法(自分用)

Posted at

import cv2
import sys

file_path = 'file' //ファイル置いてる場所
delay = 1 //再生スピード調整
window_name = 'frame'

cap = cv2.VideoCapture(file_path)

if not cap.isOpened():
sys.exit()

while True:
ret, frame = cap.read()
if ret:
cv2.imshow(window_name, frame)
if cv2.waitKey(delay) & 0xFF == ord('q'):
break
else:
cap.set(cv2.CAP_PROP_POS_FRAMES, 0)

cv2.destroyWindow(window_name)

0
3
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
3