The issue arises because MATLAB's 'read()' method in older R2013b with compressed formats is not indexed. Each call to 'read(v, i)'causes MATLAB to rescan the file from the start or the nearest key‑frame. As the frame number grows, this scanning becomes progressively slower.
To resolve the issue there are few workarounds which can be opted:
- Switch to 'readFrame()' (R2014a and newer): readFrame() reads sequentially and avoids per-call scans, tracking position internally.
- Preload All Frames Once: If memory allows, read all frames at once to build an indexed array:
frames = read(v, [1 Inf]);
- Convert Video to Indexed Format (e.g. .seq, Uncompressed AVI) : Convert to a format with a frame index table for fast random access. MATLAB supports .seq (via MathWorks example) or uncompressed AVI for quicker seeking.
Choosing one of these options- especially moving to 'readFrame()' or converting the video format-will eliminate progressive slowdowns and improve frame access effciency.
I hope this helps in resolving the query.