Create Seamless Loop

wayne-severson wrote on 3/25/2020, 12:20 PM

I've been attempting to creat a short loop to use as a background for a web page. I keep getting a quick flash or lurch or momentary drop out at the loop point. How can I do that. So far I've tried copying a short clip so the two play back to back, then reversing the second clip so the the footage should be indentical at the loop point. There's something else causing the glitch.


john_dennis wrote on 3/25/2020, 12:33 PM

Does the glitch appear if you render to a lossless intermediate?

Musicvid wrote on 3/25/2020, 1:54 PM

There's something else causing the glitch.

They are called headers.

You cannot make a player loop seamlessly using Long-GOP (MP4). If you turn off b-frames completely and keep the bitrate at a sane value, it is possible to reduce the skip down to one frame.

What embedded player are you using on your website server?

You "could" render say 100 identical events on the timeline, thus reducing the number of skips greatly.

Do try some intraframe renders as @john_dennis suggests.

wayne-severson wrote on 3/25/2020, 2:24 PM

I had no luck with an intermediate. Looks like there are several, perhap greater than 10 black frames at the begining. I don't yet know what b-frames are that you suggest (black frames?)

I accidentally discovered if I render at 640 by 320 there is no glitch, witch may be fine for this application. But still we do like to be in control.

I am not using VLC, just the default pc player, and most importantly the video loops in the wordpress theme I'm using.

Musicvid wrote on 3/25/2020, 2:29 PM

B-frames are bidirectional predictive frames in the GOP structure. Nothing to do with the color..

Please post this information.

Musicvid wrote on 3/25/2020, 2:39 PM

just the default pc player.

We don't know what that is. If you will tell us which player is embedded, and provide an original sample we may be able to help. But it sounds as if you will have a steep learning curve ahead.

wayne-severson wrote on 3/27/2020, 5:40 AM

link to clip (about 16 Mb)

Windows media player, &, Movies and TV. both players show the glitch

Complete name                            : M:\Washedup Promotional pics\WebPageMedia\Test.mp4
Format                                   : MPEG-4
Format profile                           : Base Media / Version 2
Codec ID                                 : mp42 (isom/mp42)
File size                                : 15.7 MiB
Duration                                 : 15 s 957 ms
Overall bit rate mode                    : Variable
Overall bit rate                         : 8 256 kb/s
Encoded date                             : UTC 2020-03-25 19:09:39
Tagged date                              : UTC 2020-03-25 19:09:39

ID                                       : 2
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Main@L3.1
Format settings                          : CABAC / 4 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 4 frames
Format settings, GOP                     : M=4, N=15
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 15 s 949 ms
Bit rate mode                            : Variable
Bit rate                                 : 8 065 kb/s
Maximum bit rate                         : 16.0 Mb/s
Width                                    : 854 pixels
Height                                   : 480 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 29.970 (30000/1001) FPS
Standard                                 : NTSC
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.656
Stream size                              : 15.3 MiB (98%)
Language                                 : English
Encoded date                             : UTC 2020-03-25 19:09:41
Tagged date                              : UTC 2020-03-25 19:09:41
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709
Codec configuration box                  : avcC

ID                                       : 1
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : mp4a-40-2
Duration                                 : 15 s 957 ms
Bit rate mode                            : Variable
Bit rate                                 : 192 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 368 KiB (2%)
Language                                 : English
Encoded date                             : UTC 2020-03-25 19:09:39
Tagged date                              : UTC 2020-03-25 19:09:39

FayFen wrote on 3/27/2020, 9:55 AM

Did you cut one frame at the start of the reversed clip at the joint?

lenard-p wrote on 3/27/2020, 11:41 AM

I did a 10 second version without first 3 frames - looks better

wayne-severson wrote on 3/27/2020, 11:57 AM

I did not cut a frame on the reversed clip, either end.

To make a version without the first 3 frames would require a 2nd rendering correct?


lenard-p wrote on 3/27/2020, 12:19 PM

your first frame is black, that's the problem you were talking about, frame 2 and 3 flash, I think deliberately as an effect to start video, but I don't like as that makes the loop obvious. you get frame doubling if you do not cut a frame where clip reverses, and the end frame (or first)

Yes cut first frame (for first 3), copy and reverse clip, and if you care remove the 2 duplicated frames, 1 in middle , 1 at end

john_dennis wrote on 3/27/2020, 12:20 PM

"To make a version without the first 3 frames would require a 2nd rendering correct?"

Correct. Make changes to your project and render the loop again. Don't edit a previously rendered video when using a lossey codec like the one you used for the file you uploaded.

Musicvid wrote on 3/27/2020, 1:24 PM

I know you have plenty of experimentation ahead of you, so here is a benchmark for you to try out on various players. It was encoded CABAC on, bframes=0 in Handbrake; it has a one-frame reset at loop points, which means it is the very best "looping" that can be done with a long-GOP encoder format. On a capable player, the "loop" point occurs every sixty seconds,

If you want to play with it, download from the link, not the embedded thumbnail, which is reprocessed. It plays "almost" seamlessly in Windows Media Player Classic.

Animation courtesy NASA.

Now, here is your clip, given the same treatment. How does it look to you? Again, download only from the link.

I think you need to understand that your online streaming is done by a server-embedded player, not anything you can access in Windows locally without an Apache server. Study.

SWS wrote on 3/27/2020, 4:44 PM

I create animated scenes to use as projected backgrounds for stage shows. I stumbled into this business a few years ago when I found out folks weren't painting flats anymore, they were using video-projectors, projecting scenes on cyc curtain a behind the actors...who knew??? I started using my limited animation skills to create scenes for plays like "The Wizard of OZ", "Mary Poppins", "Peter Pan" etc. It took a few shows to realize I need to create "seamless loops" so that the .mp4 clip I create would playback as long as the director needed it to play. The way I do it and it may not work for you is to put the...say a 2 min. animation on the Vegas timeline, split it in the middle, swap the right half to the left and swap the left half to the right,,,what was the end of the clip is now the front and the front is now the end. I nudge the two pieces together and create a dissolve in the middle and then the clips will repeat "seamlessly". Granted there is a dissolve in the middle but for my purposes it works fine. As I say may not work for you and I may have misread what you were doing but there it is.😄

Musicvid wrote on 3/27/2020, 5:33 PM


You have access to the file now, I thought it was already shared.:-)

wayne-severson wrote on 3/27/2020, 6:36 PM

Thank you all very much! I'll do my experimenting and come back soon as I can. Musicvid, I have your file downloaded.

wayne-severson wrote on 3/31/2020, 6:23 PM

One thing I've discovered that helps is to turn quantize to frames on. I had it off to line things up with the music beat which is totally unneeded in this instance. I haven't yet been able to locate the parameters CABAC on, bframes=0 in Handbrake (updated to the latested version)

Musicvid wrote on 3/31/2020, 8:18 PM

Quantize should be on 100% of the time. No exceptions that I'm aware of.

X264, in either Happy Otter or Handbrake exposes the advanced encoding parameters. Sorry I should have pointed that out.