Using 'read' command to read video frame sometimes returns 'No more frames available to read from file.'

3 views (last 30 days)
I'm using the 'VideoReader' and 'read' commands to pull in video frames for processing. Randomly, it will give me the following error, i.e., sometimes it pulls up the video frame fine and sometimes it doesn't.
Error using DLC_FillMarkers
No more frames available to read from file.
Error in DLC_ProcDL_SagPln (line 353)
[pdata.traj_filled.(markname),gaperror] = DLC_FillMarkers(...
Error in ALII_DLC_DLSagprocess (line 113)
[DL.sag.(trialtype).(side).data, DL.sag.(trialtype).(side).vars, DL.sag.(trialtype).(side).info] = DLC_ProcDL_SagPln...
I tried upgrading from version 2020a to 2022a, as I noticed this may help in a previous post (See Here). However I am still getting the issue.
I also tried adding a pause after the 'read' command, but this didn't help either.
Below is the the full code used to read the video frame and plot it, and the contents of the VideoReader object. You can see that there are frames to read, so I don't think that is the issue? Interestingly, if I put a break before the 'read' command and run the command manually, it will usually work fine.
f1= figure('WindowState', 'maximized');
s1 = subplot(1,3,1);
vidframe1= read(vid, frames_pre(1,1)); --> frames_pre(1,1) = 1086
pause(1)
vidframe1 = imsharpen(vidframe1,'Radius',2,'Amount',2);
vidframe1 = imadjust(vidframe1,[0 1],[0 1],0.8);
imagesc(vidframe1)
vid =
VideoReader with properties:
General Properties:
Name: '3080_dldl_trial01_S2_DL_L_GX010878_12-Aug-2021_15-47-13-converted.mp4'
Path: 'P:\1.Study Info and Data\ALII Study\Data\Video\2. Named_Sorted\DL\3080\Sag'
Duration: 5.8892
CurrentTime: 0
NumFrames: 1412
Video Properties:
Width: 1920
Height: 1080
FrameRate: 239.7622
BitsPerPixel: 24
VideoFormat: 'RGB24'
  3 Comments
Caleb Johnson
Caleb Johnson on 18 Nov 2022
I did get in touch with MATLAB support, and here are the possible solutions they provided. I haven't had any issues since trying the 2nd option, but I actually haven't used the referenced script on the computer that was having issues a lot since then either- and it was only happening sporadically for me- so I'd have to try it out more to be sure that was a real fix. Hope that helps!
1. A possible alternative is ‘vision.VideoFileReader’. I have attached a documentation link below: https://www.mathworks.com/help/vision/ref/vision.videofilereader-system-object.html
2. Try turning off the hardware acceleration using the command below and see if the issue persists.
matlab.video.read.UseHardwareAcceleration('off')
3. Install the Xvid codec. It can be downloaded from here: https://www.xvid.com/download/.
During the installation process, check "No, I want to check for updates manually" if prompted, and later select DIVX only. Then restart MATLAB after the installation is completed and see if the issues persist.
Jonas
Jonas on 15 Jun 2023
is there something new to this topic? still happening to me when trying to read avi files. most of the time the last 3 frames are not readable using the read(videoObj,...) command.
I tried suggested solution 2 and 3, since 1 can not be used to read any frame I want.
I am on Matlab 2022a, latest patch
Edit: I noted that this error occurs only if I try to read multiple video frames in a fast rate. Manually on command line, there is no error.

Sign in to comment.

Answers (0)

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!