Reading from the file timed-out error when using VideoFileReader

2 views (last 30 days)
Hi, i am using the "vision.VideoFileReader" function to read some videos in MP4 format, undistorting the frames one by one and then writing them into a new video file with "vision.VideoFileWriter", sometimes it works well, but many times the next error appears:
"Error using VideoFileReader
Reading from the file timed-out
Error in UndistortVideo (line "x")
DistFrame=videoFReader(); or DistFrame=step(videoFReader); "
I have tried different ways of programming the code:
First i always obtain the cameraParams in order to undistort the images.
1:
videoFReader=vision.VideoFileReader('Video.mp4');
videoFWriter=vision.VideoFileWriter('VideoUndist.mp4','FrameRate',videoFReader.info.VideoFrameRate,'FileFormat','MPEG4');
while ~isDone(videoFReader)
DistFrame=videoFReader();
UndistFrame=undistortImage(DistFrame, cameraParams);
videoFWriter(UndistFrame);
end
release(videoFWriter);
release(videoFReader);
2:
videoFReader=vision.VideoFileReader('Video.mp4');
videoFWriter=vision.VideoFileWriter('VideoUndist.mp4','FrameRate',videoFReader.info.VideoFrameRate,'FileFormat','MPEG4');
v=VideoReader('CERCA_HL15_3214Undist.mp4');
numFrames=v.NumberofFrames; %I kwnow this is not recommended, but it works well for me.
for i=1:numFrames
DistFrame=step(videoFReader);
UndistFrame=undistortImage(DistFrame, cameraParams);
videoFWriter(UndistFrame);
end
Each video has a duration between 5 and 20 minutes and i have also tried doing it with VideoReader function instead of vision.VideoFileReader function, but the same problem appears.
I hope you can help me with it,
Thank you all beforehand.

Answers (0)

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!