Continuous video acquisition until some other flag ends?
Afficher commentaires plus anciens
Hello!
My code to record video is as follows:
% 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 to a 3 second video: http://www.mathworks.com/products/imaq/examples.html?file=/products/demos/shipping/imaq/demoimaq_AcquisitionRate.html
but what I would like to do is:
- record a video to disk 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.
Any help/advice would be appreciated!
Réponses (1)
Youssef Khmou
le 13 Fév 2013
Hi Diego,
The only thing i can tell is that, as you got only 3 seconds so maybe i propose to modify the property "FramesPerTrigger " to infinity :
>>%v=videoinput('winvideo',1,'YUY2.......... The structure is v
>>set(v,'FramesPerTrigger',Inf)
Now i think you can put a condition you want to break the infinite loop .
1 commentaire
Vinny Chandran Suja
le 1 Nov 2016
Hi Diego,
Apart from checking the frames per trigger, it also necessary to ensure the framerate used to encode the video is the same as the framerate of the video source. In the event the framerate of the source is less than that of the video, we can expect situations like you are experiencing.
The framerate used by the encoder in your example can be checked using:
get(writerObj,'FrameRate');
The framerate of the source can be checked using (though all sources may not support this):
src = getselectedsource(video);
frameRates = set(src, 'FrameRate')
Catégories
En savoir plus sur Acquisition Using Image Acquisition Explorer dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!