필터 지우기
필터 지우기

Stretch movie size with Screen('OpenMovie')

조회 수: 5 (최근 30일)
LG
LG 2021년 12월 17일
답변: prabhat kumar sharma 2024년 2월 15일
I'm using psychtoolbox to open and play a movie, however I want to stretch the movie to be full screen.
[movie, movieduration, fps, width, height] = Screen('OpenMovie', window, movietitle)
On playing the movie I can see that the original file's width and height are smaller than my screen dimensions (1280x720 movie and 1920x1080 screen) - is there a way to stretch the movie on opening it to fit my desired screen dimensions?
Thanks

답변 (1개)

prabhat kumar sharma
prabhat kumar sharma 2024년 2월 15일
Hi LG,
I understand that you want to stretch your movie to fill the entire screen while playing it. There are two possible solutions you could try:
1. Use the Screen('DrawTexture') function:
This method involves drawing the movie texture on the screen and specifying the scaling parameters. This way, you can stretch the movie to fit the screen dimensions.
You can refer the below psuedocode for understanding:
% Get movie texture after opening
movieTex = Screen('GetMovieTexture', window, movie);
% Define target dimensions (full screen in this case)
[screenX, screenY] = Screen('WindowSize', window);
% Calculate scaling factors to maintain aspect ratio
scaleX = screenX / width;
scaleY = screenY / height;
% Choose the smaller scaling factor to avoid stretching in one dimension
scaleFactor = min(scaleX, scaleY);
% Draw the movie texture with scaling
while Screen('Flip', window) && Screen('MovieState', movieTex) == 1
Screen('DrawTexture', window, movieTex, [], [0 0 width height] * scaleFactor);
end
% Close the movie texture and movie
Screen('CloseMovie', movie);
Screen('Close');
2. Using the Screen('SetMovieDrawParams') function:
This function allows you to set drawing parameters for the movie. You can define a scaling factor that will be applied automatically during playback
% Open the movie with the desired scaling
[movie, movieduration, fps, width, height] = Screen('OpenMovie', window, movietitle, [], [], [], [1920 1080] / [width height]);
% Play the movie (no further scaling needed)
while Screen('Flip', window) && Screen('MovieState', movie) == 1
end
% Close the movie and screen
Screen('CloseMovie', movie);
Screen('Close');
I hope it helps to resolve your issue!

카테고리

Help CenterFile Exchange에서 Timing and presenting 2D and 3D stimuli에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by