Problem with creating video and frame
9 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Neda
il 26 Ago 2025
Risposto: Walter Roberson
il 26 Ago 2025
Dear Matlab Team,
I have a question regarding creating the video.
I have this, at the beginnig of my code, before the "for t=1:1000"
fig = figure('Position', [100, 100, 1924, 975]);
axis tight manual;
------------------------
drawnow;
frame = getframe(fig);
writeVideo(writerObj, frame);
-------------------------
But still get the error:
Error using VideoWriter/writeVideo
Frame must be 1924 by 975
Error in testfile (line 741)
writeVideo(writerObj, frame);
Thank you
0 Commenti
Risposta accettata
Walter Roberson
il 26 Ago 2025
The second and each following frame of video must be the same size as the first frame that is written.
Each time you draw a new plot, there is the possibility that getframe() of it might be a slightly different size, even if the figure size and axes size remains exactly the same.
In particular, the algorithm for automatically labeling axes has a little bit of slop for the position of the rightmost characters. Because of that, the captured axes width can be up to 2 pixels shorter than normal, or up to 5 pixels wider than usual.
One typical work-around is to imresize() the second and following captured frames to be the same size as the first captured frame.
0 Commenti
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!