Lyris
8th May 2012, 20:53
Hi forum,
There is so much wrong with this master I've been handed that I want to put it to the forum to see if anyone has an alternative strategy for dealing with it. Really, this is special.
77-frame clipping indicating a scene change (81mb): http://www.mediafire.com/?2n0afoo6cj0jaw4
The source is PAL, 50i, Betacam SP. The telecine is out of phase unlike most PAL transfers. So one film frame is split across two video frames.
That's easy to fix, I used this code:
avisource("xxxxx.avi")
convertTOyv12(interlaced=true)
#Correct the out of phase telecine by separating fields->frames and deleting first frame, then reinterlacing
assumeTFF()
separatefields
deleteframe(0) #Knock things back into phase
weave()
But it gets weirder. If we comment out the 'weave' command we can see that both fields have different geometry! :eek: Which is why we have saw-tooth interlacing artefacts around the edges when we view the video as progressive.
So far I haven't been able to deal with this in any intelligent way. I experimented in Photoshop and pasted both fields in to a document and used the "Auto Align" feature to see if the second field could be warped to better match the first. It wasn't too successful. Even if it was, I'm not sure if I'd be able to automate that for half of the fields in the film.
Anyway, here's the rest of my script:
chubbyrain2() #Clean out composite rainbows, works best at FRAME level - be careful of artefacts
stab() #correct telecine jitter
#Noise Reduction combo:
source = last
pred = source # to get stronger denoising, put denoisers here, they will change how motion vectors are predicted
backward_vec2 = pred.MVAnalyse(isb = true, delta = 2, pel = 2, overlap=4, sharp=2, idx = 1, truemotion=true)
backward_vec1 = pred.MVAnalyse(isb = true, delta = 1, pel = 2, overlap=4, sharp=2, idx = 1, truemotion=true)
forward_vec1 = pred.MVAnalyse(isb = false, delta = 1, pel = 2, overlap=4, sharp=2, idx = 1, truemotion=true)
forward_vec2 = pred.MVAnalyse(isb = false, delta = 2, pel = 2, overlap=4, sharp=2, idx = 1, truemotion=true)
maskp1 = mvmask(kind=1, vectors=forward_vec1, ysc=255).UtoY()
maskp2 = mvmask(kind=1, vectors=forward_vec2).UtoY()
maskp3 = mvmask(kind=1, vectors=backward_vec1, ysc=255).UtoY()
maskp4 = mvmask(kind=1, vectors=backward_vec2).UtoY()
maskf = average(maskp1, 0.25, maskp2, 0.25, maskp3, 0.25, maskp4, 0.25).spline36resize(source.width, source.height)
smooth = pred.fft3dGPU(bw=16, bh=16, ow=8, oh=8, bt=1, sigma=4, plane=0)
source2 = maskedmerge(source, smooth, maskf)
source3 = source2.MVDegrain2(backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=400,idx=2)
source3
# ttempsmooth(maxr=7)
# gradfun2db(1.51)
#So now we have the fields aligned, but each field has different geometry!!!
#A combination of anti-aliasing and deinterlacing (eugh) seems to be the best way...
antialiasing(th_luma=1)
#This in itself isn't enough to cure the saw-tooth artefacts,
#so deinterlacing as a last resort:
QTGMC( Preset="very slow" )
SelectEven() #to get original frame rate
Sharpen(0.5, 0.5)
#Sharpen(1,1)
#Fix the too high black level
levels(10,1,255,0,255) #in,gamma,out,in,out
#TO DO later: dirt and scratch filtering + add some grain
The dirt and scratches are easy enough to take care of later. As you can see I resorted to just deinterlacing. Can anyone suggest a better way?
Problems that I am still left with:
* Although the rainbows can be taken care of, I'm left with dot crawl around some edges.
* There is a "diamond-like" crawling pattern in some coloured areas which obviously only gets worse with sharpening.
Does anyone have a better suggestion at any step?
Beta SP is component so I'm also not sure why there are composite artefacts in this... perhaps it's a dub from some older format.
There is so much wrong with this master I've been handed that I want to put it to the forum to see if anyone has an alternative strategy for dealing with it. Really, this is special.
77-frame clipping indicating a scene change (81mb): http://www.mediafire.com/?2n0afoo6cj0jaw4
The source is PAL, 50i, Betacam SP. The telecine is out of phase unlike most PAL transfers. So one film frame is split across two video frames.
That's easy to fix, I used this code:
avisource("xxxxx.avi")
convertTOyv12(interlaced=true)
#Correct the out of phase telecine by separating fields->frames and deleting first frame, then reinterlacing
assumeTFF()
separatefields
deleteframe(0) #Knock things back into phase
weave()
But it gets weirder. If we comment out the 'weave' command we can see that both fields have different geometry! :eek: Which is why we have saw-tooth interlacing artefacts around the edges when we view the video as progressive.
So far I haven't been able to deal with this in any intelligent way. I experimented in Photoshop and pasted both fields in to a document and used the "Auto Align" feature to see if the second field could be warped to better match the first. It wasn't too successful. Even if it was, I'm not sure if I'd be able to automate that for half of the fields in the film.
Anyway, here's the rest of my script:
chubbyrain2() #Clean out composite rainbows, works best at FRAME level - be careful of artefacts
stab() #correct telecine jitter
#Noise Reduction combo:
source = last
pred = source # to get stronger denoising, put denoisers here, they will change how motion vectors are predicted
backward_vec2 = pred.MVAnalyse(isb = true, delta = 2, pel = 2, overlap=4, sharp=2, idx = 1, truemotion=true)
backward_vec1 = pred.MVAnalyse(isb = true, delta = 1, pel = 2, overlap=4, sharp=2, idx = 1, truemotion=true)
forward_vec1 = pred.MVAnalyse(isb = false, delta = 1, pel = 2, overlap=4, sharp=2, idx = 1, truemotion=true)
forward_vec2 = pred.MVAnalyse(isb = false, delta = 2, pel = 2, overlap=4, sharp=2, idx = 1, truemotion=true)
maskp1 = mvmask(kind=1, vectors=forward_vec1, ysc=255).UtoY()
maskp2 = mvmask(kind=1, vectors=forward_vec2).UtoY()
maskp3 = mvmask(kind=1, vectors=backward_vec1, ysc=255).UtoY()
maskp4 = mvmask(kind=1, vectors=backward_vec2).UtoY()
maskf = average(maskp1, 0.25, maskp2, 0.25, maskp3, 0.25, maskp4, 0.25).spline36resize(source.width, source.height)
smooth = pred.fft3dGPU(bw=16, bh=16, ow=8, oh=8, bt=1, sigma=4, plane=0)
source2 = maskedmerge(source, smooth, maskf)
source3 = source2.MVDegrain2(backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=400,idx=2)
source3
# ttempsmooth(maxr=7)
# gradfun2db(1.51)
#So now we have the fields aligned, but each field has different geometry!!!
#A combination of anti-aliasing and deinterlacing (eugh) seems to be the best way...
antialiasing(th_luma=1)
#This in itself isn't enough to cure the saw-tooth artefacts,
#so deinterlacing as a last resort:
QTGMC( Preset="very slow" )
SelectEven() #to get original frame rate
Sharpen(0.5, 0.5)
#Sharpen(1,1)
#Fix the too high black level
levels(10,1,255,0,255) #in,gamma,out,in,out
#TO DO later: dirt and scratch filtering + add some grain
The dirt and scratches are easy enough to take care of later. As you can see I resorted to just deinterlacing. Can anyone suggest a better way?
Problems that I am still left with:
* Although the rainbows can be taken care of, I'm left with dot crawl around some edges.
* There is a "diamond-like" crawling pattern in some coloured areas which obviously only gets worse with sharpening.
Does anyone have a better suggestion at any step?
Beta SP is component so I'm also not sure why there are composite artefacts in this... perhaps it's a dub from some older format.