Cannot get the correct AVI frame size after capturing multiple widget contents and outputing the AVI files

Frame images are correct for the generation of the AVI file, one image per frame, which I can see the animation effect from the output .avi file. I don’t need to merge all images together in each frame. Only need show one image for each frame.

I did not put the merged captured image for the case of multiple widgets. The merged captured image works fine in the code.
like the following:
The frame image is merged from two vertical widgets(capturing each image then merge in the right position).

The issue is the image in each frame did not fill the whole size.
Here we can see a large area of black region. I don’t need this black area. I have tried changing the size of canvas, the size of image, did not work. Who knows how to fix? Thanks.