VideoReader function read function in matlab

source

%取第一个文件夹里面的第一个视频
readerObj = VideoReader(strcat(strPath,nameFolds{
    
    1},'\',fileList(1).name));
vidFrames = read(readerObj);  %读取所有帧
numFrames = get(readerObj, 'NumberOfFrames'); % 帧数
% numFrames = readerObj.NumberOfFrames  % 也可以获得帧数

         
Insert picture description here

         

VideoReader function

          Used to create a VideoReader object, use the properties of the object to query the video information, and then use the object function to read the video. The VideoReader object contains information about the video file and allows the user to read data from the video.

grammar

  • v = VideoReader(filename) creates an object v to read video data from the file named filename.

  • v = VideoReader(filename,Name,Value) uses the name-value pair to set the properties CurrentTime, Tag, and UserData.

          For example, VideoReader('myfile.mp4','CurrentTime',1.2) starts to read 1.2 seconds of video. You can specify multiple name-value pairs. Enclose each attribute name in single quotes, followed by the corresponding value.

Input parameters

  • filename-filename character vector | string scalar

         

read function

          Role: read one or more video frames

1. Grammar

  • video = read(v) Read all video frames from the file associated with v.
  • video = read(v,index) only reads the frame specified by index.
  • video = read(___,'native') returns data in the format specified by the VideoFormat property, and can include any input parameters in the above syntax.

          Create a video reader object and use the frame index to read one or more video frames. Create a VideoReader object for the sample movie file abc.mp4.

v = VideoReader('abc.mp4');

          Only read the first video frame.

frame = read(v,1);

          Only the last video frame is read.

frame = read(v,Inf);

          Read frame 5 to frame 10.

frames = read(v,[5 10]);

          Read from the 50th frame to the end of the video file.

frames = read(v,[50 Inf]);

Guess you like

Origin blog.csdn.net/qq_43657442/article/details/109170079