[open] how to define media_player_vlc (set video width/height + set loop)
hello,
i'm trying to show a video in the middle of the screen and (at the same time) show text at the bottom of the screen.
therefore i tried to set video width/height.
another question is to loop a video until keyresponse.
is there any way to implement this?
thanks a lot,
ben
Comments
Hi Ben,
If you want to do (relatively) complex things with video, such as custom scaling and drawing additional things on top of the video surface, you're probably best of writing a custom script with
opencv. This is not as difficult as it sounds, and a working example is provided here:If you are using an inline script anyway, than this too would probably be best handled through a loop in your script.
If you are not familiar with Python, quite a few excellent tutorials are available:
Cheers and good luck!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
thanks!
i downloded the opencv-package at opencv.org but the debugger says: "ImportError: No module named cv"
copying the opencv-folder into opensesame-plugin-folder couldnt fix the problem...
unfortunatly the link on your "video playback" section to opencv is broken for a while (http://opencv.willowgarage.com/documentation/python/index.html)
do you have a hint for me?
cheers,
ben
Hi Boris,
Basically, the example is a bit outdated. It uses
cv, whereas the current module (and the one supplied with OpenSesame) iscv2, for OpenCV 2.The script below shows how to show how to play back a video using
cv2. As you can see, it's actually a bit simpler than withcv. Note that this requires the legacy back-end.And thanks for pointing out the broken link.
Cheers!
Sebastiaan
Update: Fixed error in script
Check out SigmundAI.eu for our OpenSesame AI assistant!
thanks! unfortunatly another problem occurred:
???
i don`t want to make any changes in "twodim_base.py" or do i have to?
cheers,
ben
Ow right, I see. The script didn't specify which file should be read. Basically, this ...
... should be ...
Check out SigmundAI.eu for our OpenSesame AI assistant!
ah ok! makes sense! but heres another debug-message:
i couldnt fix the line:
damn, i have no clue of python...sorry!
Hi Ben,
To make this script work (as I already wrote above!), you need to use the legacy back-end, or the xpyriment back-end with 'Use OpenGL' set to 'no' under back-end settings. The reason is that this script uses certain PyGame functionality that is incompatible with an OpenGL-based method of display presentation.
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
I already used the xpyriment back-end with 'Use OpenGL' set to 'no'.
After switching to legacy back-end the video plays
Didn't knew that just one of these two options works.
now i tried to let the video play in a while loop until keypress...no success
sorry, i am into from php-programming but its hard for me to understand the python logic...
thanks,
ben
Hi Ben,
If you are not familiar with Python, there are a lot of good free tutorials to get you started. For most things, you won't need any deep Python knowledge, so don't worry. But some knowledge will be necessary if you want to do semi-complicated things with video presentation.
To get you started, below is an example of how you can probe the keyboard and break the video loop when a key is pressed. For more information, see:
And indeed, the script didn't work with the xpyriment back-end. I added a small check to fix this, it's just a matter of selecting the right 'surface'.
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
the video was flipped in left/right direction so i had to add fliplr before rot90:
some further questions:
the video plays about 2times faster as normal? sample-frequence in back-end-settings and video sample-frequence are equal.
there is no sound?
any ideas? thanks, ben
Yes that might be, I think it depends on the format. Just flip and rotate until it looks right!
You need to determine the framerate yourself in this script. So if it's too fast, just add a
self.sleep()somewhere in the loop.Right, this is video only. Perhaps you misunderstood the script, so just to avoid confusion: It retrieves image frames from the video file and puts them on the screen. That's all, it's really very basic. It's not a real video engine that controls the framerate or handles audio.
Check out SigmundAI.eu for our OpenSesame AI assistant!
what if it plays to slow ?
That's possible, because there's quite a bit of processing going on, and not in a very optimized way. I'm afraid the only real solution would be to use a lower resolution video. (Or think of a more efficient script that does the same thing, but that might not be trivial.)
Check out SigmundAI.eu for our OpenSesame AI assistant!