View Full Version : How to gather 2 top fields then 2 bottom fields ?


Music Fan
19th August 2014, 14:18
Hi,
I'd like to see how does look a video in which each frame consists of 2 top fields or 2 bottom fields, and not of a top and a bottom field as usual.
I guess the first step with avisynth consists to separate fields, but then I don't know.
The idea is to gather fields 1 and 3 (while they come from 2 successive frames) then 2 and 4, 5 and 7, 6 and 8, ...
weave() is not good for that because it gathers 1 and 2, 3 and 4, ...

Wilbert
19th August 2014, 14:44
You need SeparateFields, apply SelectEven/SelectOdd on the separated fields and Weave again.

Music Fan
19th August 2014, 14:50
You need SeparateFields, apply SelectEven/SelectOdd on the separated fields and Weave again.
Thanks, how exactly do I have to apply SelectEven/SelectOdd ?
One then the other, like this ?
SeparateFields()
SelectEven()
SelectOdd()
Weave()

Music Fan
19th August 2014, 15:38
Actually no (I answer my own question), if one put SelectOdd() after SelectEven(), the total frames number is divided by 2 (it lacks a frame on two).
But after a few tests, I believe I found how to reach my goal ;
SeparateFields()
A=SelectEven().Weave()
B=SelectOdd().Weave()
Interleave(A, B)
:)

I first tried this ;
SeparateFields()
A=SelectEven()
B=SelectOdd()
Interleave(A, B)
but it seems to correspond to this ;
SeparateFields()
Weave()

Gavino
19th August 2014, 15:52
I first tried this ;
SeparateFields()
A=SelectEven()
B=SelectOdd()
Interleave(A, B)
but it seems to correspond to this ;
SeparateFields()
Weave()
No, it corresponds to just SeparateFields() on its own, because
A=SelectEven()
B=SelectOdd()
Interleave(A, B)
effectively does nothing. (It divides the clip into two then simply puts it back together again.)

Music Fan
19th August 2014, 16:17
Right, I confounded some tests I made, I should have seen this before to write it.;)

edit : I believe I meant that ;
A=SelectEven()
B=SelectOdd()
Interleave(A, B)
corresponds to ;
SeparateFields()
Weave()

videoh
19th August 2014, 16:45
It's a stretch to say they correspond, beyond the fact that they both do nothing. One creates two clips and the other doesn't.

feisty2
19th August 2014, 17:30
you might need separaterows and weaverows functions

Music Fan
19th August 2014, 17:47
you might need separaterows and weaverows functions
What's the difference compared to the script I gave ?

StainlessS
19th August 2014, 18:14
Does this work ?


mpeg2source("d:\vob\XMEN2.d2v")

SeparateFields
E=SelectEven.AssumeFrameBased.SeparateFields
E_A=E.SelectEven
E_B=E.SelectOdd

O=SelectOdd.AssumeFrameBased.SeparateFields
O_A=O.SelectEven
O_B=O.SelectOdd

Interleave(E_A,O_A,E_B,O_B)
Weave
AssumeFieldBased
Weave


EDIT: I may have misunderstood requirement, above intended to have 2 top fields, then two bottom repeated.

Wilbert
19th August 2014, 23:25
Something like the above should work. Shorter would be:

c = mpeg2source("d:\vob\XMEN2.d2v")
f = c.SeparateFields().AssumeFrameBased() #t1b1t2b2t3b3... #not sure whether AssumeFrameBased() is necessary
f.SelectEvery(4,0,2,1,3) #t1t2b1b2 t3t4b3b4 ...
AssumeFieldBased()
Weave()

wonkey_monkey
19th August 2014, 23:47
Did you miss a weave() at the end there, Wilbert?

Annoyingly that script is exactly what I was going to suggest, but didn't want to look foolish if it turned out I'd got it wrong ;)

Wilbert
20th August 2014, 00:46
Did you miss a weave() at the end there, Wilbert?
Yes doctor ;) Thx. I corrected it above.

Music Fan
20th August 2014, 00:51
Same question than above, what's the difference between this script and mine for the output ?
I post it here again ;

SeparateFields()
A=SelectEven().Weave()
B=SelectOdd().Weave()
Interleave(A, B)

Wilbert
20th August 2014, 00:55
I think they are the same.

Music Fan
20th August 2014, 01:57
Ok.
There is something strange in Virtual Dub with my script : the duration is divided by 4 compared to the original video while the framerate and the number of frames of my script are identical to those of the original video.:confused:

edit : that's an error, actually the duration is the same but I realize that ffvideosource does not detect the good framerate, thus I have to add assumefps(25/1), which I did in my main script but not in my first script containing only one line (ffvideosource ...).
The source is a TS file containing mpeg-2 in 720.576, ffvideosource has maybe a problem with ts files.
If I don't add assumefps(25/1), the detected framerate is 5.89 fps.:scared:

bxyhxyh
20th August 2014, 14:30
It seems you found the answer. But you can try this
SeparateRows(4)
SelectEvery(4,0,2,1,3)
WeaveRows(4)

Music Fan
21st August 2014, 14:20
It seems you found the answer. But you can try this
SeparateRows(4)
SelectEvery(4,0,2,1,3)
WeaveRows(4)
The result is very different than my script which makes the video shake, not yours.
And the frame number differs in 1 case ; if I i add trim(100,0) (= from 100 to end) in both scripts, I get 6832 frames with mine, 6831 with yours.:confused:
But if I add trim(100,199), they both get 100 frames.
If I don't use trim, they both get 6931 frames.

But this is a ts file recorded on tv, I should try with another file.

Music Fan
22nd August 2014, 11:43
@ bxyhxyh ;
I tested with another file, there is clearly a problem with your script which seems to blend fields, not mine.
You can see it by adding SeparateFields() at the end of the script.

Music Fan
22nd August 2014, 12:28
Here is an interesting exercise, begin the script with this to see big numbers on an interlaced video, you don't even need video, thanks to BlankClip function ;
BlankClip(length=100, width=720, height=576, fps=25, color=$000000)
ShowFrameNumber(size=400)
separatefields()
selectevery(4,0,3)
weave()
This way, each field has its number.

Then add bxyhxyh's script, then mine, add SeparateFields() at the end, forward frame by frame in Virtual Dub and see what happens ;)

Here are the complete scripts ;
BlankClip(length=100, width=720, height=576, fps=25, color=$000000)
ShowFrameNumber(size=400)
separatefields()
selectevery(4,0,3)
weave()
SeparateFields()
A=SelectEven().Weave()
B=SelectOdd().Weave()
Interleave(A, B)
SeparateFields()


BlankClip(length=100, width=720, height=576, fps=25, color=$000000)
ShowFrameNumber(size=400)
separatefields()
selectevery(4,0,3)
weave()
SeparateRows(4)
SelectEvery(4,0,2,1,3)
WeaveRows(4)
SeparateFields()

bxyhxyh
22nd August 2014, 15:50
Oh, I thought 2 field means you needed 0th and 2nd fields as top field and 1st and 3rd fields as bottom field from one frame. Not 1 from one frame and 1 from another one.

So a script I gave you would be like that which isn't you wanted.