フィルターのクリア

Using while loop in a video

4 ビュー (過去 30 日間)
Eliska Paulikova
Eliska Paulikova 2022 年 10 月 25 日
編集済み: KALYAN ACHARJYA 2022 年 10 月 25 日
Hello, My goal is to read a video, than split it to different number of frames, and than make it stop. It still does not work. Please help
vid=VideoReader("video.mp4");
k=200;
while hasFrame(vid)
frame=readFrame(vid);
numberOfFrames = vid.NumFrames;
framesToRead = 1:k: numberOfFrames;
limit=length(framesToRead);
for h = 1:length(framesToRead)
if h<limit
thisFrame = read(vid, framesToRead(h));
else
break
end
end
end
  1 件のコメント
Eliska Paulikova
Eliska Paulikova 2022 年 10 月 25 日
Well I have a video which has more than 100 000 frames --> So I need to read every 2000 frames. I now I have there the step k=200 but it suppose to be 2000
But still it does not work

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

採用された回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2022 年 10 月 25 日
編集済み: KALYAN ACHARJYA 2022 年 10 月 25 日
vid=VideoReader('video.mp4');
frame_num=vid.NumFrames;
frame_format='.jpg';
vid=read(vid);
for i=1:frame_num %Initial Level: Check with less number of frames, e.g.i=1:5
frame_name=num2str(i);
file_name=strcat(frame_name,frame_format);
Vid_frame=vid(:,:,:,i);
imwrite(Vid_frame,file_name);%Save the frame in the current directtory
% Or you can save the frame(images) into specific directory also.
end
It's perfectly working in my system with sample video. Hope it Helps, good wishes!
Kalyan
  1 件のコメント
Eliska Paulikova
Eliska Paulikova 2022 年 10 月 25 日
Thank you so much

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by