Log in

View Full Version : ConditionalSelect() bug ?


dan59
21st November 2012, 16:18
Hello

I make an abstract ofmy problem but the origianl thread is here :
http://forum.videohelp.com/threads/350663-Strange-Hue-problem

I use Ati TV wonder 600 to capture old family VHS.
I have a problem during the capture, the U and V are sometime inverted.

With the help of other people, I make a little script :

#fonction qui corrige le probleme d'inversion UV
function correct(clip c)
{
global U = c.UtoY()
global V = c.VtoY().Invert()
c=YtoUV(U, V, c)
return c
}

# on crée un clip corrigé (meme quand on a pas besoin de correction)
global clip2 = clip1.correct().ConvertToYV12
# flag de source (src1=1 -> clip1 , src1=0 -> clip2)
src1=true
#on detecte les image en erreur et on switch de source pour les imges suivantes
#VDifferenceToNext()>10
#!(VDifferenceFromPrevious()>10) pour eviter les erreurs en doublons
#!(YDifferenceFromPrevious()>50) changement de scene
#
clip3 = ConditionalSelect(clip3,"src1 = (VDifferenceToNext()>10 && !(VDifferenceFromPrevious()>10)&& !(YDifferenceFromPrevious()>50))? !src1 : src1 "+chr(13)+"(src1 ==true ? 0 : 1)", clip1, clip2,show=true)
# il reste a supprimer les 1ere images en erreur
clip4 = ConditionalFilter(clip4, clip3.correct(),clip3, "VDifferenceToNext()", ">", "10", true)

My problem is in the ConditionalSelect(), when I detect an U and V inversion, I switch from clip1 to clip2 BUT the frame where I detect the change stay in the clip.
To solve this problem, I need to use ConditionalFilter() to do the same correction but it's not optimised.

Do you think it's a bug on the ConditionalFilter()'s code ??
In fact, for me, when ConditionalFilter() need to switch, why it doing this on the frame+1 and not on the current_frame ?

Do you understand what I say ?
Thanks.

Gavino
21st November 2012, 18:54
I don't fully understand what you are saying, but it seems to me you need to do the ConditionalSelect based on the condition applied to the previous frame.

Try this (code also tidied up):
clip3 = ConditionalSelect(clip1.SelectEvery(1,-1), \
"src1 = (VDifferenceToNext()>10 && !(VDifferenceFromPrevious()>10)&& !(YDifferenceFromPrevious()>50))? !src1 : src1
src1 ? 0 : 1", clip1, clip2,show=true)

I assume the script you posted is not exactly the one you used, since 'clip3' and 'clip4' are used before they are defined.

Also, note there is no need for any of your variables to be global.