Video Playback: Difference between revisions
Jump to navigation
Jump to search
m →FFmpeg |
|||
| (2 intermediate revisions by one other user not shown) | |||
| Line 6: | Line 6: | ||
Note that the Lab Computer displays are typically set to 1920×1080 at 120Hz. We found that this is sufficient for most applications. There are possibilities to go higher. Later in this wiki we will explain how to build audio and video. We will start with playing video, both with and without audio. | Note that the Lab Computer displays are typically set to 1920×1080 at 120Hz. We found that this is sufficient for most applications. There are possibilities to go higher. Later in this wiki we will explain how to build audio and video. We will start with playing video, both with and without audio. | ||
=== Python === | === Python psychopy 2024.2.4=== | ||
Example demonstrating how to play a video with audio: | Example demonstrating how to play a video with audio: | ||
<syntaxhighlight lang="python" line> | <syntaxhighlight lang="python" line> | ||
| Line 21: | Line 21: | ||
win = visual.Window(size=(1024, 768), fullscr=False, color=(0, 0, 0)) | win = visual.Window(size=(1024, 768), fullscr=False, color=(0, 0, 0)) | ||
movie = visual.MovieStim( | |||
win, filename=video_file, | win, filename=video_file, | ||
autoStart= False | autoStart= False | ||
| Line 35: | Line 35: | ||
# Main loop for video playback | # Main loop for video playback | ||
while | while not movie.isFinished: | ||
# Draw the current video frame | # Draw the current video frame | ||
movie.draw() | |||
win.flip() | win.flip() | ||
| Line 43: | Line 43: | ||
if 'q' in keys: | if 'q' in keys: | ||
break | break | ||
movie.stop() # stop playback | |||
del movie | |||
gc.collect() | |||
win.close() | win.close() | ||
| Line 63: | Line 66: | ||
win = visual.Window(size=(1280, 720), fullscr=False, color=(0, 0, 0), units="pix") | win = visual.Window(size=(1280, 720), fullscr=False, color=(0, 0, 0), units="pix") | ||
movie = visual.MovieStim( | |||
win, filename=video_file, | win, filename=video_file, | ||
size=None, # Use the native video size | size=None, # Use the native video size | ||
| Line 85: | Line 88: | ||
audio.play() | audio.play() | ||
time.sleep(0.04) | time.sleep(0.04) | ||
movie.play() | |||
movie_start_time = core.getTime() | |||
while | while not movie.isFinished: | ||
# Draw the current video frame | # Draw the current video frame | ||
movie.draw() | |||
win.flip() | win.flip() | ||
| Line 97: | Line 100: | ||
audio.stop() | audio.stop() | ||
break | break | ||
movie.stop() # stop playback | |||
del movie | |||
gc.collect() | |||
# Close the PsychoPy window | # Close the PsychoPy window | ||
| Line 281: | Line 287: | ||
Stabilize the camera and avoid automatic exposure, white balance, or focus during recording to prevent inconsistencies. | Stabilize the camera and avoid automatic exposure, white balance, or focus during recording to prevent inconsistencies. | ||
Record in a controlled environment with consistent lighting and minimal background distractions. | Record in a controlled environment with consistent lighting and minimal background distractions. | ||
The TSG recomends to use the [ | The TSG recomends to use the [[Elgato Facecam]] for high quality video recording. | ||
===Video Settings=== | ===Video Settings=== | ||