Log in

View Full Version : Detecting a loop


shroomM
17th December 2008, 09:53
Hey,

I've got a clip of a fireplace burning, which is 1 hour in length.

I think that the whole clip is just one shorter clip, repeating itself, but am not sure of this.

It's practically impossible to manually figure out if the clip is indeed just another clip looping.

Is there any way to loop through all the frames, comparing all of them to the first one and somehow find if there is a loop?

hanfrunz
17th December 2008, 13:55
you can try something like this (i assume fps is 25, and lenght=1 hour)


offset=0
video={your clip}
search_short=video.trim(0,int(framerate(video))) # take one second to look for
search_long= search_short.Loop(60*60+int(framerate(video))) #repeat the part to look for to get one hour + one second
Subtract( video.trim(offset,0),search_long.trim(0,60*60+int(framerate(video))-offset))


now watch the script in vdub. You'll see the difference of the clip and looped first second. Look for frames that are totaly grey and you have found a part which is the same. Then increase offset + 1 and do the same again. Do that until offset is 25. Now you should have found all positions of the first second of your clip.

hanfrunz

2Bdecided
17th December 2008, 14:48
If it was looped in the uncompressed domain (i.e. before MPEG-2 encoding), and then MPEG-2 encoded, then unless the GOPs line up with the loop period, the "same" frames won't be the same due to different encoding artefacts.

If it was looped in analogue, or even before a noise introducing D>A>D conversion, then you have no chance.

At best, the "same" frames might be less different than the "different" frames.

Cheers,
David.

shroomM
17th December 2008, 15:19
Thank you for the script, it was of great help!

The codec used was MJPEG.