Hi Xelnia,
I'll add to sock's analogy with some more concrete descriptions of how I remember this working from when Jeff and I were looking into this years ago.
The first key detail is that rng does not come into play for barrel release until the barrel screen is half way finished (half of the total number of barrels have already been released). Believe it or not, I think that the programmers were actually trying to simulate Kong getting "tired" after releasing so many barrels. So, if you are using a Level 5 save state, make sure that you are testing the screen while the Timer is below 4000.
Now for more details. It takes Kong exactly 97 frames to complete his "cycle" of releasing a barrel (except wild barrels and during hammer smashes, which I will ignore). Internally, there is this 32 frame counter which loops around and around from 31 to 0. Note that 32 x 3 equals 96. That's important. Next, assuming Level 5, if Kong is "ready" to begin a new cycle while the frame counter reads 4, 3, 2, 1, or 0 then he will do so. If it's some other number, say, 17, then Kong will do nothing on this frame and check again on the next frame (and will continue this every frame until the counter reads 4.
Notice that if Kong releases a barrel at 4, the next time that he is ready the counter will be at 3 due to his 97 frame cycle, and after Kong releases 5 barrels in a row (on the early portion of Level 5), the counter will then roll back to 31. While Kong waits for the frames to go by until the counter gets all the way back down to 4, he "pauses" briefly, causing a noticeable change in barrel spacing.
Next, once Kong gets tired, every time the counter lands on 4, 3, 2, 1 or 0, an extra rng-based check now occurs where there is a 50/50 chance that the frame will be skipped. So, during this time, instead of 5 barrels in a row being released, Kong will release a variable number of barrels in a row, typically about 2 or 3. In the rare event that all 5 of the frames are skipped, a "long pause" will occur while Kong waits for the counter to progress from 31 back to 4 again (twice in a row).
Lastly, any time an rng-based check occurs, the result can and often will change based on player input. This can easily be seen with save states. Save a state a few frames before a fireball crosses a ladder from left to right. Upon loading the state, if the player does no input, the fireball will have the same behavior every time (let's say, it passes by the ladder). But if the state is loaded and the player immediately inputs, then sometimes fireball behavior will change and it will climb the ladder.
Given all of this, it's unclear to me if a TAS could be created that can manipulate unlimited consecutive long pauses.