The second gif is just the same footage looping.. As for the first, and perfect, gif, notice that as the guy holding his head moves from right to left, he is acting as an eraser that wipes the current video and replace it with another one that starts from the beginning. English is not my first language, so I'm sorry…