0

I would like to record a continuous video in Matlab until some other flag changes, allowing matlab to continue performing other tasks during video acquisition (like deciding whether or not the flag should be set). Since these recordings could last upwards of 3 hours, perhaps closing the recording every hour, writing to a file video_1, then recording for another hour and dumping to video_2, etc for as long as the flag isn't set. However, from what I've seen using Matlab's Image Processing Toolbox, you have to specify some kind of number of frames to capture, or frames per trigger, etc. I'm not really too sure how to proceed.

Some simple code to record video I have is:

% create video obj
video = videoinput('winvideo',1);

% create writer obj
writerObj = VideoWriter('output.avi');

% set video properties
video.LoggingMode = 'disk';
video.DiskLogger = writerObj;

% start recording video
start(video);

% wait
wait(video, inf)

% save video
close(video.DiskLogger);
delete(video);
clear video;

However, the output video is only .3 seconds long. I've followed the following tutorial to get a 30 second recording down to a 3 second video available here but I can't figure out how to make it go on continuously.

Any help would be appreciated!

1 Answer 1

0
aviObject = avifile('myVideo.avi');   % Create a new AVI file
for iFrame = 1:100                    % Capture 100 frames
  % ...
  % You would capture a single image I from your webcam here
  % ...
  F = im2frame(I);                    % Convert I to a movie frame
  aviObject = addframe(aviObject,F);  % Add the frame to the AVI file
end
aviObject = close(aviObject);         % Close the AVI file

source: How do I record video from a webcam in MATLAB?

1
  • avifile is deprecated I think. you should use videowriter. And Im wondering if I have to do it frame by frame? I dont know what the max number of frames is thats the entire problem.
    – Diego
    Feb 14, 2013 at 23:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.