You know those infinite loop videos uploaded to Twitter? You just can't help but watch them, right?
When it comes to infinite loop videos, GIF format videos are famous, but on Twitter, you can make videos loop even if they aren't GIF loop videos.
This time, let's try doing it without using GIF loops.
How do you make it loop?
The Twitter FAQ states, 'All videos posted to Twitter that are 6.5 seconds or shorter will automatically loop.'
In other words, if you just create and upload a video that is 6.5 seconds or shorter without overthinking it, it will automatically loop.
'Videos 6.5 seconds or shorter will loop' is information as of September 4, 2018. As of September 20, 2020, it is 'videos 60 seconds or shorter will loop'.
But if you do this, it's just a choppy animation playing on repeat, right?
To make the movement look like it continues infinitely, you need to connect the beginning and the end.
For example, by having it pass from top to bottom, or left to right,
or by having it move in a circle.
But is this a bit monotonous on its own?
Can complex movements also be looped?
The circular motion from earlier—the sin/cos values that form it repeat and loop between -1 and +1 forever, right?
If you incorporate this into the parameters that control the animation's movement, you can easily create animations that continue to repeat smoothly and seamlessly, just like moving along a circumference.
With a little bit of ingenuity, you can make even complex movements like this loop perfectly.
Specifically, if you are creating a 15fps x 6-second animation using Processing as an example,
sin(TWO_PI * frameCount / (15 x 6))
using this value will allow the zero frame and the final frame to connect seamlessly.
However, if the video is one where the sin() value directly dictates the movement, it can sometimes feel too much like it's 'going back and forth,' so you might need to add some tricks like mixing in noise.
Example
// Twitter 無限ループアニメーションの作り方
// @author @deconbatch
// @version 05 作例
// Processing 3.2.1
// 2018.09.02
// 15fps x 6s = 90f
void setup()
size(720, 720);
colorMode(HSB, 360, 100, 100, 100);
blendMode(SCREEN);
noStroke();
smooth();
void draw()
background(0, 0, 0, 100);
translate(width / 2, height / 2);
// このパラメータを変えると動きが変わります。
float paramWaveX = 0.995;
float paramWaveY = 1.005;
float paramBendX = 1.0;
float paramBendY = 1.0;
int spotCntMax = 100;
int frameCntMax = 15 * 6;
for (int spotCnt = 1; spotCnt <= spotCntMax; ++spotCnt)
// ここの radian の計算がミソ!
float radian = TWO_PI * frameCount / frameCntMax;
float startPos = map(spotCnt, 1, spotCntMax, TWO_PI * 100.0, 0.0);
float radius = sin(map(spotCnt, 1, spotCntMax, 0, PI * 0.5)) * 280 + 50;
float hueApply = map(spotCnt, 1, spotCntMax, 200.0, 260.0);
float x = radius * cos((radian + startPos) + sin((radian + startPos) * paramWaveX) * paramBendX);
float y = radius * sin((radian + startPos) + cos((radian + startPos) * paramWaveY) * paramBendY);
fill(hueApply, 40.0, 60.0, 100.0);
ellipse(x, y , 13.0, 13.0);
ellipse(-x, -y , 13.0, 13.0);
saveFrame("frames/####.png");
if (frameCount > frameCntMax)
exit();
/*
Copyright (C) 2018- deconbatch
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/I have set the license to GPLv3.
Please feel free to use it.
There is a saying that creativity increases when you add constraints.
Why not let your creativity shine under the 6.5-second limit?
Summary
・Videos 6.5 seconds or shorter on Twitter are automatically looped.
・Using sin() is a good way to connect the beginning and end smoothly.
Reference
Please also refer to this for how to create videos in Processing.