hasFrame
Determine if video frame is available to read
Syntax
Description
Examples
Create VideoReader Object and Read Video
Create a VideoReader
object for the example movie file xylophone.mp4
.
v = VideoReader('xylophone.mp4');
Read all the frames from the video, one frame at a time.
while hasFrame(v) frame = readFrame(v); end
Display information about the last frame returned by readFrame
.
whos frame
Name Size Bytes Class Attributes frame 240x320x3 230400 uint8
Read and Play Back Movie File
Read and play back the sample movie file, xylophone.mp4
.
Create a VideoReader
object to read
data from the sample file. Then, determine the width and height of
the video.
xyloObj = VideoReader('xylophone.mp4');
vidWidth = xyloObj.Width;
vidHeight = xyloObj.Height;
Create a movie structure array, mov
.
mov = struct('cdata',zeros(vidHeight,vidWidth,3,'uint8'),... 'colormap',[]);
Read one frame at a time until the end of the video is reached.
k = 1; while hasFrame(xyloObj) mov(k).cdata = readFrame(xyloObj); k = k+1; end
Size a figure based on the width and height of the video. Then, play back the movie once at the video frame rate.
hf = figure;
set(hf,'position',[150 150 vidWidth vidHeight]);
movie(hf,mov,1,xyloObj.FrameRate);
Input Arguments
v
— Input VideoReader object
VideoReader
object
Input VideoReader object. Use the VideoReader
function to
create a VideoReader
object from your video file.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Version History
Apri esempio
Si dispone di una versione modificata di questo esempio. Desideri aprire questo esempio con le tue modifiche?
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)