3
votes

I wish to playback a large video (1080p at 30fps, ~100K frames) within Matlab, such that I can:

  • play/pause the video
  • jump to a given frame number
  • obtain the current frame number

The purpose of doing this is for annotating each video frame with a (global) frame label in a streamlined way.

To achieve this I have tried:

  • VideoReader: fast playback (~30fps), slow buffering (~5 fps, memory limitations)
  • vision.VideoFileReader: slow playback (<5fps), streaming (no/minimal buffering?)
  • imread/imshow (iterating over image sequence): slow playback (<5fps), streaming

I am using Matlab R2014a 64-bit on OS X.

What alternative approach can I use to obtain fast playback (~30fps) without significant buffering overheads?

1
Are you doing this annotation entirely programmatically, partially with some user input, or entirely manually? Does this mean your modifying the video data or do you just need to find a given frame and save it's location to an array or even an external file? What exactly do you mean by "buffering"? Also, is the imread/imshow option your own code? I wonder if there could be performance issues in the implementation?horchler
Can you use an external player? QuickTime Player 7 (the classic player, not the newer built-in version) can show you the frame number and allow you to jump to a specific frame. Click on the time-code in the lower left and select "Frame Number" from the drop down. You can then type in the the frame number field to jump to a specific frame. Select the playhead and the arrow keys will then allow you to increment and decrement the frame number.horchler
Thanks for the comments horchler. The annotation is entirely manually driven, but I wanted to build a simple UI around the process to prevent/reduce human error and allow playback with labels to verify correct labelling. The video data is not being modified -- the labels are exported to an external file. By "buffering" I mean preloading frames in memory prior to display. I am calling imread/imshow functions which are built into Matlab's image processing toolbox. From profiling, the bottlenecks lie in these functions.Josh
Yes, I could use an external player, but then it will involve looking up and entering frame numbers, which is a bit tedious and error-prone. However, your suggestion of using QuickTime Player 7 is a good one for the meantime while I look into a more user-friendly option. I would be interested in any other ideas you have :-) Thanks again.Josh
I've not dealt with this issue exactly, so it's hard to say much more without specific code and not knowing the codecs involved, etc. Are you playing back at full 1080p resolution? It might be possible to improve performance and reduce the memory footprint if you don't display all of the pixels (it's also possible this could slowdown playback if resizing is inefficient). You could also display in grayscale or reduced color and grab color frames only when the video is paused by the user. With imread, use an image format that is fast to decompress even if file sizes are larger, e.g., TIFF.horchler

1 Answers

0
votes

The speed of reading the video depends on the video format. You may be able to speed up vision.VideoFileReader if you use Motion JPEG video.

The other question is playback. What are you using for that? Have you tried vision.VideoPlayer? There is also vision.DeployableVideoPlayer, which may be faster, but it only works on Windows.