Log in

View Full Version : insert 'cutaway' shots, ConditionalFilter or ScriptClip?


protovision
21st March 2011, 18:29
Hey,

I want to dynamically insert 'cutaway' shots when I detect a scene change, then cut back to the original footage.

IE:
1. David Letterman makes a (bad) joke (*camera cuts to different angle)
2. cut to shot of Tom Hanks sitting at The Oscars laughing
3. cut back to Letterman

I have 2 clips, the main clip, and my clip containing random cutaways. I don't need to worry about when to cut the cutaways, all I need is to detect scene or angle change in the main footage, inject 10 sec cutaway, cut back to main footage.

This has to happen in realtime during playback, I cannot manually specify where the scenes change or camera changes angles.

Any suggestions? Will ConditionalFilter or ScriptClip help me?

thanks!

Gavino
22nd March 2011, 03:40
Automatic detection of scene changes is not 100% reliable, and inserting extra frames with ScriptClip is quite tricky, but try this (requires GScript):
function GetCutaway(int i) {
# insert code here to
# return the clip to be used for the i'th cutaway (0 = first)
# eg a trim from a compilation of suitable scenes
...
}

thresh = 5 # luma difference threshold for scene detection (adjust to suit)
showCut = false # are we currently in a cutaway?
nCut = -1 # index of current cutaway clip
inserted = 0 # cutaway frames inserted so far
pad = 1000 # max no of cutaway frames expected

# ... # set source

# As ScriptClip cannot change clip length,
# pad to allow for insertions (repeat final frame):
Loop(pad+1, Framecount-1)

ScriptClip("""
GScript("
if (showCut) {
inserted = inserted+1
showCut = current_frame < cutEnd
# emit current frame of cutaway:
return cutClip.SelectEvery(1, -cutStart)
}
else {
# examine current frame of source:
SelectEvery(1, -inserted)
if (YDifferenceToNext() > thresh) {
# next frame is a new scene
nCut = nCut+1
cutClip = GetCutaway(nCut)
cutStart = current_frame+1
cutEnd = cutStart + cutClip.Framecount-1
showCut = true
}
# emit current frame of source:
return last
}
")
""")
[A nice problem for what turns out to be my 2000'th post. :)]

protovision
22nd March 2011, 13:50
That looks great, can't wait to try it tonight.

thx!