https://casualganpapers.com/periodic-image-animation/EndlessLoops.html
Check out this paper summary