Log in

View Full Version : Source underlying framerate - Conversion


Dogway
8th December 2011, 11:30
hello, here I have a funny source I think I solved but output framerate comes to be a bit strange.

You better download the sample to understand, but I explain:

source is interlaced NTSC, but only every other frame is a new frame, that is in fields: ab,ab,cd,cd...
-so select odds: ab,cd,ef...

-then bob and get NTSC 29.970 fps output with no dups. BUT, every 2 frames there is a bigger jump, just if the next had happened: ab,cd,gh,ij,mn...

-so I frame interpolate those missing frames, and I get 44.955fps. What kind of framerate this is? It's not even near any standard...
# NTSC 30fps source

selectodd # to 15fps

bob # back to 30fps

InterFrame(Preset="Placebo",Tuning="Film",NewNum=60000,NewDen=1001,...) # to 60fps

selectevery(4,2,3,4) # To 45 fps. Skip the no-gaps interpolated frames.

Sample 60Mb (sorry there is little motion to catch):
http://www.mediafire.com/?722eb33nz5c3c6t

Didée
8th December 2011, 12:35
It are interlaced frames that are missing (dup-replaced) in the source file. Therefore in the gaps there are 2 fields missing, hence you need to fill in 2 frames after bobbing.


ab cd ef gh ij kl mn op # (1) interlaced original

ab ab ef ef ij ij mn mn # (2) oddframes dropped, evenframes doubled

A B x x E F x x I J x x M N x x # (3) this is needed, but can't be constructed directly

A . . B x x E . . F x x I . . J x x M . . N x x # construct this (2 newframes for each),
0 1 2 3 4 5 0 1 2 3 4 5 0 1 2 3 4 5 0 1 2 3 4 5 # then select


With (2) being the source you're starting with.


# NTSC 30fps source

selectodd # to 15fps

bob # back to 30fps

assumefps(30)
InterFrame(Preset="Placebo",Tuning="Film",NewNum=90,NewDen=1,...) # tripling to 90fps

SelectEvery(6,0,3,4,5)
AssumeFPS(60000,1001) # now have reconstucted 60p.

No guarantee this works directly (cannot try now with your sample), but you see the principle.

Dogway
8th December 2011, 17:26
ah, yes. I was thinking source was originally 29.97, hence assuming that type of interlacing where you discard half the dups. But seems it originally was 60fps, so 2 frames to add. It didn't look so a big gap to fill.

In this case Interframe doesn't work because it tries to even the temporal difference touching correct frames: A,B,E,F etc

So I used mflowfps, I ended up with this script, just left bob to be replaced. I added the variable "b" because the source is composed of numerous trims, so it was going to be a pain to manual edit each of those, I just wonder if I'm gonna have a problem if I go out of range like selectevery(2,1,2)

### Deblock
SeparateFields()
Deblock_QED(quant1=20, quant2=30)


### Averaging repeated fields
b=0
e=mt_average(selectevery(4,b),selectevery(4,b+2),u=3,v=3)
o=mt_average(selectevery(4,b+1),selectevery(4,b+3),u=3,v=3)


### Remove Dups
interleave(e,o) # fields...
weave # 15fps (interlaced)
bob # back to 30fps. Working in frames now.
assumefps(30)


### Frame interpolation
super = MSuper(pel=2)
backward_vec = MAnalyse(super, overlap=4, isb = true, search=3)
forward_vec = MAnalyse(super, overlap=4, isb = false, search=3)
MFlowFps(super, backward_vec, forward_vec, num=90,den=1)


### Back to source framerate
SelectEvery(6,b,b+3,b+4,b+5)
AssumeFPS(60000,1001)

I also discovered FillDropsI() (http://forum.doom9.org/showthread.php?p=1493082#post1493082)while searching, I thought it was going to work as per description, but it didn't : /

poisondeathray
8th December 2011, 18:21
Are you trying to interpolate to 59.94p then re-interlace for NTSC?


a = MPEG2Source


###ODD FIELDS INTERPOLATION using "FILLDROPS"
a
AssumeTFF()
SeparateFields()
SelectOdd()
odd = last
super_odd=MSuper(odd,pel=2)
vfo=manalyse(super_odd,truemotion=true,isb=false, delta=1)
vbo=manalyse(super_odd,truemotion=true,isb=true,delta=1)
filldrops_o = mflowinter(odd,super_odd,vbo,vfo,time=50)

ConditionalFilter(odd, filldrops_o, odd, "YDifferenceFromPrevious()", "lessthan", "1.3")

odd_filtered=last


odd_filtered
bob #interpolated 29.97p now


###MFlowFPS for 2x framerate (or use interframe instead)
source=last

super = source.MSuper(pel=2)
backward_vec = MAnalyse(super, overlap=4, isb = true, search=3)
forward_vec = MAnalyse(super, overlap=4, isb = false, search=3)
source.MFlowFps(super, backward_vec, forward_vec, blend=false, num=60000, den=1001)

#59.94p now, reinterlace if necessary

Dogway
8th December 2011, 23:27
I think I finally got it. I can use variable "b" for the averaging of fields, and another variable "c" for the last selectevery offset, on debug test I try several incremental numbers until I find what I like for each, and based on the this number I manual input the correct offset inside the selectevery range as closest to zero as possible, to avoid some misalignments at the trim extremes.

I also had to fix chroma:
interleave(mergechroma(selectevery(4,0),selectevery(4,-2)),selectevery(4,1),selectevery(4,2),selectevery(4,3))

@poisondeathray: I wanted to recover the original framerate with progressive output. Actually Didée explained it very well on his first CODE box. The source is like if it was 60fps but with dupped frames, hence the output has 60fps resolution pair of frames, and 20fps resolution pair of frames, producing a gap. So I'm just filling those holes, there's no need for dup detection since it's constant all over the footage. But I'll keep the function just in case.

Thanks to both for the help, now just left some dozen trims and adjustments, and the anime insertions which is another story : )