Previewing pre recorded video

5 ビュー (過去 30 日間)
Koohyar
Koohyar 2020 年 9 月 10 日
編集済み: Madhav Thakker 2020 年 9 月 23 日
Hi,
Does anybody knows how can I change the following code to use for a pre-recorded video (mp4).?
i need to preview of a pre-recorded video, not live one!
Thanks.
*i am using matlab R2020a
% Create a video input object.
vid = videoinput('winvideo', 1, 'YUY2_640x480');
set(vid,'ReturnedColorSpace','grayscale');
% Create a figure window. This example turns off the default
% toolbar, menubar, and figure numbering.
figure('Toolbar','none',...
'Menubar', 'none',...
'NumberTitle','Off',...
'Name','My Preview Window');
% Create the image object in which you want to display
% the video preview data. Make the size of the image
% object match the dimensions of the video frames.
vidRes = vid.VideoResolution;
nBands = vid.NumberOfBands;
hImage = image( zeros(vidRes(2), vidRes(1), nBands) );
% Display the video data in your GUI.
preview(vid, hImage);

採用された回答

Madhav Thakker
Madhav Thakker 2020 年 9 月 15 日
Hi Koohyar,
I understand that you want to preview pre-recorded video and not a live one. The preview function requires a video input object which is not possible to create using pre-recorded video file.
VideoReader is used for reading and previewing a pre-recorded mp4 file. I am attaching a snippet from the documentation that does the same.
v = VideoReader('xylophone.mp4');
currAxes = axes;
while hasFrame(v)
vidFrame = readFrame(v);
image(vidFrame, 'Parent', currAxes);
currAxes.Visible = 'off';
pause(1/v.FrameRate);
end
Hope this helps.
  3 件のコメント
Koohyar
Koohyar 2020 年 9 月 21 日
Hi Madhav ,
Please can you let me know that how can I have a graystyle video, in the code you provided for me?
Thanks.
Madhav Thakker
Madhav Thakker 2020 年 9 月 23 日
編集済み: Madhav Thakker 2020 年 9 月 23 日

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by