1

I tried to display frames (in MATLAB GUI axes) of video with intervals for example 0.5 s (i.e. first display frame from video time 0.0, then frame from video time 0.5 and so on).

The following code works really slowly:

vidObj = VideoReader('video.mp4');
for i=1:20
  frame = readFrame(vidObj);
  imshow(frame);
  vidObj.CurrentTime = vidObj.CurrentTime + 0.5;
end

Do you know a better method for that?

Dev-iL
  • 23,742
  • 7
  • 57
  • 99
  • 3
    I think you should first [read all frames of the video file](https://www.mathworks.com/help/matlab/import_export/read-video-files.html), and then display them at your leisure. Also, you might want to display it using [`movie`](https://www.mathworks.com/help/matlab/ref/movie.html). – Dev-iL Nov 23 '16 at 21:24
  • I tried this, but loading 1200 frames (1280x720) to Matlab takes a lot of time and memory. – Misiaczek22 Nov 23 '16 at 22:37
  • Maybe you can save the loaded frame in a mat file, it may takes some time and memory but you need to do it only one time. For the frame display process, you can load the mat file instead of using VideoReader – oro777 Nov 24 '16 at 00:46
  • MATLAB is not a good tool for loading and processing video. Only do this if it's absolutely necessary. – rayryeng Nov 24 '16 at 07:26

0 Answers0