Animated Gif with Opencv

sorry, but there is nothing builtin to do that here.
(it neither reads nor writes gif)

save your animation as an image list, then use some external tool to write a gif from it.