Saliency Maps in Videos

I’m a beginner in opencv, so sorry about that.

I’m trying to implement a code that creates saliency maps in a video. I’ve done it in images, but I’m not sure what is the best way to do it in videos?

I’m particularly concerned about the size of the videos. What do you think is the best way to optimize the performance of my function?