Log in

View Full Version : Interlaced croping, filtering / help


DSP8000
3rd May 2005, 08:20
Hi guys,

I've got a small problem with some of my scripts.
The source is old VHS (PAL) & I've captured it with my DV CAM.
There is some garbage at the bottom,left,right side of the picture.
Yesterday I found out some great filters & got very surprised with the picture quality improvement.
Following scarfi's_brain methods, I deinterlaced,cropped,resized back to 720,576, used fft3d, tdeint, limitedsharpen.

Can some of you gurus check my script, please.
-----------------------------------------------
AVIsource("D:\my_video.avi")
ConvertToYV12(interlaced=true)
AssumeBFF()
TDeint(mode=1)
Crop(26,2,-20,-16)
Lanczos4Resize(720,576)
AssumeBFF()
SeparateFields().fft3dfilter(sigma=2)
SelectEvery(4,0,3)
Weave()
LimitedSharpen(Lmode=2)
------------------------------------------------

I'm just not sure about the croping & resizing thing.
Tnx. for any help in advance:)

DSP8000

zilog jones
4th May 2005, 11:52
Resizing like that is an awful waste - you'll be better off just using Crop then AddBorders to make it back to 720x576. When watching on a normal TV you won't notice the black borders as they'll be overscanned, but only up to about 16-20 lines - you might see 26, so you may want to crop less from that side.

You lose a lot of quality by sizing by such a small a value *and* with interlcaed video.

DSP8000
4th May 2005, 12:25
Tnx. for the info zilog jones:)
I know about overscan.
So, 16-20 lines is usual TV overscan?

I've ended up encoding the video without croping, resizing, watched today & it looks very good, all of the garbage from the sides & bottom was not visible.The only reason why I wanted to crop, resize is because the encoder wouldn't have to encode the garbage as well, thus faster encode.

DSP8000

Didée
4th May 2005, 12:28
Moreover, at the end LimitedSharpen() is applied to interlaced content. That's a complete no-no. LimitedSharpen is for progressive content only. For interlaced stuff, it must be used either on separated fields, or on a bobbed stream with re-weaving afterwards.
For above script, move the LS() line to this location:
[...]
SeparateFields().fft3dfilter(sigma=2)
SelectEvery(4,0,3)
LimitedSharpen(Lmode=2)
weave()

Then, it's not fully clear to me why fft3dfilter() is applied to separated fields, after the clip has been bob-deinterlaced to 50fps by TDeint? (But well, me & interlacing ... oh my dear) :D


edit: Script sniplet corrected: created too much overhead.

scharfis_brain
4th May 2005, 14:25
Didèe!

indeed! interlaced impaired!

either:


SeparateFields()
fft3dfilter(sigma=2)
LimitedSharpen(Lmode=2)
weave()


or

assume?ff # set correct fieldorder
bob() # or tdeint(mode=1) or leakkernelbob()
fft3dfilter(sigma=2)
LimitedSharpen(Lmode=2)

assume?ff() # set the same fieldorder again!
separatefields()
SelectEvery(4,0,3)
weave()

Didée
4th May 2005, 15:27
Originally posted by scharfis_brain
Didèe!

indeed! interlaced impaired!
:D

I didn't even think about whether DSP8000's script is correct or not, regarding the deinterlacing.
But blindly assuming it was correct, LimitedSharpen obviously was placed at the wrong position.

If SeparateFields().fft3dfilter(sigma=2)
SelectEvery(4,0,3)
Weave()
# LimitedSharpen(Lmode=2) is correct here, then SeparateFields().fft3dfilter(sigma=2)
SelectEvery(4,0,3)
LimitedSharpen(Lmode=2)
Weave() is correct, too. The former, with LS activated, is cr*p in any case.

I'd be more interested in a comment about applying fft3d to the "fields" separated from a bobbed 50fps stream. IMIO (in my impaired opinion :) ), the whole separatefields/weave stuff is not only superfluid, but even contraproductive, since the stream was already bob-deinterlaced beforehand. (?)

scharfis_brain
4th May 2005, 16:11
this will half the framerate causing ultra jerk motion!

Didée
4th May 2005, 16:42
Originally posted by scharfis_brain
this will half the framerate causing ultra jerk motion!
What will halve the framerate??

/*me gets the feeling there's a hidden camera around & I'll be in TV somewhen soon*/

Reducing TSP8000's script to the bones (of field manipulations), there is
AVIsource (PAL)

TDeint(mode=1)
# -> result: 50fps progressive

SeparateFields()
# -> result: field sequence @ 100Hz

FFT3dFilter()
# -> FFT3d is working on 100Hz field sequence. WHY??

SelectEvery(4,0,3)
# -> result: field sequence @ 50Hz

Weave()
# -> result: 25fps interlaced

We see:

FFT3dFilter, being a spatio-temporal one, is working on a 100Hz field sequence created out of 50fps progressive (bob-deinterlaced) frames. Since FFT3d works spatio-temporal, my understanding is that the temporal part is compairing subsequent scanlines of different vertical alignment, because it is actually working on a sequence of separated fields.

Why should
TDeint(mode=1)
FFT3dFilter()
SeparateFields()
SelectEvery(4,0,3)
Weave()

give half framerate and/or ultra-jerky motion? FFT3d works on fluid 50fps full frames, then the according scanlines are re-weaved, and everything is fine. Or is it not?

scharfis_brain
4th May 2005, 16:53
OMG!

I've totally missed, that you were only showing an EXERPT of his script...

DSP8000
4th May 2005, 17:05
Then, it's not fully clear to me why fft3dfilter() is applied to separated fields, after the clip has been bob-deinterlaced to 50fps by TDeint?

Didée, to be honest I did that out of habit.
The help file for fft3d filter clearly says "2. Directly works with progressive clips only. For interlaced sources, probably you must use SeparateFields, SelectEven, SelectOdd, FieldUnfold, Bod and/or similar methods."


scharfis_brain, thanks for the correction
------------------------------------------------
assume?ff # set correct fieldorder
bob() # or tdeint(mode=1) or leakkernelbob()
fft3dfilter(sigma=2)
LimitedSharpen(Lmode=2)

assume?ff() # set the same fieldorder again!
separatefields()
SelectEvery(4,0,3)
weave()
------------------------------------------------
I'll reencode to see how it looks.
Do you guys have any comment or suggestion on my croping/resizing?

DSP8000

zilog jones
5th May 2005, 23:00
With VHS cap's I usually cut off the total junk around the edges, but as little as possible. I don't know how much difference it makes with encoding.