How to play full screen videos using matlab
7 views (last 30 days)
Show older comments
For my experiment, I am trying to play a 1 minute black and white clip in full screen. Then I will be using eyelink to track the viewers eye motion. I have tried almost everything: mplay, the PsychToolbox video player, vision.VideoFileReader, videoReader, and opening/playing VLC externally. I have also exported my video clip into .mov, .mpv, .avi, and others, but still nothing works
Any of these options would be fine with me but each face a unique problem:
VLC: I don't now how to simultaneously start the VLC video player and eye tracker to ensure they are synced up time wise.
videoReader: I can get this into full screen but theres a large white boarder around it.
vision.videoFileReader: This one would be the best option of all, but it either plays the clip too fast (when converted to .mov) or too slow (when converted to .avi or .mp4) or not work on the computer with the vision tracker.
Here is the sample code from my videoReader
% get the figure and axes handles
hFig = gcf;
hAx = gca;
% set the figure to full screen
set(hFig,'units','normalized','outerposition',[0 0 1 1]);
% set the axes to full screen
set(hAx,'Unit','normalized','Position',[0 0 1 1]);
% hide the toolbar
set(hFig,'menubar','none')
% to hide the title
set(hFig,'NumberTitle','off');
video = 'CMBYN_1.avi';
videoReader = VideoReader(video);
myVideo.FrameRate = 60; % Default 30
myVideo.Quality = 50; % Default 75
fps = get(videoReader, 'FrameRate');
disp(fps); % the fps is correct: it's the same declared in the video file properties
currAxes = axes;
while hasFrame(videoReader)
vidFrame = readFrame(videoReader);
image(vidFrame, 'Parent', currAxes);
currAxes.Visible = 'off';
pause(1/videoReader.FrameRate);
end
Here is the sample code from my VideoFileReader
% Movie Start Code
videoFReader = vision.VideoFileReader('ClipTest.mp4'); %Upload movie
pause(2)
depVideoPlayer = vision.DeployableVideoPlayer; %Starting video player
myVideo.FrameRate = 30;
pause(3)
cont = ~isDone(videoFReader); %Plays movie until done
while cont
frame = step(videoFReader);
step(depVideoPlayer, frame);
cont = ~isDone(videoFReader) && isOpen(depVideoPlayer);
end
release(videoFReader);
release(depVideoPlayer);
Any help or suggestions will be greatly appreciated
2 Comments
Alexander Reyes
on 7 Jun 2021
I would also be interested if this problem has been solved. Is there a solution?
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!