FMP4 Error When Using VideoReader

5 visualizzazioni (ultimi 30 giorni)
Brent Weyers
Brent Weyers il 28 Feb 2022
Commentato: Brent Weyers il 27 Gen 2024
Hello,
I am trying to run the following code in MATLAB R2021b on Windows 10:
obj=VideoReader('Video_File.avi'); % Specify the video file to load
I=read(obj); % Stores data in variable I
implay(I,18);
And the following error is recieved:
Error using VideoReader/initReader (line 734)
FMP4
Error in audiovideo.internal.IVideoReader (line 136)
initReader(obj, fileName, currentTime);
Error in VideoReader (line 104)
obj@audiovideo.internal.IVideoReader(varargin{:});
Error in Extract_Reference_Frame (line 3)
obj=VideoReader('P800853_01_26_22_run4.avi'); % Specify the video file to load
Any ideas on how to solve the error?

Risposta accettata

Aditya
Aditya il 24 Gen 2024
Hi Brent,
The error you're encountering suggests that MATLAB's VideoReader is having trouble initializing the reader for the specified video file, potentially due to the codec used in the video file. The FMP4 mentioned in the error message refers to a video codec that may not be supported directly by MATLAB.
Here are some steps you can take to try to resolve this issue:
  1. Install Required Codecs: Ensure that the necessary codecs for the video format are installed on your system. The FMP4 codec is associated with the MPEG-4 video codec. Sometimes installing a codec pack like K-Lite can help.
  2. Convert the Video: Convert the video to a different format that is known to be supported by MATLAB's VideoReader, such as MJPEG or Motion JPEG 2000. You can use video conversion software like HandBrake or FFmpeg for this purpose. For example, with FFmpeg, you could convert the video using the following command in a command prompt:
ffmpeg -i Video_File.avi -c:v mjpeg -q:v 3 -an Output_File.avi
3.Read Frames Correctly: The way you're attempting to read frames from the video might be incorrect.
obj = VideoReader('Video_File.avi');
while hasFrame(obj)
I = readFrame(obj);
% Process the frame I here
end
If you manage to read the video frames successfully, use the implay function to play the video at the desired frame rate. If you have read multiple frames and stored them in an array or cell array, make sure to pass the correct data structure to implay.
Hope this helps.
  1 Commento
Brent Weyers
Brent Weyers il 27 Gen 2024
Thank you! This is helpful. I was missing the required system Codecs for Windows.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by