MATLAB: How to read audio signal and video frames from an .avi file using mmreader function in matlab

audio extractionaudioreadComputer Vision ToolboxImage Processing Toolboxmmreader

I tried the mmreader function to read the frames of a video, at the same time I need the audio of that video. But I cant able to read the audio of the video. Please somebody help me to read the audio data simultaneously with the video frames.
I trie the code given below:
xyloObj = mmreader('xylophone.mpg');
nFrames = xyloObj.NumberOfFrames;
vidHeight = xyloObj.Height;
vidWidth = xyloObj.Width;
% Preallocate movie structure.
mov(1:nFrames) = ...
struct('cdata', zeros(vidHeight, vidWidth, 3, 'uint8'),...
'colormap', []);
% Read one frame at a time.
for k = 1 : nFrames
mov(k).cdata = read(xyloObj, k);
end
% Size a figure based on the video's width and height.
hf = figure;
set(hf, 'position', [150 150 vidWidth vidHeight])
% Play back the movie once at the video's frame rate.
movie(hf, mov, 1, xyloObj.FrameRate);

Best Answer

mmreader() cannot be used to read audio.
The Computer Vision Toolbox has the only Mathworks-provided routine that can read audio and video simultaneously. Otherwise you need to read them separately and match them up by time.
Related Question