Why do i get error in videowriter as "Error using VideoWriter/writeVideo Frame must be 436 by 344 Error in videoominusone (lwriteVid​eo(writerO​bj,getfram​e(gca));"

39 次查看(过去 30 天)
Please help me to solve this errror
Error using VideoWriter/writeVideo (line 383)
Frame must be 436 by 344
Error in videoominusone (line 286)
writeVideo(writerObj,getframe(gca));

采纳的回答

Walter Roberson
Walter Roberson 2015-7-13
Every frame that you write with VideoWriter must be the exact same size.
getframe(gca) returns according to the current axes size. If you have not taken special care, that axes size will not necessarily be exactly the same size as the previous frame.
You should be considering setting up the axes once and using "hold on", and then updating only the content of the axes. Your current code likely rebuilds the axes each time through your loop.
  1 个评论
James Marron
James Marron 2023-8-30
Had this problem, which was caused by first creating an image, and then plotting additional graphics on top, within each frame. Sometimes the additional graphic would extend beyond the image which would then extend the axes beyond hte original image. The function getframe would still contruct a movie structure (with indeed difernt sizes of cdata in different frames). That seemed to generate this error when VidoWriter was called. The solution for me was:
  1. After creating the image part, but before adding the additional graphics, store the axis limits, wth a command like "vaxlim = axis;"
  2. Add the additional graphcs
  3. Restore the orginal axis limits useing "axis(vaxlim);"

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Animation 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by