View Full Version : need script ideas and hints for "progressivizing" the StarTrek TNG PAL-DVDs
scharfis_brain
11th September 2004, 23:53
Let me explain what it is about with those TNG-DVDs.
they are build from the NTSC-Video, which mostly contains 3:2 Telecined films and some 30p and 60i effects (beaming, flying starships and sometimes slowered or accelerated telecined parts)
this Hybrid NTSC has been converted to PAL using IVTC and PAL-Speedup with a lousy Telecine-detection.
This means: the PAL-DVD contains:
normal, as it is the nature of such conversion, and well decimateable to pure 25fps
- progressive 25fps (as it should be generally the case)
- phase shifted progressive (no problem for telecide)
- 30p and 60i blended to 48i for further speedup to 50i (the above mentioned effect scenes)
but now prepare:
- sometimes FILM parts (24p) that had been blended in a way, that every other FIELD is a blend of its neighbors
this means, in a scene, there are either all odd fields good and all even fields blends or vice versa.
so a simple deinterlacing will yield to a stuttering result, cause the blending weights are alternating all the time.
sometimes there is only every 4th field a blended one.
so, I cooked up an idea in my mind to work against the "now prepare" part.
it is like follows:
- TELECIDE the video
- make an ISCOMBED check on that (combed frames remaining after telecide == blends present)
- now fieldseparate or bob the unprocessed video and build an edgemask for blend detection and calculate the averageluma of that edgemasked field (bobbed frame).
- then compare at least 4 even to 4 odd edgmasked-averagelumaed fields to decide whether the odd field is the clean one, or the even field is the clean one.
everything is no problem to script, exept the last step of comparing 8 lumas in avisynth to decide the outputted correct fields...
if this part could be done, we would be able to build completely progressive TNG-backups in an automated way without exessive stutters...
MrBunny
12th September 2004, 06:16
Originally posted by scharfis_brain
This means: the PAL-DVD contains:
normal, as it is the nature of such conversion, and well decimateable to pure 25fps
- progressive 25fps (as it should be generally the case)
- phase shifted progressive (no problem for telecide)
- 30p and 60i blended to 48i for further speedup to 50i (the above mentioned effect scenes)
One question that arises is how the 30p & 60i was blended into 48i before speedup and the quality of this conversion. I think this would be of interest to those of us that have been trying to do that ourselves with decomb on the NTSC DVDs. If this conversion is bad however, you'll be stuck with stuttering regardless of how well the film portions are reconstructed.
As for your proposed procedure, I can definately see it working however there would definately need to be a lot of tweaking of the various thresholds in the telecide and iscombed, much like the ones being done by us NTSCers. However, if that can be resolved, it sounds like a very good solution to the problem. I assume that the good fields are just the NTSC film frames with the appropriate PAL speedup?
scharfis_brain
12th September 2004, 10:55
- 30p and 60i blended to 48i for further speedup to 50i (the above mentioned effect scenes)
those ones will get detected as combed and then been simple deinterlaced, which results in a smooth 25p of the formerly 60i and a stuttery 25p of the formerly 30p. There is nothing I can do about the last issue.
btw. I had some creative hours this night. I've solved the problem detecting & removing those odd-only or even-only blends. but this method is painfully slow:
function repairPAL_TNG_DVD(clip i, bool "show")
{ # creating strings for analysing the video depending on the show-flag
show = default(show,true)
global h=i.intellibob()
global he = show ? " even" : ""
global ho = show ? " odd" : ""
tele = show ? " fieldmatched" : ""
auto = show ? " deblended" : ""
# create best possible deinterlaced image from blended source
h=i.intellibob(showmask=false)
# create analysis-clip for blend-detection
j=i.r24kernelbob()
# create edgemask of analysis-clip (stolen from restore24)
global k=logic(j.DEdgemask(0,255,0,255,"5 0 -5 10 0 -10 5 0 -5",setdivisor=true,divisor=6,y=3,u=1,v=1),
\ j.DEdgemask(0,255,0,255,"5 10 5 0 0 0 -5 -10 -5",setdivisor=true,divisor=6,y=3,u=1,v=1),"max",y=3,u=1,v=1)
\ .greyscale().levels(0,0.5,160,0,255,false).reduceby2()
# create some fwd & bwd clips. syntax:
# e=even | o=odd
# c=current | n=next | p=prev
global kec=k.selecteven()
global ken=kec.deleteframe(0)
global kep=kec.duplicateframe(0)
global koc=k.selectodd()
global kon=koc.deleteframe(0)
global kop=koc.duplicateframe(0)
# deblend the video
k1 = ScriptClip(blankclip(h.selectodd()), "(x>0) ? h.selectodd().subtitle(ho) : h.selecteven().subtitle(he)")
k2 = FrameEvaluate(k1, "x=(konl>kenl) ? x+1 : x-1")
k3 = Frameevaluate(k2, "x=(kocl>kenl) ? x+1 : x-1")
k4 = Frameevaluate(k3, "x=(kocl>kecl) ? x+1 : x-1")
k5 = FrameEvaluate(k4, "x=(kopl>kecl) ? x+1 : x-1")
k6 = Frameevaluate(k5, "x=(kopl>kepl) ? x+1 : x-1")
k7 = Frameevaluate(k6, "x=0")
k8 = FrameEvaluate(k7, "kopl=averageluma(kop)")
k9 = Frameevaluate(k8, "konl=averageluma(kon)")
k10 = Frameevaluate(k9, "kocl=averageluma(koc)")
k11 = FrameEvaluate(k10,"kepl=averageluma(kep)")
k12 = Frameevaluate(k11,"kenl=averageluma(ken)")
k13 = Frameevaluate(k12,"kecl=averageluma(kec)")
# try to telecide the video
tel=telecide(i,order=1,post=0)
tel0=tel.greyscale()
tel1=tel.subtitle(tele)
tel2=k13.subtitle(auto)
# if this fails (combing remains), then do fallback to deblend
conditionalfilter(tel0,tel1,tel2,"iscombed(8)","==","false")
}
import("d:\x\intellibob.avs")
loadplugin("d:\x\dgdecode.dll")
loadplugin("d:\x\tcombmask.dll")
loadplugin("d:\x\masktools.dll")
loadplugin("d:\x\kerneldeint140.dll")
loadplugin("d:\x\decomb511.dll")
i=mpeg2source("tng.d2v").assumetff()
repairPAL_TNG_DVD(i,show=true)
it runs fast on pure telecined (progressive & phase shifted progresse) but, gets ten times slower, if blending/remained combs are detected and corrected.
have fun!
and please report possible problems!
Didée
12th September 2004, 15:54
A question about PAL ST-TNG sources in general. Perhaps someone can answer this.
I haver never had my own hands on any "official" TNG DVD, but I have captured all episodes (except 2 :devil: ) by DVB.
Now, the material that was aired here in Germany was a 100% NTSC -->fieldblending--> PAL conversion, the usual crappy stuff (and not even the "intelligent" fieldblending like in the new ENT series, but the "dumb" blending whithout considering the repeated fields from NTSC).
I wonder, are there different PAL conversions out there? Because, from the material that scharfis_brain is describing, a fieldblended version cannot be created. This gives me the impression that the PAL DVD release was IVTC'ed (they tried, at least ;) ), and that for TV airing another, (even) less quality conversion was prepared.
?
scharfis_brain
12th September 2004, 16:08
TV-PAL-TNG = simple fieldblending : NTSC -> bobbing -> fpsconversion -> reinterlacing -> PAL
DVD-PAL-TNG: partial IVTC then slowPAL transfer.
this means, 3:2 patterns are getting IVTCed and non 3:2 pattern are getting blended to 48 fps interlaced.
but this semi intelligent conversion method, called DEFT (digital electronic film transfer), fails matching the 3:2 pattern after 30p or 60i scenes or if the movement was too low.
so it blends the 3:2 pattern into 48i, which jields to this pattern:
G - good field
B - hard blended fields (50:50)
b - soft blended fields (20:80)
G b G B G b G B G b G B G b .....
as you can see, every other field is clean and every other + 1 field ist blended
and these blended fields are alternating their blending weights from even (odd) to even (odd) field.
this is really weird stuff.
@Didée: please try repairTNG_PAL_DVD() on your enterprise scenes/episodes, which fail with r24.
my method is based on a three-frames (six fields) patternguidance. maybe it is worth being build into r24 ?!?
EDIT
the usual crappy stuff (and not even the "intelligent" fieldblending like in the new ENT series, but the "dumb" blending whithout considering the repeated fields from NTSC).
I did not see any difference between the blending patterns of ET & TNG.
so what do you mean?
Didée
12th September 2004, 23:06
I mean, if you take an IVTC'ed stream and do a "linear" blending without caring or looking for IVTC-repeated fields, then you'll end up with some blends of (top[n] + top[n+2]) fields.
Only if the converter is either looking for or knows about IVTC-repeats (or if it's fed with 23.976fps directly), the blended output will be "clean", where only direct field neighbors are blended.
I'm sure to have seen those "blendings with too far away" in that stuff that Kabel1 dares to put on digital air. It's also common in a lot of screwed animee stuff, from what I've seen so far.
scharfis_brain
13th September 2004, 06:11
you'll end up with some blends of (top[n] + top[n+2]) fields.
???
I've never seen SUCH a blending.
even the stupid
bob().convertfps(50).reinterlace()
method cannot blend more than two neighboring fields (one top & one bottom) together. So it is impossible to blend two top or two bottoms fields together with this method.
maybe you had got a TNG-episode that had been strongly denoised AFTER the standards conversion? like boulders sample?
Didée
13th September 2004, 09:00
scharfi, some time ago you've made a scriptlet that produces fieldblended 25fps output from progressive 24fps input by first doing telecineing, and then producing the fieldblend-decimating.
Did you ever feed that script with a ShowFrameNumber(true)'ed input?
edit: Oh :o ... I must have made something wrong back at that time. Shame on me. Indeed it works like it's supposed, and I'm an idiot ... no: interlacing impaired.
scharfis_brain
13th September 2004, 16:19
LOL :)
so we can agree, that the pattern is the same in TNG & ET?
(at least for the TV-transmissions)
Mug Funky
13th September 2004, 16:40
are there any sizeable samples of TNG available? i'd like to see how terrible they look (haven't trekked it up for years, and back when i watched the show i wasn't exactly looking for video problems).
the only field blends i see are from animes, really
Didée
13th September 2004, 17:02
scharfi:
Probably yes, although I cannot check that thoroughly right now (lack of samples, and mood as well). The fishy appearance of Kabel1's material indeed could be caused by too strong filtering.
Mug Funky:
With a little luck, I've still such a DVB snipplet somewhere on my HD's - else I'll catch another one today (if I return home early enough). Be prepared for big crap ;)
scharfis_brain
13th September 2004, 17:35
I've the DVD-Version of Episode 01x08 (Das Gesetz der Edo = Justice) on my HDD.
maybe Didée can provide DVB-sample of exact this episode?!?
(preferable the scene after the TNG-intro)
so we can do an exact comparision between the TV (stupid blending) & DVD (DEFT PALspeedup)
Didée
14th September 2004, 10:16
No I can't, scharfi. Back when I capped TNG, I was on analog capture, and Restore24 didn't exist yet. I blended the crap down to iirc 480*352, compressed to 200MB in XviD, and hided the poor resul in the darkest corner of the cellar ...
Here come some DVB samples of the TNG episode 6x03 "Man Of The People" ("Der unmoralische Friedensvermittler"), aired (satellited?) by the German TV station "Kabel1".
For some reason I currently cannot connect to my "gift" ftp directory, so I'll put them temporarily on my company's server. Please be a little sparing with downloading - if I can get on the other server again, these links will be edited.
sample1 **link removed**
sample2 **link removed**
sample3 **link removed**
Bad enough, isn't it?
But I wish I still had samples from season 1. There, moving objects left 12-frames-long trails behind them ...
For me, all this has to be seen in connection with the fact that digital TV transmission always gets advertised to the average joe user by praising the "crystal clear picture quality" beyond heaven ... ROTFLOL. No, halt. It's not for laughing. It's for crying.
scharfis_brain
14th September 2004, 16:21
For me, all this has to be seen in connection with the fact that digital TV transmission always gets advertised to the average joe user by praising the "crystal clear picture quality" beyond heaven ... ROTFLOL. No, halt. It's not for laughing. It's for crying.
that's why I always say: keep your analogue sattellite receiver as long as analogue TV is aired.
for recording DVB may be a very comfortable solution (no encoding needed in some [most ?!?] cases)
but for simple TV-viewing I would stick for the simple analogue TV.
scharfis_brain
19th August 2005, 15:51
This is my little attemt to re-progressivize the interlaced scenes of DEFT-Conversions.
function repairPAL_TNG_DVD(clip i, bool "show")
{
ord = getparity(i) ? 1 : 0
show = default(show,true)
global h=i.leakkernelbob(order=ord,threshold=5)
global he = show ? " even " : ""
global ho = show ? " odd " : ""
tele = show ? " fieldmatched" : ""
auto = show ? " deblended" : ""
# create analysis-clip for blend-detection
j=h.reduceby2()
# create edgemask of analysis-clip
global k=logic(j.DEdgemask(0,255,0,255,"5 0 -5 10 0 -10 5 0 -5",setdivisor=true,divisor=6,y=3,u=1,v=1),
\ j.DEdgemask(0,255,0,255,"5 10 5 0 0 0 -5 -10 -5",setdivisor=true,divisor=6,y=3,u=1,v=1),"max",y=3,u=1,v=1)
\ .greyscale().levels(0,0.5,160,0,255,false).bicubicresize(80,80)
# create some fwd & bwd clips. syntax:
# e=even | o=odd
# c=current | n=next | p=prev
# nn=next+1 | pp=prev-1
global kec=k.selecteven()
global ken=kec.deleteframe(0)
global kenn=kec.deleteframe(0).deleteframe(0)
global kep=kec.duplicateframe(0)
global kepp=kec.duplicateframe(0).duplicateframe(0)
global koc=k.selectodd()
global kon=koc.deleteframe(0)
global konn=koc.deleteframe(0).deleteframe(0)
global kop=koc.duplicateframe(0)
global kopp=koc.duplicateframe(0).duplicateframe(0)
global ko=h.selectodd() #.subtitle(ho)
global ke=h.selecteven()#.subtitle(he)
global kb=ko.mergeluma(ke,0.5).mergechroma(ke,0.5)
global th=1.02
# deblend the video
#k0 = ScriptClip(blankclip(ko), "(x>0) ? ko.subtitle(string(x)) : (x<0) ? ke.subtitle(string(x)) : kb.subtitle(string(x))")
k0 = ScriptClip(blankclip(ko), "(x>0) ? ko : (x<0) ? ke : kb")
k1 = FrameEvaluate(k0, "")
k2 = FrameEvaluate(k1, "x=(konl /th > kenl ) ? x+1 : (kenl /th > konl ) ? x-1 : x")
k3 = Frameevaluate(k2, "x=(kocl /th > kenl ) ? x+1 : (kenl /th > kocl ) ? x-1 : x")
k4 = Frameevaluate(k3, "x=(kocl /th > kecl ) ? x+1 : (kecl /th > kocl ) ? x-1 : x")
k5 = FrameEvaluate(k4, "x=(kopl /th > kecl ) ? x+1 : (kecl /th > kopl ) ? x-1 : x")
k6 = Frameevaluate(k5, "x=(kopl /th > kepl ) ? x+1 : (kepl /th > kopl ) ? x-1 : x")
k7 = FrameEvaluate(k6, "x=(koppl/th > kepl ) ? x+1 : (kepl /th > koppl) ? x-1 : x")
k8 = Frameevaluate(k7, "x=(koppl/th > keppl) ? x+1 : (keppl/th > koppl) ? x-1 : x")
k9 = FrameEvaluate(k8, "x=(konl /th > kennl) ? x+1 : (kennl/th > konl ) ? x-1 : x")
k10= Frameevaluate(k9, "x=(konnl/th > kennl) ? x+1 : (kennl/th > konnl) ? x-1 : x")
k17 = Frameevaluate(k10, "x=0")
k18 = FrameEvaluate(k17, "kopl=averageluma(kop)")
k19 = Frameevaluate(k18, "konl=averageluma(kon)")
k20 = Frameevaluate(k19, "kocl=averageluma(koc)")
k21 = FrameEvaluate(k20,"kepl=averageluma(kep)")
k22 = Frameevaluate(k21,"kenl=averageluma(ken)")
k23 = Frameevaluate(k22,"kecl=averageluma(kec)")
k24 = Frameevaluate(k23,"kennl=averageluma(kenn)")
k25 = Frameevaluate(k24,"keppl=averageluma(kepp)")
k26 = Frameevaluate(k25,"konnl=averageluma(konn)")
k27 = Frameevaluate(k26,"koppl=averageluma(kopp)")
result=k27
# try to telecide the video
tel=telecide(i,order=1,post=0)
tel0=tel.greyscale()
tel1=tel #.subtitle(tele)
tel2=result#.subtitle(" deblend")
flag1=blankclip(tel)
flag2=flag1.invert()
# if this fails (combing remains), then do fallback to deblend
flag=conditionalfilter(tel0,flag1,flag2,"iscombed(7)","==","false").crop(0,0,64,64)
flaga=flag.temporalsoften(2,255,255)
conditionalfilter(flaga,tel1,tel2,"averageluma()","<","62")
#conditionalfilter(flaga,last,last.subtitle("o"),"averageluma()","<","62")
}
Mug Funky
20th August 2005, 05:08
one suggestion: you can replace the chained deleteframe()'s with "selectevery(1,0-offset)" and save a little text space.
btw, i'm very interested in this project - i've been trying to emulate the DEFT conversions you're referring to so i can apply it to uncompressed anime captures. except i want to get it right, so a simple motion-adaptive deinterlace would be enough to get the PAL version looking beautiful for a progressive format like x264. not that i encourage people to make wanton copies of DVDs or anything... backup purposes only, guys ;). in fact, everyone should buy as much region-4 anime as they can afford :devil:
only problem is i just can't get my head around the 3:2 detection, in particular, how to handle the transition from film to 30p/60i (which will be blended to 48i, then sped up). how many frames need to be "buffered" so that film detection doesn't get thrown off? how will this affect 30p/60i stuff?
it's hard to handle those concepts when also trying to fit it all in the rather counter-intuitive conditional-filtering environment...
well, for now anime is going to keep getting blended, which isn't so bad. the standards-converter here at least gives good material for Cdeblend/restore24 to work on.
scharfis_brain
20th August 2005, 09:21
so a simple motion-adaptive deinterlace would be enough to get the PAL version looking beautiful for a progressive format like x264.
That doesn't work always with DEFT-converted stuff.
Because there are a lot of scenes that are 3:2 but been blended to PAL.
this results in this pattern:
A A ab B C C cd D E E ef F G G gh H
deinterlacing will produce this:
A ab C cd E ef G gh
blended and jerky mess.
Roscoe62
21st August 2005, 22:16
scharfis_brain,
I'm still a little unsure as to how to apply your script. I admit I am a bit of a newbie, but currently use an avs script. Do you run your script in addition to a normal XVid creation script, prior to running the XVid creation script, instead of?
Just a tiny bit more info would be really helpful!
PS - FWIW - STTNG - Justice is also the "problematic episode" I use!
Thanks again.
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.