Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory ingeasing till freeze while using bge.texture.VideoFFmpeg("Webcam", 0) as video texture on Linux #1881

Open
spezi opened this issue Apr 15, 2024 · 0 comments

Comments

@spezi
Copy link

spezi commented Apr 15, 2024

Hi ..

if using bge.texture.VideoFFmpeg with Camera input as video texture ingreases memory usage till system freeze on Linux.
To reproduce using following example: https://blenderartists.org/uploads/short-url/pz35WU9XUCPJxOyCTnGzC2HNwEb.zip

using bge.texture.VideoFFmpeg() with a video file, the problem doesn't occur.
I tried things like gc.collect() to clear the memory with no luck.

Script for setting texture from the example .blend File:

import bge
import sys

from collections import OrderedDict

if not hasattr(bge, "__component__"):
    # Put shared definitions here executed only in game engine.
    # e.g:
    # scene = bge.logic.getCurrentScene()
    pass

class Play(bge.types.KX_PythonComponent):
    # Put your arguments here of the format ("key", default_value).
    # These values are exposed to the UI.
    args = OrderedDict([
        ("File", "//my_file.avi"),
        ("Speed", 1.0),
        ("Repeat", -1),
        ("Flip", True),
    ])

    def start(self, args):
        self.file = args["File"]
        self.framerate = args["Speed"]
        self.repeat = args["Repeat"]
        self.flip = args["Flip"]

        path = bge.logic.expandPath(self.file)
        self.tex = bge.texture.Texture(self.object, 0, 0)
        self.tex.source = bge.texture.VideoFFmpeg(path)
        self.tex.source.repeat = self.repeat
        self.tex.source.scale = True
        self.tex.source.flip = self.flip
        self.tex.source.framerate = self.framerate
        self.tex.source.play()

    def update(self):
        self.tex.refresh(True)

class Capture(bge.types.KX_PythonComponent):
    # Put your arguments here of the format ("key", default_value).
    # These values are exposed to the UI.
    args = OrderedDict([
        ("Camera", "Camera_Name"),
        ("Framerate", 30.0),
        ("Width", 640),
        ("Height", 480),
        ("Flip", True),
    ])

    def start(self, args):
        self.camera_name = args["Camera"]
        self.framerate = args["Framerate"]
        self.width = args["Width"]
        self.height = args["Height"]
        self.flip = args["Flip"]

        self.tex = bge.texture.Texture(self.object, 0, 0)
        self.tex.source = bge.texture.VideoFFmpeg(self.camera_name, 0, self.framerate, self.width, self.height)
        self.tex.source.repeat = -1
        self.tex.source.scale = True
        self.tex.source.flip = self.flip
        self.tex.source.play()

    def update(self):
        self.tex.refresh(True)

Best Regards peter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant