Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 7th December 2004, 13:11   #1  |  Link
dplaton
Registered User
 
Join Date: Apr 2004
Location: Romania
Posts: 101
How to process interlaced and the final result to be interlaced

I'm not a native English speaker and I feel that I don't understand correctly, so please help me.
Let's say
SeparateFiels()
Degrain()
Wave()

or

SeparateFields()
odd=SelectOdd.Degrain()
evn=SelectEven.Degrain()
Interleave(evn,odd)
Weave()
DoubleWeave.SelectOdd()


My AviSource is RAW YUV captured from a S-VHS JVC camcorder that
process internaly Digital and record on a S-VHS cassete.

My processor is a Duron 950 MHz

Can I use Convolution3D?

My Duron is not SSE.
dplaton is offline   Reply With Quote
Old 7th December 2004, 17:57   #2  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
Quote:
DeGrainMedian - Spatio-Temporal Limited Median filter for grain removal
thus second script (also when you use Convolution3d) ...
Wilbert is offline   Reply With Quote
Old 8th December 2004, 09:14   #3  |  Link
dplaton
Registered User
 
Join Date: Apr 2004
Location: Romania
Posts: 101
I don't understand the sequence

Weave() [I read that is equivalent to DoubleWeave().SelectEven]
DoubleWeve().SelectOdd()

I found an other script on http://www.afterdawn.com/avisynth_tu...age_6.cfm.html

