Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use a VideoReader object to read files containing video data. The object contains information about the video file and enables you to read data from

 

Use a VideoReader object to read files containing video data. The object contains information about the video file and enables you to read data from the video. You can create a VideoReader object using the VideoReader function, query information about the video using the object properties, and then read the video using object functions.

Creation Syntax v = VideoReader (filename) v = VideoReader (filename, Name, Value)

Description v = VideoReader (filename) creates object v to read video data from the file named filename. v = VideoReader (filename, Name, Value) sets the properties CurrentTime, Tag, and UserData using name-value pairs. For example, VideoReader(\'myfile.mp4\', \'Current Time\',1.2) starts reading 1.2 seconds into the video. You can specify multiple name-value pairs. Enclose each property name in single quotes followed by its value.

Input Arguments filename File name character vector | string scalar Properties

The VideoReader object has properties that contain information about the video file. Properties are read only, except CurrentTime, Tag, and UserData. You can view or modify the value of a property after creating the object. For example, this command finds the value of the Duration property of the VideoReader object, v. D = v.Duration; BitsPerPixel - Bits per pixel of video data numeric scalar CurrentTime Timestamp of video frame to read numeric scalar Duration - Length of file numeric scalar FrameRate - Number of video frames per second numeric scalar Height Height of video frame numeric scalar Name File name character vector | string scalar NumberOfFrames - Number of frames in video stream numeric scalar Path - Full path to video file character vector | string scalar Tag Generic text \'\' (default) | character vector | string scalar UserData- User-defined data [] (default) | any data type VideoFormat - MATLAB representation of video format character vector | string scalar Width - Width of video frame numeric scalar

Object Functions read Read video frame data from file File formats that VideoReader supports VideoReader.getFileFormats readFrame Read video frame from video file hasFrame Determine if frame is available to read

Examples The video is found at matlabroot/toolbox/vision/visiondata in the computer vision toolbox. Create VideoReader Object and Read Video Try This Example Create a VideoReader object for the example movie file, xylophone.mp4. v = VideoReader(\'xylophone.mp4\'); Read all video frames. while hasFrame (v) video= readFrame (v); end whos video Name Size Bytes Class Attributes video 240x320x3 230400 uint8 Read Video Starting at Specific Time Create an object to read the sample file, xylophone.mp4. v=VideoReader(\'xylophone.mp4\'); Specify the reading to begin 2.5 seconds from the beginning of the video. v.CurrentTime = 2.5; Create an axes object. Then, read video frames until no more frames are available to read. currAxes = axes; while hasFrame (v) vidFrame = readFrame (v); image (vidFrame, \'Parent\', currAxes); currAxes.Visible = \'off\'; pause (1/v. FrameRate); end

Tips

O Open the video file using the QuickTime player. If the player detects the file to be of an older format, then it automatically converts the file to a newer format.

O Save the newly converted video file.

O Use the VideoReader to read this newly converted video file.

Sol7:

The VideoReader object in MATLAB is used to read video data from files. It contains information about the video file and enables users to read data from the video. The object is created using the VideoReader function, which takes a file name as input. Additional properties, such as the current time, tag, and user data, can be set using name-value pairs.

The VideoReader object has several read-only properties that provide information about the video file, such as the number of frames, frame rate, duration, width, and height. The object functions include read, which reads video frame data from a file, readFrame, which reads a single video frame from a file, and hasFrame, which determines if a frame is available to read.

Users can create a VideoReader object, read all video frames, or read video frames starting at a specific time. The VideoReader object can be used with axes objects to display video frames.

Some tips for working with the VideoReader object include opening the video file using the QuickTime player, saving newly converted video files, and using the VideoReader to read these newly converted video files.




Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

What is a payment-in-kind bond?

Answered: 1 week ago