How to use real time for writeVideo
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I am using following code to track a point in 3d with respect to time.
h=animatedline('Marker', 'o');
vidObj=VideoWriter('abc.avi');
open(vidObj);
for i=1:length(t) % t is time as an vector defined by user with, let's say, 1/10000 sec as time interval
addpoints(h, x, y, z) % x,y,z are of same length as of t
view(45, 45)
frame=getframe(gcf);
writeVideo(vidObj, frame);
drawnow
end
close(vidObj)
The program is running alright but the video generated in slow as compared to the time t which was defined already. for example the total video time is 0.16 sec whereas the actual time was only 0.05 sec. I want the video time to be 0.05 with real time speed.
Kindly help.
0 Commenti
Risposte (1)
Rahul
il 24 Gen 2025
I understand that while trying to track 3d points and create a video object while doing so, the speed with which the video gets created would not be as expected in a real time simulation video.
The following MATLAB Answers mention that adjusting the 'FrameRate' property of the 'VideoWriter' object would ensure that each frame in the video corresponds to the same time interval as your data.
Here is an example, how you can adjust the code:
desiredFrameRate = 1 / length(t)
% Set the frame rate for the video
vidObj.FrameRate = desiredFrameRate;
Refer to the following MathWorks documentation to know more:
Thanks.
0 Commenti
Vedere anche
Categorie
Scopri di più su Audio and Video Data in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!