File Exchange

image thumbnail

Video Recorder

version (4.03 KB) by Eric Ogier
Video recorder for dynamic figure


Updated 26 Mar 2016

View License

"Video Recorder" is an object dedicated to the recording of dynamic MATLAB figures in video files (formats: AVI, JPEG 2000 and MPEG-4).
The object results from the combination of "timer" and "VideoWriter" MATLAB objects and allows two recording modes:
- Timed recording, synchronized by an internal timer set and started by user
- Manual recording, through a method called by user
Video demonstrations:

Cite As

Eric Ogier (2020). Video Recorder (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (3)

Gives the following error

>> Test_plot
'fieldnames' is not an accessible method of base class 'hgsetget'.

Error in VideoWriter/fieldnames (line 556)
res = fieldnames@hgsetget(obj,varargin{:});

Error in VideoRecorder/ispropertyvideowriter (line 298)
Properties = fieldnames(Object.Recorder);

Error in VideoRecorder/set (line 166)
[is2, Property2] = ispropertyvideowriter(Object,Properties{n});

Error in VideoRecorder (line 151)

Error in Test_plot (line 14)
VR = VideoRecorder('Filename', Filename,...

Eric Ogier

Thank you for your message. I have never tried to record a video from a webcam but I found this link :
The corresponding code is:
vid = videoinput('winvideo', 1);
set(vid, 'ReturnedColorSpace', 'RGB');
img = getsnapshot(vid);
This code seems to extract the frame called "img" with "getsnapshot" function the same way "getframe" function does it for a figure.
You could try to record it through a "VideoWriter" object like that :
YourVideoWriter = VideoWriter('WebCamVideo','MPEG-4');

Ali Tareq

Good job! I have a related question, however it may be simple I could not do that.

I've faced problem recording video from webcam. in older version of matlab, specifically release 2013 I could, but in 2015 I cannot work with new functions. Please help me!


Correction of a bug in record file naming.

Adding of video demonstrations link.

MATLAB Release Compatibility
Created with R2014b
Compatible with any release
Platform Compatibility
Windows macOS Linux