Posts for Sp00kyFox

Experienced Forum User
Joined: 8/3/2012
Posts: 10
yeah, if I remember correctly youtube also had problems to decode x264-10bit encoded videos. yip, keeping it at 8bit and yuv420 for yt is the safe way to go.
Experienced Forum User
Joined: 8/3/2012
Posts: 10
just wanted to give some feedback. after I solved the issue with the color conversion (see a few posts back), I checked if i444 is indeed more efficient than i420. well visually and metric wise it is at the same bitrate. I kinda thought that with pixel art the encoder has more freedom to make errors at 2xPoint, where at the original resolution every small error is a big issue. but that's not the case and of course the encoding is way faster. well maybe it was obvious but now I know it for sure!
Experienced Forum User
Joined: 8/3/2012
Posts: 10
ok now we know how to reverse the process. the actual pixel blendings in the yv12 seems to be based on how the croma plane is upscaled. so yeah, it's an application dependent thing. from the look of it virtualdub seems to use bilinear/bicubic for the chroma plane which I thought was an error in my color conversion.
Experienced Forum User
Joined: 8/3/2012
Posts: 10
yeah I also found this thread in my search, this script only makes sense in the case of converting back to yv24. thanks for the help though. I started a thread on doom9 regarding this issue, let's see what the veterans have to say about this: http://forum.doom9.org/showthread.php?p=1681752
Experienced Forum User
Joined: 8/3/2012
Posts: 10
well this really confuses me. also tried the chromainplacement argument in the converttorgb32 function. well it gives different results but not one of them is correct. here is a little sample, maye a problem with the source? https://anonfiles.com/file/4826998bd17c2a89f0b1c44cbcaea109 (msu screen capture lossless codec) edit: I did nothing more than the script I posted. I only magnified a specific part of the screenshot to make the difference more viewable. edit2: avisynth version is 2.6.0.
Experienced Forum User
Joined: 8/3/2012
Posts: 10
with virtualdub (v1.10.4). adding your suggested line makes it actually worse: https://imgur.com/a/PnGqt edit: already played around with the chromaoutplacement argument. no difference at all, what I guess is exactly one would expect if the input clip was 2x-pointresized.
Experienced Forum User
Joined: 8/3/2012
Posts: 10
can someone explain me what I'm doing wrong. just playing around with some encoding tests on my new system- I thought by doubling the resolution with pointresize and then converting it to yv12 the result should be colorwise the same as converting the original resolution to yv24. but in the result I can clearly see color mergings at pixel borders despite the chromaresample="point" argument. here is the script I used:
AviSource("sample.avi") #RGB clip
PointResize(2*last.width, 2*last.height)
ConvertToYV12(chromaresample="point", matrix="PC.601")
Experienced Forum User
Joined: 8/3/2012
Posts: 10
hi there. I'd love to help out with 10bit444 encodes of some older movies here. I found the encoding guide and pretty much know how to do the technical stuff. but where do I have to approve my custom logo and post the upload? all these different articles on the frontpage are a little bit confusing to be honest ;)
Experienced Forum User
Joined: 8/3/2012
Posts: 10
well I had the problem that I couldn't find many 1frame-shake scenes. it was often at least 2 frames (and these need no fixing). the flashes were easier to find. I had to selecteven() the source for some scenes to get 1frame-flashes/shakes for testing. 1frame-flashes: castlevania3 http://tasvideos.org/764M.html ~ 2:00 where the hero picks up the holy cross bionic comando http://tasvideos.org/1396M.html ~ 4:32 flashing sky ~ 12:32 ship boss super metroid http://tasvideos.org/1368M.html ~ 4:22 lightning behind samus ship ~ 33:42 mother brain boss part 1 (selecteven()) 1frame-shakes (probably have to lower the threshold value): contra3 http://tasvideos.org/787M.html ~ 1:21 destroying midstage boss (selecteven()) super metroid (same tas as above) ~ 3:18 escape intro ~ 32:25 disappearing boss statue (selecteven()) bionic commando (same tas as above) ~ 13:05 dialogue (selecteven()) just look at the masks. the deblinkmod function is not working properly for flashes/shakes in a row. well the shake detection script could probably be improved. if you imagine the 3 frames (b,c,f) as a triangle we only tested 2 edges. if we include the third edge (which is c-f) in the determination it could make it more accurate. suggestion (with corresponding variable names):
function sfx_shake2(clip clp, int "thr"){

   thr = default(thr, 0)
   src = clp.ConvertToYV12()
	
   super = MSuper(src, pel=1)
   fvec  = MAnalyse(super, isb=false, blksize=4)
   
   gmc  = MDepan(src, fvec)
   b1gmc = Depan(src, data=gmc, offset=1)
   b2gmc = Depan(src, data=gmc, offset=2)

   bcshake = mt_lutxy(src.selectevery(1,-1),b1gmc,expr="x y - abs 2 *").mt_binarize()
   cfshake = mt_lutxy(src.selectevery(1,1),b1gmc.selectevery(1,1),expr="x y - abs 2 *").mt_binarize()
   bfshake = mt_lutxy(src.selectevery(1,-1),b2gmc.selectevery(1,1),expr="x y - abs 2 *").mt_binarize()

   bcshkavg = mt_lutf(bcshake,bcshake,"avg",expr="x")
   cfshkavg = mt_lutf(cfshake,cfshake,"avg",expr="x")
   bfshkavg = mt_lutf(bfshake,bfshake,"avg",expr="x")

   minshk = mt_lutxy(bcshkavg,cfshkavg,expr="x y <= x y ?")
	
   mt_lutxy(minshk,bfshkavg,"x y -").mt_binarize(thr).GreyScale()
}
edit: noticed some luma issues with the masks and the yuv->rgb conversion. substituded tweak with greyscale function call. also fixed the other post.
Experienced Forum User
Joined: 8/3/2012
Posts: 10
hi nanogyth, since I'm interested in speedruns and also avisynth and video editing I've come to see this thread and your script. I must say, pretty amazing work there. But I noticed that the detection of shakes and global flashes is not working pretty well (well that's probably the reason you put it in test mode). I came up with a pretty good solution for this problem. basically it doesn't use the local motion (like you did with mmask) but the global motion compensation aka the camera pan or scrolling. here is the function for 1frame-flashes:
function sfx_flash(clip clp, int "thr"){
	
   thr = default(thr, 64)
   src = clp.ConvertToYV12()
	
   super = MSuper(src, pel=1)
   fvec  = MAnalyse(super, isb=false, blksize=4)
   
   gmc  = MDepan(src, fvec)
   fgmc = Depan(src, data=gmc, offset=-1)
   bgmc = Depan(src, data=gmc, offset=1)

   fflash = mt_lutxy(fgmc,src,expr="x y - abs 2 *").mt_binarize(thr)
   bflash = mt_lutxy(bgmc,src,expr="x y - abs 2 *").mt_binarize(thr)
   flash  = mt_logic(fflash,bflash,mode="and")

   mt_lutf(flash,flash,"avg",expr="x").mt_binarize(thr).GreyScale()
}
litte explanation: let's say (c)urrent is our reference frame, (f)orward and (b)ackward the neighbor frames and diff(x,y) the difference between frames x and y. we eliminate the scrolling effect (which distorts the difference calculation) by analyzing the global motion (with MDepan() and Depan()) and shifting the frame to the postion of the reference frame. the rest is simple: we move f and b with depan to the position of c. if c is a single frame flash then diff(c,f) and diff(c,b) is pretty big and we set the mask to 255. otherwise it's zero. the threshold maybe needs adjustment from game to game. and now the code for 1frame-shakes:
function sfx_shake(clip clp, int "thr"){

   thr = default(thr, 32)
   src = clp.ConvertToYV12()
	
   super = MSuper(src, pel=1)
   fvec  = MAnalyse(super, isb=false, blksize=4)
   
   gmc  = MDepan(src, fvec)
   b1gmc = Depan(src, data=gmc, offset=1)
   b2gmc = Depan(src, data=gmc, offset=2)

   b1shake = mt_lutxy(src.selectevery(1,-1),b1gmc,expr="x y - abs 2 *").mt_binarize()
   b2shake = mt_lutxy(src.selectevery(1,-1),b2gmc.selectevery(1,1),expr="x y - abs 2 *").mt_binarize()

   b1shkavg = mt_lutf(b1shake,b1shake,"avg",expr="x")
   b2shkavg = mt_lutf(b2shake,b2shake,"avg",expr="x")

   mt_lutxy(b1shkavg,b2shkavg,"x y -").mt_binarize(thr).GreyScale()
}
explanation: if c is a single frame flash then diff(b,c) should be greater than diff(b,f) otherwise the camera is standing still or we have normal motion. to compensate for the differences inside the actual frames we don't compare the given frames but again using the global motion analysis. we shift b to the position of c and compare to the original position of b. then we do the same with b and f. the rest is just building the differences and comparing the results. the problem I have now is that I don't really now how I use the information of these masks, especially when there are many flashes/shakes in a row. here is my code so far, which works good if the source only has single flashes/shakes. maybe you have some ideas (should've add parameters for the new threshold values):
function sfx_deblinkmod(clip clp,
\ float "ratio",
\ int "level",
\ clip "blinkmask"
\){

    deblink = ng_deblink(clp, ratio, level, blinkmask)
    
    sfx = mt_lutxy(sfx_flash(deblink),sfx_shake(deblink),"x y +").ConvertToRGB32()

    f0=Layer(deblink.SelectEvery(2,0),
\            deblink.SelectEvery(2,1).Mask(sfx.SelectEvery(2,1)),
\            level=257)
    f1=Layer(deblink.SelectEvery(2,1),
\            deblink.SelectEvery(2,0).Mask(sfx.SelectEvery(2,0)),
\            level=257)

    interleave(f0,f1)
}
you can easily add the 3 functions to your script and it should work. of course you can optimize the code by eliminating the additional msuper and manalyze calls. but this would have required a rewrite of a great part of your script which had made my changes incomprehensible. tested the script modification with castlevania3, super metroid, bionic commando and contra3.