Skip to content

Video for py5 #266

Answered by villares
villares asked this question in Q&A
Mar 23, 2023 · 3 comments · 10 replies
Discussion options

You must be logged in to vote

Maybe we should avoid Processing Video and use OpenCV instead... this works, adapted from my webcam capture code, with a few tweaks:

import py5
import cv2
import numpy as np
from py5 import create_image_from_numpy

movie = cv2.VideoCapture('launch2.mp4')
movie_width = int(movie.get(cv2.CAP_PROP_FRAME_WIDTH))
movie_height = int(movie.get(cv2.CAP_PROP_FRAME_HEIGHT))
fps = movie.get(cv2.CAP_PROP_FPS)

py5_img = None

def setup():
    py5.size(movie_width, movie_height)
    py5.frame_rate(fps)

def draw():
    global py5_img
    success, frame = movie.read()  # frame is a numpy array
    if success:
#         gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
#         edges = cv2.Canny(gray, 100…

Replies: 3 comments 10 replies

Comment options

You must be logged in to vote
4 replies
@villares
Comment options

villares Mar 24, 2023
Collaborator Author

@hx2A
Comment options

hx2A Mar 25, 2023
Maintainer

@villares
Comment options

villares Mar 25, 2023
Collaborator Author

@hx2A
Comment options

hx2A Mar 25, 2023
Maintainer

Comment options

villares
Mar 26, 2023
Collaborator Author

You must be logged in to vote
3 replies
@hx2A
Comment options

hx2A Mar 27, 2023
Maintainer

@villares
Comment options

villares Mar 27, 2023
Collaborator Author

@villares
Comment options

villares Mar 27, 2023
Collaborator Author

Comment options

villares
Mar 27, 2023
Collaborator Author

You must be logged in to vote
3 replies
@hx2A
Comment options

hx2A Mar 30, 2023
Maintainer

@villares
Comment options

villares Mar 30, 2023
Collaborator Author

@hx2A
Comment options

hx2A Mar 31, 2023
Maintainer

Answer selected by villares
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants