Search code examples
matlabaudiovideoh.264mpeg-4

Matlab - vision.VideoFileReader never reads audio samples


I tried to read a video (and it's audio) using vision.VideoFileReader like this:

video = vision.VideoFileReader('test.mp4', 'AudioOutputPort', true);

while ~isDone( video )
     [frame, audioSample] = step(video);
end

However, audioSample is always a logic 0.

EDIT: The video has audio.


Solution

  • The problem is not with the code, or the specific file, but the file type.

    From the help:

    Reading audio from compressed MP4 files with video and audio is not supported by vision.VideoFileReader.

    The most obvious solution would be to convert (outside Matlab using the method of your choice) to a format that vision.VideoFileReader can handle, such as .avi