Create object p of the VideoReader class.
Outputs a list of all available properties.
Get next RGB24 frame. This also increases ’FrameNumber’.
Internal function to increase chattiness of the underlying code for debugging purposes.
The following code
fn = fullfile (tempdir(), "sombrero.mp4"); if (! exist (fn, "file")) warning ("'%s' doesn't exist, running demo VideoWriter first...", fn); demo ("VideoWriter"); endif x = VideoReader (fn); im = []; while (! isempty (img = readFrame (x))) if (isempty (im)) im = image (img); axis off; else set (im, "cdata", img); endif drawnow pause (1/30); endwhile
Produces the following output
warning: '/tmp/sombrero.mp4' doesn't exist, running demo VideoWriter first... warning: called from get_output at line 50 column 5 __html_help_text__ at line 67 column 28 generate_package_html>wrote_html at line 842 column 5 generate_package_html at line 207 column 11 VideoWriter example 1: fn = fullfile (tempdir (), "sombrero.mp4"); w = VideoWriter (fn); w.FrameRate = 50; open (w); z = sombrero (); hs = surf (z); axis manual nframes = 200; for ii = 1:nframes set (hs, "zdata", z * sin (2*pi*ii/nframes + pi/5)); drawnow writeVideo (w, getframe (gcf)); endfor close (w) printf ("Now run 'open %s' to read the video with your default video player or try 'demo VideoReader'!\n", fn); Now run 'open /tmp/sombrero.mp4' to read the video with your default video player or try 'demo VideoReader'!
and the following figure
Figure 1 |
---|
The following code
r = VideoReader("https://raw.githubusercontent.com/opencv/opencv/master/samples/data/vtest.avi") im = []; while (r.hasFrame()) img = readFrame (r); if (isempty (im)) im = image (img); axis off; else set (im, "cdata", img); endif drawnow endwhile
Produces the following output
r = class VideoReader: read-only access: Duration [s] = 79.50 BitsPerPixel = 24 Bitrate = 818 FrameRate [fps] = 10.00 Height [px] = 576 Width [px] = 768 Name = 'vtest.avi' Path = 'https://raw.githubusercontent.com/opencv/opencv/master/samples/data' NumberOfFrames = 795 VideoFormat = 'RGB24' FrameNumber = 0 VideoCodec = 'msmpeg4v3' AspectRatio = '[0 1]' FFmpeg_versions = 'Lavu57.28.100, SwS6.7.100, Lavc59.37.100, Lavf59.27.100' read-write access: CurrentTime = 0 Tag = ''
and the following figure
Figure 1 |
---|
Package: video