#Functions For Processing Interlaced Video
#By stickboy (James D. Lin)#
# SetParity
function SetParity(clip c, bool parity)
{
return parity ? c.AssumeTFF() : c.AssumeBFF()
}
# UnfoldFieldsVertical
function UnfoldFieldsVertical(clip c, bool "flip")
{
flip = default(flip, false)
oldParity = c.GetParity()
c = c.AssumeTFF().SeparateFields().AssumeFrameBased()
top = c.SelectEven()
bottom = c.SelectOdd()
c = StackVertical(top, flip ? bottom.FlipVertical()
\ : bottom)
return c.SetParity(oldParity)
}
# FoldFieldsVertical
function FoldFieldsVertical(clip c, bool "flip")
{
assert(c.Height() % 2 == 0, "FoldFieldsVertical: unexpected frame height")
flip = default(flip, false)
oldParity = c.GetParity()
originalHeight = c.Height() / 2
evens = c.Crop(0, 0, c.Width(), originalHeight)
odds = c.Crop(0, originalHeight, c.Width(), originalHeight)
odds = flip ? odds.FlipVertical() : odds
c = Interleave(evens, odds).AssumeFieldBased().AssumeTFF().Weave()
return c.SetParity(oldParity)
}
#Stop Copying Here
dplaton is offline   Reply With Quote
Old 8th December 2004, 09:49   #4  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,733
Try this (you'll need TomsMoComp) :

Code:
AssumeTFF() or AssumeBFF() depending on your input clip's field order
TMCBob()
Degrain()
AssumeTFF() or AssumeBFF() depending on your input clip's field order
SeparateFields()
SelectEvery(4,0,3)
Weave()

function TMCbob(clip c)
{	ord = getparity(c) ? 1 : 0
	c = c.SeparateFields.TomsMoComp(1,-1,0)
	c = stackvertical(c.crop(0,0,0,1-c.height),c,c.crop(0,c.height-1,0,0))
	evn  = c.SelectEven 
	odd  = c.SelectOdd 
	evn = (ord == 0) ? evn : evn.crop(0,1,0,0).addborders(0,0,0,1)
	odd = (ord == 1) ? odd : odd.crop(0,1,0,0).addborders(0,0,0,1)
	interleave(evn,odd).crop(0,0,0,-2).assumeframebased()
}
If you don't know how to determine the field order, use a simple script like this:

Code:
AVISource("path\clip.avi")
AssumeTFF()
SeparateFields()
Open it in VDub and seek to a scene with motion. If the motion is smooth, your clip is top field first. If it jerks back and forth, it's bottom field first. You can verify this by using AssumeBFF() and doing the same test.
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 8th December 2004, 10:17   #5  |  Link
dplaton
Registered User
 
Join Date: Apr 2004
Location: Romania
Posts: 101
You lost me!
Let's take easy please.

1. AssumeTTF() - the correct order

2. TMCBob() - deinterlace and re-interlace correct???

3. Degrain() - grain removal

4. AssumeTTF() - once again the correct order

5. SeparateFields() - once again separate the fields

6. SelectEvery(4,0,3) - select frames I don't know

7. Wave() - that means to SelectEven()

As far as I can understand it seems to me that I apply Degrain() to an
interlaced clip. I understand correct???
dplaton is offline   Reply With Quote
Old 8th December 2004, 10:37   #6  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,733
Quote:
Originally posted by dplaton
1. AssumeTTF() - the correct order
To ensure that TMCBob() has the field order correct. It's AssumeTFF() btw.
Quote:
2. TMCBob() - deinterlace and re-interlace correct???
Bob-deinterlace to make the clip progressive for filtering.
Quote:
3. Degrain() - grain removal
Could be any filter, resizing, whatever. All processing should happen between TMCBob() and AssumeTFF()
Quote:
4. AssumeTTF() - once again the correct order
To make sure the field order we get from the next three lines is correct.
Quote:
5. SeparateFields() - once again separate the fields
6. SelectEvery(4,0,3) - select frames I don't know
7. Wave() - that means to SelectEven()
It's Weave Those three lines will reinterlace the clip. SelectEvery(4,0,3) keeps the field order, SelectEvery(4,1,2) would change it. So if there's AssumeTFF(), the output field order would be TFF.

Quote:
As far as I can understand it seems to me that I apply Degrain() to an
interlaced clip. I understand correct??? [/B]
Yes.
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 8th December 2004, 10:53   #7  |  Link
dplaton
Registered User
 
Join Date: Apr 2004
Location: Romania
Posts: 101
Thank you for your time.

What does Interleave(), I didn't understand.
Please say it in simple English.
I represented Interleave() as combining 2 fiels in one frame,
but that is not true.

Why I try to understand how to process interlaced clips?
I made some hours of deinterlaced home captures and it was
painfully slow 1fps (even the grass was clear).

Now I think that deinterlacing is not at all needed for my home
videos.
If the target is MPEG2 on a TV set or on a PC via DVDplayer interlaced is just fine.
If the target is MPEG4 just SeparateFields and everything is OK, even on my 950 MHz Duron.

The Doom9 guide tells how to deinterlace, once again for me I think I don't need, but says allmost nothing on how to treat interlaced video.

Once again thank you.
dplaton is offline   Reply With Quote
Old 8th December 2004, 11:05   #8  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,733
Quote:
Originally posted by dplaton
[B]Thank you for your time.

What does Interleave(), I didn't understand.
Please say it in simple English.
I represented Interleave() as combining 2 fiels in one frame,
but that is not true.
Interleave(a,b,c,...) (the Avisynth function) places frames of the clips a,b,c,.. so that they appear in the output video like this: a1,b1,c1,a2,b2,c2,a3,b3,c3 and so on. a1 means the first frame of clip a, b1 the first frame of clip b etc.
Quote:
Why I try to understand how to process interlaced clips?
I made some hours of deinterlaced home captures and it was
painfully slow 1fps (even the grass was clear).
Unfortunately I have to reveal that processing material as interlaced is even slower.
Quote:
If the target is MPEG2 on a TV set or on a PC via DVDplayer interlaced is just fine.
True.
Quote:
If the target is MPEG4 just SeparateFields and everything is OK, even on my 950 MHz Duron.
I would rather use KernelDeint() or TDeint() for deinterlacing.
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 8th December 2004, 11:20   #9  |  Link
dplaton
Registered User
 
Join Date: Apr 2004
Location: Romania
Posts: 101
My first attempts to process interlaced was quite simple

AsumeTTF() - frame order established via VirtualDub
SeparateFields()
Degrain()
resize
Wave() - without Interleave() the references for Interleave
were not clear to me.

The quality and speed were just fine.
I used Degrain() because I filmed on poor light conditions,
and Degrain() did a good job for me.
dplaton is offline   Reply With Quote
Old 8th December 2004, 11:44   #10  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,733
If you use SeparateFields and then use a temporal filter (or a spatio-temporal filter), you can mess things up easily as you are filtering the two scanlines from the same frame against each other. And that's a big no-no.

If you don't want to do a bob-then-reinterlace, I suggest you check stickboy's functions.

http://www.avisynth.org/stickboy/

What you are looking for are JDL_UnfoldFieldsVertical and JDL_FoldFieldsVertical.
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 8th December 2004, 11:50   #11  |  Link
dplaton
Registered User
 
Join Date: Apr 2004
Location: Romania
Posts: 101
Degrain() is just a spatial filter and this is why I used.
I think if I want to use a spatial filter I had to make 2 clips
from the original one, apply the temporal filter to each and after that
I have to recombine the 2 clips in just 1.
But is too complex for my knowledge.
dplaton is offline   Reply With Quote
Old 10th December 2004, 18:08   #12  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,733
You can use stickboy's JDL_UnFoldFields function to get the fields separate but displayed on the same frame. Then use JDL_FoldFields to get them back as they were.

JDL_UnFoldFieldsVertical(flip=true)
DeGrainMedian()
JDL_FoldFieldsVertical(flip=true)


Download this : http://www.avisynth.org/stickboy/jdl-interlace.avsi and save it to your Avisynth 2.5 plugins folder. By default it is C:\Program Files\Avisynth 2.5\plugins . That way it will be auto-loaded when needed. Then try that script, if you don't know what it does, comment out (by placing a # in front of the line you comment out) line by line and you'll see what happens. No need for separating fields, weaving etc.
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...

Last edited by Boulder; 10th December 2004 at 18:14.
Boulder is offline   Reply With Quote
Old 13th December 2004, 10:49   #13  |  Link
dplaton
Registered User
 
Join Date: Apr 2004
Location: Romania
Posts: 101
Thanks,

I allready see James D. Lin (stickboy) AVIS, but I didn't tested yet.
I found also a thread about spliting the RAW avi into 2 field avi to apply Dust(), and recombining the 2 avi into a interlaced file.
dplaton is offline   Reply With Quote
Old 15th December 2004, 23:14   #14  |  Link
cweb
Registered User
 
cweb's Avatar
 
Join Date: Oct 2002
Location: The Pandorica
Posts: 527
Quote:
Originally posted by Boulder
If you use SeparateFields and then use a temporal filter (or a spatio-temporal filter), you can mess things up easily as you are filtering the two scanlines from the same frame against each other. And that's a big no-no
Actually other posts in this forum (which I searched for) have said you can apply the same temporal filter to the two separated fields (selectodd and selecteven). I tried with pal DV and the result looks good. Does anyone have any other ideas pro/con temporal filtering in this kind of situation.
__________________
PC specs for bug reports: Intel Core i7-4790K @4Ghz Win10(Linux VM) PCI express NVIDIA RTX 2060 SUPER graphics card
http://twitter.com/cwebdesign
cweb is offline   Reply With Quote
Old 16th December 2004, 00:12   #15  |  Link
scharfis_brain
brainless
 
scharfis_brain's Avatar
 
Join Date: Mar 2003
Location: Germany
Posts: 3,653
the best solution for filtering interlaced video is this:


avisource("video.avi")
assume?ff() #set the correct fieldorder!
bob() # or use any other bobbing deinterlacer you like

#maybe with converttoyv12(interlaced=false), if needed
yourfilterchainhere()

converttoyuy2(interlaced=false)
assume?ff() #set the fieldorder again (the same as above!)
separatefields().selectevery(4,0,3).weave()
__________________
Don't forget the 'c'!

Don't PM me for technical support, please.
scharfis_brain is offline   Reply With Quote
Old 16th December 2004, 04:09   #16  |  Link
stickboy
AviSynth Enthusiast
 
Join Date: Jul 2002
Location: California, U.S.
Posts: 1,267
Quote:
Originally posted by cweb
Actually other posts in this forum (which I searched for) have said you can apply the same temporal filter to the two separated fields (selectodd and selecteven).
For purely temporal filters, you don't need to use SeparateFields at all, so SelectOdd and SelectEven aren't necessary.
stickboy is offline   Reply With Quote
Old 16th December 2004, 06:13   #17  |  Link
scharfis_brain
brainless
 
scharfis_brain's Avatar
 
Join Date: Mar 2003
Location: Germany
Posts: 3,653
separatefields().temporalfilter().weave()

results in vertical misalignement!

wich further leads to bobbing denoised static backgrounds on TV!

because of this I recommend my method.
__________________
Don't forget the 'c'!

Don't PM me for technical support, please.
scharfis_brain is offline   Reply With Quote
Old 16th December 2004, 08:47   #18  |  Link
dplaton
Registered User
 
Join Date: Apr 2004
Location: Romania
Posts: 101
Quote:
the best solution for filtering interlaced video is this:


avisource("video.avi")
assume?ff() #set the correct fieldorder!
bob() # or use any other bobbing deinterlacer you like

#maybe with converttoyv12(interlaced=false), if needed
yourfilterchainhere()

converttoyuy2(interlaced=false)
assume?ff() #set the fieldorder again (the same as above!)
separatefields().selectevery(4,0,3).weave()
Pease explain this script, as far as I understand>

1. bob()
Frame based interlaced material -> field material
frame 0 that consist in 2 fields -> frame 0 and 1 from each field

2. separatefields() ???

3. selectevery(4,0,3)

frames selected 0,3,4,7,8,11,12,15

Is that a correct understanding?

4. Wave()

Frames 0 and 3, 4 and 7, 8 and 11, 12 and 15 are combinated in
frame 0 1 2 3

I clearly don't understand
dplaton is offline   Reply With Quote
Old 16th December 2004, 11:44   #19  |  Link
stickboy
AviSynth Enthusiast
 
Join Date: Jul 2002
Location: California, U.S.
Posts: 1,267
Quote:
Originally posted by scharfis_brain
separatefields().temporalfilter().weave()

results in vertical misalignement!

wich further leads to bobbing denoised static backgrounds on TV!
Yes, exactly; that's why I said not to use SeparateFields...
Quote:
Originally posted by dplaton
Pease explain this script, as far as I understand
scharfis_brain's script bob-deinterlaces the clip, applies the filters, and finally interlaces it back.

So let's say your frames look like this:
Code:
A C E G I (field 0)
b d f h j (field 1)
(Each column represents a frame; time progresses going from left to right.) After the bob-deinterlace step, the frame count is doubled:
Code:
A  B' C  D' E  F' G  H' I  J' (field 0)
a' b  c' d  e' f  g' h  i' j  (field 1)
[Edit: Bob interpolates the missing scanlines to make progressive frames. a' represents scanlines that Bob interpolated from A.]

and you then filter.

After the SeparateFields step, it looks like (assuming TFF):
Code:
A a' B' b   C c' D' d   E e' F' f   G g' H' h   I i' J' j
and SelectEvery(4, 0, 3) selects the first and last frame of each group of four:
Code:
A b C d E f G h I j
and then Weave reconstructs frames from the separated fields:
Code:
A C E G I (field 0)
b d f h j (field 1)
which is what you started with, but which is now filtered.

[Edit: Tweaked the way I named the fields for clarity (hopefully).]

Last edited by stickboy; 16th December 2004 at 20:32.
stickboy is offline   Reply With Quote
Old 16th December 2004, 12:44   #20  |  Link
dplaton
Registered User
 
Join Date: Apr 2004
Location: Romania
Posts: 101
I belived that bob() transform a field based clip in a frame based clip that have as frame a single enlarged field.

Now I understand that bob() transform a field based clip with 2 different fields per frame in a field based clip with 2 identical
fields in a frame.

It is that right?
dplaton is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:54.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.