Log in

View Full Version : Recovering blended frames (fields).


waka
28th April 2003, 13:03
I've come across some stuff that appears to be 25fps that was brought up to 30 by blending. Original frames A B C D E became A B B/C C/D D/E E. Actually its on a field level and the offsets are different but you get the idea. Now since we know one part of the frames B/C and D/E we should be able to get C and D by removing some portion of B and E from those frames. I tried this awhile ago with levels and layer, but it didn't work out too well. Trying it again with coloryuv and layer I was able to get fairly decent results.


function removeblend(clip clip, float str, int order)
{
base=trim(clip,(abs(order)-order)/2,0)
subt=trim(clip,(abs(order)+order)/2,0)
lstr=round(256*float(str)/(str+100))
cstr=((256/(1-2*(float(str)/(str+100))))-256)
ostr=round((cstr+256)/256)

layer(base,subt,"subtract",lstr)
coloryuv(cont_y=cstr,cont_u=cstr,cont_v=cstr)
coloryuv(off_y=ostr,off_u=ostr,off_v=ostr)
}

Order controls which frame is removed from the blended frame, -1 for the previous and 1 for the following. Str is the percentage of the known frame in the blend.

Before (http://mywebpages.comcast.net/jczimmerman/source.avi) and after (http://mywebpages.comcast.net/jczimmerman/25fps.avi) mjpegs using the following script:

src=source("source.avi")
srce=src.separatefields().selecteven()
srco=src.separatefields().selectodd()

newe1=interleave(srce,srce.removeblend(20,-1),
\srce.removeblend(40,1)).selectevery(18,0,3,6,7,17)
newe2=interleave(srce,srce.removeblend(35,-1),
\srce.removeblend(20,1)).selectevery(18,2,3,6,9,10)
newe=newe1.trim(2,23)+newe2.trim(24,0)
newo=interleave(srco,srco.removeblend(20,-1),
\srco.removeblend(20,1)).selectevery(18,8,9,12,15,16)

interleave(newe,newo).weave()

Pay no attention to source() its just a function I made to take care of some apparent mjpeg problems.

Since it is essentially amplifying a weak signal, there is a marked increase of noise in four of every five frames. This is mitigated somewhat because each frame only has one noiser field. It's still rather noticable, especially with a high str. So any ideas on how to improve this? Also the coloryuv offsets seem to be needed, but I have no idea why?

At this point I think I prefer telecide and decimate, but I found this interesting in a proof of concept sorta way and perhaps useful for those extra special clips.

WarpEnterprises
29th April 2003, 20:56
Accidentally I made a filter last week that does something quite similar:
It checks if a field is a blend between its neighbours and if YES returns the closest neighbour.

DeBlend(noise threshold, blend percentage threshold, show debug)

Example:

SeperateFields
DeBlend (10, 3.0, false)
Weave

Only YUY2, AviSynth 2.0x.

The calculated values are outputted via DebugView.

First you set show=true, then set the noise threshold as high that the background noise vanishes.
Then go to a blended field and check which "blend percentage" is calculated (values >0 should mark blended fields, <0 are considered not blended) and set the blend percentage threshold lower than this.
Then set show=false and watch the result.

(attachement removed)

WarpEnterprises
1st May 2003, 23:17
As there was a bug in the former version I attach a new one.

scharfis_brain
1st May 2003, 23:25
I am living in a PAL-country and we have lots of problems with standard converted series.

Those are mostly converted from 24p to 30i (telecine) and then via fieldblending to 25i (PAL).
The most know examples are "StarTrek TNG, DS9, VOY" or "The X-Files".

Is there a possibility to recover the 24 progressive frames/sec out of the 50 (partially blended) fields/sec ?

waka
2nd May 2003, 06:12
I would guess some but not all. Looking at an individual field for simplicity, 24 telecined to 30 gives a duplicate pair every 5 frames. Assuming they just blend two frames together to form one, at some point one of those two blended will belong to the duplicate pair. When this is the case, you have the other frame from the pair in "good" condition and can subtract that from the blend to reproduce the unknown frame.

I don't if this would happen often enough to justify the time spent in figuring out sequences and setting it up properly. You can check fairly easily by looking at one of the fields in a high motion scene and seeing if some portion of the blend is identical to either the preceding or following frame.

Any 30fps portions, such as special effects sometimes, couldn't be recovered. Anime should fair better as that often has lots of duplicates since it's actually 12fps or whatever.