Log in

View Full Version : Hue flicker between analog fields


Filker
1st May 2009, 14:34
Hi, this is my first post here so bear with my newbness plz!

I've captured my old analog PAL VHS tapes (video8 to be exact) to a lossless compressor (huffyuv)

Now I want to make a progressive version keeping as much info as possible. In the process of doing 25 fps to 50p deinterlacing (through mvbobmod, thx scharfis_brain!) I slammed into one of VHS's "features". Every field (now every frame because of deinterlacing) is either too reddish or too greenish (more pronounced in PAL than NTSC maybe?) so I made the following script to cope with it:

clip=AVISource("capture.avi").ConvertToYV12().Assumetff.mvbobmod
reddishA=SelectEvery(clip,4, 0).tweak(hue=-10,bright=+5,cont=1.1)
reddishB=SelectEvery(clip,4, 1).tweak(bright=+5,cont=1.1)
greenishA=SelectEvery(clip,4, 2).tweak(hue=+2,bright=+5,cont=1.1)
greenishB=SelectEvery(clip,4, 3).tweak(hue=-5,bright=+5,cont=1.1)
Interleave(reddishA,reddishB,greenishA,greenishB)

So far so good. This is how far searching the board and copy pasting may take any noob.

Next problem is that every time there's a scene change (handycam stopped recording and restarted) there's a 50% chance this code will get messed up and it will add red where it should be reducing and vice-versa.

Is it possible to have a routine detect if we're at a reddish or greenish frame and adjust accordingly knowing that every 2 frames should be reddish and every other 2 should be greenish (except when there's a scene change)? Or will I have to hunt down every scene change by hand?

The sequence can be for example:
nomenclature: Ff= Frame,field (ie field 2 of frame 4 = 42)

11reddish,12greenish,21greenish,22reddish,31reddish,32greenish,41greenish [scene change] 42greenish,51reddish,52reddish...

That's why it's not very noticeable when playing interlaced, the error is averaged out by the human eye since every frame has a bit of excess red and excess green (VHS look, :rolleyes: ).

http://www.mypicx.com/05012009/redgreeninterlaced/

Greenish:
http://www.mypicx.com/uploadimg/1877356972_05012009_1.jpg

Reddish:
http://www.mypicx.com/uploadimg/1890301667_05012009_2.jpg

Interlaced:
http://www.mypicx.com/uploadimg/556044523_05012009_3.jpg

Adub
1st May 2009, 19:50
You should be able to achieve your desired effect using the awesome Masktools package. It may even be able to do it "automatically", provided you have the proper configuration. Unfortunately, I do not possess the desired knowledge for this scripting feat, but I do know that there are others on this forum who are more than qualified.

Maybe look at the usage of mt_lut, perhaps?

zilog jones
1st May 2009, 23:40
You should try out MCTemporalDenoise with chroma processing enabled - although it won't do the specific filtering you're looking for it should smooth out that flickering. Though I'm sure it'll be very slow if you're using mvbobmod at the same time :)

Lynx Pardinus
2nd May 2009, 15:26
What color space did you use for capturing, YV12?

I have also come across this problem, but since I capture using lossless Lagarith YUY2 I have noticed that the problem is not that every captured field is shifted to green or red alternatively.

The problem is that the lines of every field are shited to green and red alternatively.

One quick and dirty solution is: capture in YUY2 and then

AVISource("D:\test.avi")
AssumeTFF()
luma=last
SeparateFields()
Blur(0,1.0)
chroma=Interleave(SelectEven(), SelectOdd()).Weave()
MergeChroma(luma, chroma)
ConverttoYV12(interlaced=true)

You are losing some vertical resolution in YUY2 but not that much assuming you will convert to YV12 and this way the color histogram looks better than shifting the hue. I can tell because in my capture there were a few frames without the hue shift, they showed a huge interference at the PAL color carrier frequency instead.