Writing RGB frames into video

Yes. It needs to exactly match the size used in initializing the writer, so you need to resize the images.