I currently am successfully recording video to an avi file. I would like to record audio and add it to the same file. Is this possible?
%Create a video input object for the logitech webcam
vid = videoinput('winvideo',1 );%Create an audio input object for the computer's microphone
audio = audiorecorder(sps,16,1,4);%audio
record(audio);% Grab every frame
set(vid,'FrameGrabInterval',1);% Specify a trigger to fire (specifically, fire a trigger after 100 frames)
set(vid, 'FramesPerTrigger', 100);% Get a file name
Today = datestr(now, 'dd-mm-yyyy');data_file = strcat(dataFolder, Today, '.avi');% Create an AVI file object to hold the frames
avi = avifile(data_file,'fps',15, 'compression', 'none'); % Log the images
set(vid,'LoggingMode','disk'); % Log to disk
set(vid,'DiskLogger',avi); % Log the disk to the AVI file object
% Start the video input object
start(vid);% Wait (i.e., block) for the given amount of time or until a trigger is
% fired (whichever comes first). In this case, the trigger
% will be fired after 100 frames.
%
% Note that other MATLAB code can be executing since the
% Image Acquisition Toolbox runs in another thread of execution
wait(vid,20); % Could use Inf
% After the trigger is fired...
% Get the AVI object
avi = get(vid,'DiskLogger');% Close the AVI file
avi = close(avi);% Free the hardware resources associated with the video input
delete(vid);stop(audio);% Remove the video object from the workspace
clear vid;
Best Answer