问题
I'm trying to write a program in python to be used by people with a disability while they use something as a hometrainer (or MotoMed). To do so I have to be able to show a video and write additional info/images to the screen if need be. This info is dependant on other sensors (including a Hall Effect sensor and sensors that can detect a spasm for instance).
Using the Pygame Movie feature you can update the screen frame by frame using the pygame.update() function. See: How to load and play a video in pygame However, I need to run other video formats (Pygame can only play MPEG-1) and am therefore playing with theVLC python bindings to render a video in pygame window.
VLC renders the video directly onto/into the pygame window. TO do so you have to provide it with the window ID:
player.set_xwindow(win_id)
Instead of rendering it on the window I need to render it on a Pygame surface such that I am able to update the screen with pygame and write other info to the screen as well. With the pygame Movie function it would be
movie_screen = pygame.Surface((x,y)).convert()
movie.set_display(movie_screen)
movie.play()
I have noticed that there is a nextframe function in the VLC bindings. Is it possible for pygame to dynamically obtain this frame and put it on a surface? I guess this will be quite slow, but I am willing to give it a shot as it is my only guess at getting a dynamic overlay for videofiles other than MPEG-1 in python/pygame.
来源:https://stackoverflow.com/questions/33443396/dynamic-overlay-for-video-using-python