필터 지우기
필터 지우기

How can i write multiple video files? with videoWriter?

조회 수: 14 (최근 30일)
Bilal qureshi
Bilal qureshi 2018년 6월 1일
댓글: Walter Roberson 2018년 6월 1일
I want to write multiple video files and my conditions are here
j=1
if (t >= 125)
writerObj1 = VideoWriter('voilation1.avi');
open(writerObj1);
writerObj2 = VideoWriter('violation2.avi');
open(writerObj2);
disp("<--------- Violation Detected----------> ")
vidname=strcat('writerObj',num2str(j));
writeVideo(vidname,img1);
end
if(t ==600)
close(vidname);
j=j+1;
end

채택된 답변

KSSV
KSSV 2018년 6월 1일
X = rand(100,1) ;
writerObj1 = VideoWriter('Video1.avi');
writerObj2 = VideoWriter('Video2.avi');
writerObj1.FrameRate = 10;
writerObj2.FrameRate = 10;
% open the video writer
open(writerObj1);
open(writerObj2);
h1 = figure(1) ;
hax1=axes ;
hold on
h2 = figure(2) ;
hax2=axes ;
hold on
for i = 1:length(X)
if X(i)<0.5
plot(hax1,i,X(i),'.r')
f1 = getframe(h1);
writeVideo(writerObj1, f1);
else
plot(hax2,i,X(i),'.b')
f2 = getframe(h2);
writeVideo(writerObj2, f2);
end
% close the writer object
end
close(writerObj1);
close(writerObj2);
  댓글 수: 4
Bilal qureshi
Bilal qureshi 2018년 6월 1일
its not only two objects i want to make dynamically writing object with loop ??
how can i write like this
vidname=strcat('writerObj',num2str(j));
writeVideo(vidname,img1);
Walter Roberson
Walter Roberson 2018년 6월 1일
You cannot. You need to call VideoWriter to create a new object for the new file. writeVideo does not accept a file name as a parameter, and there is no way to change the file name associated with a VideoWriter object after you have created the object.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by