Log in

View Full Version : 60fps progressive to 30fps interlaced


TCmullet
19th July 2011, 16:07
Am still pretty green so am stuck. Sorry I can't figure it out alone.

Have a clip 720x480 60fps (frames / sec) progressive. Need to convert to 720x480 30fps interlaced. Tried this:

avisource("MyClip.avi")
AssumeFieldBased
SelectEvery(2, 0,1)
weave

But it results in 720x960. Would someone kindly help correct me?

Chikuzen
19th July 2011, 16:14
AVISource("MyClip.avi")
#AssumeTFF()
SeparateFields()
SelectEvery(4, 0, 3)
Weave()

TCmullet
19th July 2011, 20:51
Thanks so much, Chikuzen!

I'm guessing it doesn't hurt to include AssumeFrameBased() at the top.

Uh, every time I revisit code I wrote 2 years ago, I struggle to re-figure it out. This is what I wrote, with great difficulty for home movie conversion to DVD:

# Take a 16fps progressive input clip and apply 3:4:4:4
* pulldown, yielding a 30fps interlaced output clip
AssumeFrameBased
SeparateFields
SelectEvery(16, 0,1,0, 3,2,3,2, 5,4,5,4, 7,6,7,6,\
9,8,9, 10,11,10,11, 12,13,12,13, 14,15,14,15)
Weave

It's not greatly helped by the AviSynth doc, which gives examples, but no explicit description of them. Concerning our present script:

AssumeFrameBased()
SeparateFields()
SelectEvery(4, 0, 3)
Weave()

...Is this what it means?
The "4" means, grab the next 4 fields (numbered 0, 1, 2 and 3), which were really from 2 original frames, and output 2 fields (1 frame) in their place. ("0, 3" is a list of 2 field numbers.) "0" is the 1st of the 4 fields (top field of the 1st of 2 frames), and "3" is the 4th of the 4 fields (bottom field of the 2nd of 2 frames).

Am I grasping it right??

My old notes cover 2:3 and 3:4:4:4. As I re-study them, the thing that's initially confusing is that each of these has to be done TWICE to work. "2:3" means the 1st source frame supplies fields toward "2" destination fields, and the 2nd source frame supplies fields toward "3 destination fields. But that would leave you with only 5 destination fields, an odd number. So we do "2:3" TWICE so that we have 10 fields, an even number. Therefore we write using an "8":
SelectEvery(8, 0,1, 2,3,2, 5,4, 7,6,7)
which means grab 8 fields and output them into 10 fields (5 frames) with no leftover field.

If this is all correct, maybe it will help somebody down the road who stumbles upon this thread.

Gavino
19th July 2011, 22:48
AssumeFrameBased()
SeparateFields()
SelectEvery(4, 0, 3)
Weave()

...Is this what it means?
The "4" means, grab the next 4 fields (numbered 0, 1, 2 and 3), which were really from 2 original frames, and output 2 fields (1 frame) in their place. ("0, 3" is a list of 2 field numbers.) "0" is the 1st of the 4 fields (top field of the 1st of 2 frames), and "3" is the 4th of the 4 fields (bottom field of the 2nd of 2 frames).

Am I grasping it right??
Essentially, yes, but with this script "0" is the bottom field of the 1st of 2 frames and "3" is the top field of the 2nd of 2 frames. This is because Avisynth defaults to BFF (bottom field first). If you want the top field first, you have to add AssumeTFF() before SeparateFields() (as suggested as an option in Chikuzen's script).

You don't normally need AssumeFrameBased as all normal source filters will set this already.
(It does not indicate whether the clip is progressive or interlaced.)

TCmullet
21st July 2011, 17:18
Thanks, Gavino.

I ran thru my whole 2-hr show without the AssumeTFF(), then encoded to Mpeg2. The TV showed intraframe jaggies. Then in frustration I went back to this forum intending to ask a question and saw your comment that I had missed. (Somehow my email notification hadn't worked.) Ahh, your comment was the explanation!

I've now done a SMALL test (15-sec clip) both ways, and adding TFF does get things right.

But I'm still puzzled. I thought I should be able to verify this with:

#AssumeTFF()
SeparateFields()
#SelectEvery(4, 0, 3)
#Weave()

In Vdub, I thought I should have seen the jaggies temporally by scrolling the timeline (you know, sometimes a forward motion goes backward a frame, then forward again). But I couldn't. Whether I did AssumeTFF or not, the 60fps result of SeparateFields() is smooth. Yet the final results were appropriately different (via watching the mpeg2 result on my TV). How can I visually test the correct field order by inspecting the SeparateFields() output? It would be nice to SEE the difference by manually scrolling along in Vdub rather than have to wait til after an Mpeg encoding to see if I got it right.

TCmullet
21st July 2011, 17:38
>> (Somehow my email notification hadn't worked.)

I discovered the email address I had in my profile was one I haven't check in about 4 years! I had 300+ emails there, mostly spam, but also the 2 notifications from here at the top. So the notification feature is working just fine. (And I've updated my address, embarassingly.)

:stupid:

Gavino
21st July 2011, 18:55
Whether I did AssumeTFF or not, the 60fps result of SeparateFields() is smooth. Yet the final results were appropriately different (via watching the mpeg2 result on my TV).
Since your input is progressive, the result of SeparateFields() will never show a backward jump, whether you use TFF or BFF. The two fields in each frame (top and bottom) correspond to the same moment in time.

The use of AssumeTFF or AssumeBFF in the script affects the field order of the final output (after Weave). The important thing is that what you tell your Mpeg2 encoder about the field order should match what the script produces.

TCmullet
21st July 2011, 19:14
If I've done it incorrectly (by leaving off the AssumeTFF), isn't there something I could temporarily add after the Weave that would help me see in Vdub (via scrolling the timeline) the judders? (I wrongly labelled 'em "jaggies" earlier.)

Gavino
21st July 2011, 19:57
Well, you could add another call to SeparateFields() after the Weave() (or just comment out the Weave instead) if you want to inspect the stream of fields produced by the script.

But again that won't show you anything wrong with the temporal order - it only becomes 'wrong' if your encoder thinks it's TFF when it's BFF, or vice versa.