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));"

36 views (last 30 days)
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));

Accepted Answer

Walter Roberson
Walter Roberson on 13 Jul 2015
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 Comment
James Marron
James Marron on 30 Aug 2023
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);"

Sign in to comment.

More Answers (0)

Categories

Find more on Animation in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!