How to make a seemless back and forth video loop? Ping Pong? Rebound? Boomerang?

Hello,

How can I make a very short length seemless video loop in Shotcut so, for example, a dog walking forward a step and then backwards a step?

I think it’s sometimes called ping pong looping, or boomerang looping, or rebound looping, forward and reverse looping?

Any other names for this type of looping?

I think it’s fun to see things smoothly loop forward and reverse, back and forth like that, on and on.

So the video frames would be something like this

Frames 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4 ,3, 2 ,1, 2, 3 ,4 ,5 ,6 …etc?

No gaps.

No black frames at beginning or end.

Just simple seemless back and forth looping.

Thanks for any ideas and techniques.

Step 1: Make the forward motion video like normal.

Step 2: Export the project from Step 1 with an intermediate or lossless format like FFV1 or DNxHR HQ. There are stock presets for these formats in the export panel.

Step 3: Add the video from Step 2 to the end of the timeline.

Step 4: Reverse the video from Step 3. (Look at the clip Properties panel and click the Reverse button.)

Step 5: Export the whole video using a format that supports looping, such as Animated PNG. Export settings for APNG can be found here:

Note that Animated PNG does not support audio.

Theoretically, looping WebP could work too with a loop=0 line on the Other tab, but I have not personally tested this. The file size should be notably smaller than APNG.

EDIT: I forgot, there is already an export preset for Stock > WebP Animation built into Shotcut. If you want a clean video look with no GIF-like pixelation, the quality will probably have to be bumped up to 95% or higher.

2 Likes

I’ll have to try that method @Austin. Thanks.
Earlier today I started to make a quick tutorial on how I usually loop a clip.
I’ll share it too, as an alternative.

By the way, to create seamless loops, there is also this method explained by Aaron Nace in his tutorial on how to create Cinemagraphs in Photoshop. It can easily be adapted for Shotcut to create a looping GIF or a single-loop video that can be repeated in a project.
Not what @frew asked for. But it’s a nice technique to learn.

3 Likes

Thanks Austin for that.

I’m trying it now.

Just wondering though, as I try to learn the reasons for your suggestions.

Why is lossless (or intermediate format) export in step 2 needed?

And what is an intermediate format?

And why in step 5 is it needed to export in a format that supports looping?

ie rather than a common mp4 file for example.

Thanks

Most MP4 are compressed using something called B-frames and sometimes open GOP, which makes them unsuitable (too slow and unreliable backward seeking) for reverse playback of every frame. Properties > Reverse always converts to avoid that.

You do need to use lossless as every option is high quality. A short file or trimmed clip is fine for lossless, but it will generate a huge file if long.

If you know your MP4 is edit-friendly (no B-frames or open GOP) you can use the time filter Speed: Forward & Reverse to reverse it without conversion. When you try to add the filler it will warn you if it is incompatible.

Two reasons:

  • To retain extremely high quality. Otherwise, the second half of the movie will look lower quality than the first half.
  • Intra-frame formats work better when doing a lot of frame seeking, which happens during the Reverse operation.

Very high quality, visually lossless, but not bit-for-bit exactly lossless. Usually smaller file size than lossless, and sometimes faster processing.

Looping is what you specifically requested. Standard MP4 does not support looping. A final MP4 video would look like forward motion, backward motion, done. No repeat. To get a seamless repeat, the format must support looping. Very few formats do.

Nice! For looping a video with only a single source clip, your way is definitely faster and easier. Without knowing exactly what the OP was doing, I suggested a more generic method that will work even if the source is an image sequence, or if there are multiple source videos or multiple tracks involved (like text or special effects).

2 Likes

Thank you all for the technical advice and explanations.

Very much appreciated.

This gives me tools and techniques to work with and I’m starting to get some results I like.

One small note, with the dog video example technique above, I try removing one frame from the beginning and ending of the 2nd (reversed) clip, for an even smoother “turnaround”.

So, for example with a very short loop, the frame numbers would go like this:

1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2 , then loop, rather than this:

1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, then loop.

…because those duplicate frames can cause a very subtle, yet noticeable, pause in the continuous flow of the motion.

3 Likes