Setting CurrentTime = 0 and then attempting to read the object results in error for larger file only.
8 views (last 30 days)
Show older comments
Shane McCarthy on 7 Jun 2022
Answered: Nalini Vishnoi on 14 Jun 2022
I am using VideoReader to read in multiple video files (.avi) whose only difference is duration. For the majority of my files, ranging from 2-2.5 GB I use the following:
vid = VideoReader(file);
frames = read(vid);
This works as expected and results in frames being a 4D-uint8 variable. Additionally, the vid variable created is a 1x1 VideoReader with CurrentTime = 0.
When I attempt to run this for my larger file, 4.5 GB, I am unable to read the video object, the variable vid is a 1x1 VideoReader with CurrentTime = 17, the duration of the video, and the final result, frames, is a 0x0 double.
I have tried to force the VideoReader to establish a CurrentTime = 0 by doing
vid = VideoReader(file,'CurrentTime',0);
frames = read(vid);
This results in an error of "Unable to read the file."
I have also tried to tell read to read specific frames by doing
frames = read(vid, [1 Inf]);
frames = read(vid, [2 5]);
With the former resulting in an empty array and the latter resulting in the "Unable to read the file" message.
I mention the video file sizes because that is the only difference between the files, leading me to believe there might be some complications with VideoReader for larger files or additional steps I need to take somewhere along the process. This is not a standalone issue, I have multiple batches of video files, for all of the batches the smaller files run fine, while the one big does not process. I have not used MATLAB for processing videos before, if the solution is trivial I apologize for my incompetence and I appreciate your patience.
I am looking for someone who is familiar with these functions and can provide insight on what might be causing the issues.
Nalini Vishnoi on 14 Jun 2022
It would be useful to have access to files for which VideoReader is unable to read the data. You can also create a tech support case at support.mathworks.com, provide them access to the problematic files and they will be able to help you get to the root cause.
Hope this helps.
Find more on Video Formats and Interfaces in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!