Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 19th April 2021, 18:40   #41  |  Link
Frank62
Registered User
 
Join Date: Mar 2017
Location: Germany
Posts: 234
God luck.
Frank62 is offline   Reply With Quote
Old 19th April 2021, 20:24   #42  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,345
Quote:
Originally Posted by Atlantis View Post

poisondeathray's script works on all scene changes as I'm comparing and also has no wave effect. I first want to understand it so that I can use it correctly.
It is also deintelacing and it is using nnedi3, correct? I just don't understand why it is not giving that wave effect. nnedi3 alone shows the wave effect.


Yes, it's deinterlacing with bwdif+nnedi3 . A blend deinterlacing variation is applied by merging n, n+1 frames after double rate deinterlacing. It's analagous to blend deinterlacing with blending of top and bottom fields. bwdif+nnedi3 gives less aliasing or jaggy deinterlacing artifacts than fielddeinterlace - that was the reason for choosing it.

The wavy distortions are cancelled out because of the blend deinterlacing - same as fielddeinterlace

Blend deinterlacing in general is a "terrible" approach... But your source has this unique property that seems to cancel out when top and bottom field are combined (or n, n+1 frames when double rate deinterlaced)

Scene change blend frame from 2 scenes is detected with logic - if current frame is very different than next AND previous, then do "x" . Where "x" is replace with a single rate deinterlaced version - that "replaced" frame still has the original frequency distortion pattern (ie. the "wave" effect). But it's "less bad" than the blend frame from 2 scenes,and you only see it for 1 frame on blended scene changes

If you prefer to use a blended copy instead, you can replace it with a n+1 shifted version instead, but the total frame count will be increased by 1 . The timing should still be the same until the very end frame

Code:
deintblendplus = deintblend.loop(2,0,0)
ConditionalFilter(deintblend, deintblendplus, deintblend, "YDifferenceFromPrevious>19 && YDifferenceToNext>19")

I too would like to see defreq, or F1Quiver, or F2Quiver or similar script, because in theory they should give better results than "terrible" blend deinterlacing. The problem is finding the correct parameters...
poisondeathray is offline   Reply With Quote
Old 19th April 2021, 22:02   #43  |  Link
zorr
Registered User
 
Join Date: Mar 2018
Posts: 447
I think this problem can be attacked with Zopti. Since the blend deinterlaced frame doesn't have the moire pattern, that can work as the target. Do normal deinterlacing and apply DeFreq, compare with blend deinterlaced frame. Let Zopti find the optimal values for DeFreq.

I'd like to try this but seems the download link of the original video isn't working.
zorr is offline   Reply With Quote
Old 19th April 2021, 22:19   #44  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,345
Quote:
Originally Posted by zorr View Post
I think this problem can be attacked with Zopti. Since the blend deinterlaced frame doesn't have the moire pattern, that can work as the target. Do normal deinterlacing and apply DeFreq, compare with blend deinterlaced frame. Let Zopti find the optimal values for DeFreq.

I'd like to try this but seems the download link of the original video isn't working.
mirror of both clips
https://www.mediafire.com/file/7ewph...ifact.zip/file

Also maybe look at
http://www.avisynth.nl/users/vcmohan...r/F1Quiver.htm
http://www.avisynth.nl/users/vcmohan...r/F2Quiver.htm
poisondeathray is offline   Reply With Quote
Old 19th April 2021, 23:00   #45  |  Link
Frank62
Registered User
 
Join Date: Mar 2017
Location: Germany
Posts: 234
If anyone should try this with zopti:
If I interpret correctly what had been said in another thread about DeFreq by its author, you will have to turn the picture first by 45 degrees so that the moire lines will be vertical.
Frank62 is offline   Reply With Quote
Old 19th April 2021, 23:44   #46  |  Link
Atlantis
Registered User
 
Join Date: Feb 2002
Posts: 758
deintblendplus = deintblend.loop(2,0,0)
ConditionalFilter(deintblend, deintblendplus, deintblend, "YDifferenceFromPrevious>19 && YDifferenceToNext>19")

I tried that but the old version is better. This new one gives 2 consecutive frames before some scene changes that are exactly like each other. It's like 2 fixed frames copied. The old version gives a frame that is a little different, so it's smoother.
Atlantis is offline   Reply With Quote
Old 19th April 2021, 23:57   #47  |  Link
Atlantis
Registered User
 
Join Date: Feb 2002
Posts: 758
Some scene changes were still blended, so I had to reduce the threshold to 7.
ConditionalFilter(deintblend, deintblendhalf, deintblend, "YDifferenceFromPrevious>7 && YDifferenceToNext>7")

What happens if you go too low?
Atlantis is offline   Reply With Quote
Old 20th April 2021, 00:09   #48  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,345
Quote:
Originally Posted by Atlantis View Post
Some scene changes were still blended, so I had to reduce the threshold to 7.
ConditionalFilter(deintblend, deintblendhalf, deintblend, "YDifferenceFromPrevious>7 && YDifferenceToNext>7")

What happens if you go too low?
They get replaced by nonblended deinterlaced version. Artifact should be present in those replaced frames

You can use show=true to help identify which frames are replaced

ConditionalFilter(deintblend, deintblendhalf, deintblend, "YDifferenceFromPrevious>7 && YDifferenceToNext>7", show=true)


There might be better conditions to use, or other parameters that are more specific to identify that sceneblend frame
poisondeathray is offline   Reply With Quote
Old 20th April 2021, 00:13   #49  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,345
eg. StainlessS has a bunch of detection and utility scripts - it might be better to run a first pass scene detection script to get metrics , then replace those scene blend frames - just throwing out ideas
poisondeathray is offline   Reply With Quote
Old 20th April 2021, 14:48   #50  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
eg. StainlessS has a bunch of detection and utility scripts
OK, I finally got a bit of time to knock this up [need some kind soul to integrate into the deinterlace thingy].
This is just demo, detect on original clip only [pre deinterlace], I dont kow what that BWDif thing is,
if assistance needed I could mod to work with double rate.

here tis, Just displayed metrics, choose which [or combination] you prefer [I have not really tweaked LPD_Th, probably anything about 4 -> 16 might be OK].

Code:
AvisourcE("clip3.mkv.avi")
o=last
assumetff()

# Config
LPD_Th = 10  # RT_LumaPixelsDifferent(), if corresponding pixels more different than this then is counted

SSS="""
    n = current_frame
    YAE = RT_AverageLuma(n=n,y=0,interlaced=True)                           # AverageLuma Even scanlines [ie even field]
    YAO = RT_AverageLuma(n=n,y=1,interlaced=True)                           # AverageLuma Odd  scanlines [ie odd  field]
    YAD = Abs(YAE-YAO)                                                      # AverageLuma Difference of Even,Odd Scanline [Brightness Diff)
    YD  = RT_LumaDifference(Last,Last,n=n,y=0,n2=n,y2=1,interlaced=true)    # Average Per Pixel Diff betwwen Even and Odd fields
    YC  = RT_LumaCorrelation(Last,Last,n=n,y=0,n2=n,y2=1,interlaced=True)   # Correlation Between Even and Odd scanlines
    YDC = (1.0-YC)*255.0                                                    # Difference by Correlation
    YPD = RT_LumaPixelsDifferent(Last,Last,n=n,y=0,n2=n,y2=1,interlaced=true,Thresh=LPD_Th)
    RT_Subtitle("%d]\nYAD=%7.3f : { YAE=%7.3f : YAO=%7.3f }\nYD =%7.3f\nYDC=%7.3f\nYPD=%7.3f",n,YAD,YAE,YAO,YD,YDC,YPD)
"""
Scriptclip(SSS)
#StackHorizontal(o,Last)
Return last
__END__

/*
    RT_LumaPixelsDifferent(clip c,clip c2,int "n"=current_frame,int "delta"=0,int "x"=0,int "y"=0,int "w"=0,int "h"=0, \
        int "n2"=current_frame,int "delta2"=0,int "x2"=x,int"y2"=y,bool "interlaced"=false,            \
        int "matrix"=(Width>1100||Height>600?3:2),int "Thresh"=0)

    Compares clip c frame (n+delta) at x,y,w,h, and clip c2 frame (n2+delta2) at x2,y2,w,h, and returns amount of pixels
    whose pixel luma difference is greater than Thresh (RGB converted to Luma-Y using Matrix).
    Matrix 0=Rec601, 1=Rec709, 2=PC601, 3=PC709.
    If Interlaced=True, then skips every other raster line, eg process only y, y+2, y+4 etc.
    Thresh Default 0, returns number of pixels that are not exactly the same.
    Return value is in range 0.0 (meaning none) to 255.0 meaning 100% of pixels.
*/
Frame 103


Frame 104


Frame 105


EDIT: If making frames.txt command file whotsit, [for double rated result clip, and eg ClipClop replaceemnt]
n*2 = last of current scene, n*2+1 = scene change, when decided to be different

EDIT: Maybe, if 2 (or maybe 3) out of 4 say scene change then is scene change, ie a voting system.
[but you need vote threholds for each, eg Brightness_Diff_Vote = (YAD > BRIGHT_TH) and where eg BRIGHT_TH=20]

EDIT: YAD is probably a bit weak a detector compared to others, so maybe voting system 2 out of 3 and skip the YAD metric.
The other 3 metrics are difference per pixel, whereas YAD is difference of field average.
EDIT: Yeh, skip the YAD metric.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 20th April 2021 at 15:40.
StainlessS is offline   Reply With Quote
Old 20th April 2021, 16:26   #51  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Here, removed YAD (Brightness diff metric), and added frames file writing for singlerate, and doublerate even and doubrate odd scene change.

Voting thresholds not tweaked [I only got a single scene change clip].

Code:
Avisource("clip3.mkv.avi")
o=last
assumetff()

### Config ###
LPD_Th = 10  # RT_LumaPixelsDifferent() Threshold, if corresponding pixels more different than this then is counted
# Voting Thresholds, if above these then VOTE is counted
V_YD_TH  = 30.0
V_YCD_TH = 100.0
V_YPD_TH = 100.0
###
SUBS=True
WRITE=True
SFrames  = ".\SingleRate.txt"
DFramesE = ".\DoubleRateEven.txt"
DFramesO = ".\DoubleRateOdd.txt"
############################
############################
############################

if(WRITE) {
    RT_fileDelete(SFrames)
    RT_fileDelete(DFramesE)
    RT_fileDelete(DFramesO)
}

COUNT = 0 # COUNT valid only on forward ONLY scan
SSS="""
    n = current_frame
    YD  = RT_LumaDifference(Last,Last,n=n,y=0,n2=n,y2=1,interlaced=true)    # Average Per Pixel Diff betwwen Even and Odd fields
    YC  = RT_LumaCorrelation(Last,Last,n=n,y=0,n2=n,y2=1,interlaced=True)   # Correlation Between Even and Odd fields
    YCD = (1.0-YC)*255.0                          # Difference by Correlation [0.0->255, max poss 512.0=-1.0 -ve correlation]
    YPD = RT_LumaPixelsDifferent(Last,Last,n=n,y=0,n2=n,y2=1,interlaced=true,Thresh=LPD_Th) # Population [0->255.0] where pixels different by LPD_Th or more
    VOTE_YD  = (YD  > V_YD_TH)   ? 1:0
    VOTE_YCD = (YCD > V_YCD_TH)  ? 1:0
    VOTE_YPD = (YPD > V_YPD_TH)  ? 1:0
    VOTE_CNT = VOTE_YD + VOTE_YCD + VOTE_YPD
    SC       = VOTE_CNT >= 2
    COUNT = (SC) ? COUNT + 1 : COUNT
    (SUBS)?RT_Subtitle("%d]\nYD =%7.3f\nYCD=%7.3f\nYPD=%7.3f\nVOTE_YD =%.1s\nVOTE_YCD=%.1s\nVOTE_YPD=%.1s\nVOTE_CNT=%d\nSceneChange=%s (COUNT=%d)",
        \ n,YD,YCD,YPD,VOTE_YD!=0,VOTE_YCD!=0,VOTE_YPD!=0,VOTE_CNT,SC,COUNT) : NOP
    if(WRITE && SC) {
        RT_WriteFile(SFrames,"%d",n,Append=True)
        RT_WriteFile(DFramesE,"%d",n*2,Append=True)
        RT_WriteFile(DFramesO,"%d",n*2+1,Append=True)
    }
    Return Last
"""
Scriptclip(SSS)
#StackHorizontal(o,Last)
Return last
EDIT: Slight mods to comments

Frame 103


Frame 104


Frame 105


.\SingleRate.txt
Code:
104
.\DoubleRateEven.txt
Code:
208
\DoubleRateOdd.txt
Code:
209
Could just use result of BOB() [Maybe SelectEven/Odd if singlerate] to fix scene change frame using ClipClop(cmd=Frames) after your dienterlace pass.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 20th April 2021 at 19:59.
StainlessS is offline   Reply With Quote
Old 20th April 2021, 21:28   #52  |  Link
zorr
Registered User
 
Join Date: Mar 2018
Posts: 447
Thanks, those links work. I will try the Quivers too but I'd like to start with a simpler filter just to see how it performs.

Annoyingly I cannot get even Defreq to work, it's the classic "FFT3DFilter: Can not load FFTW3.DLL". It used to work with 32bit Avisynth but not with the 64bit one which I'm using now. I have updated fftw3.dll in Windows/System32 to a 64bit version but I suspect I still may have a wrong version. Could someone provide a link to a version that is known to work with 64bit Windows 10 and 64bit Avisynth? Here's the log from AvisynthInfoTool if it helps:

Code:
[OS/Hardware info]
Operating system:           Windows 10 (x64) (Build 19041)

CPU:                        AMD Ryzen 9 3900X 12-Core Processor  / Ryzen 9 (Matisse)
                            MMX, MMXEXT, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, SSE4A, FMA3, RDSEED, ADX, AVX, AVX2
                            12 physical cores / 24 logical cores


[Avisynth info]
VersionString:              AviSynth+ 3.7.0 (r3382, 3.7, x86_64)
VersionNumber:              2.60
File / Product version:     3.7.0.0 / 3.7.0.0
Interface Version:          8
Multi-threading support:    Yes
Avisynth.dll location:      C:\WINDOWS\SYSTEM32\avisynth.dll
Avisynth.dll time stamp:    2021-01-11, 21:36:39 (UTC)
PluginDir2_5 (HKLM, x64):   E:\AviSynth\AVSPLUS370_x64\plugins
PluginDir+   (HKLM, x64):   E:\AviSynth\AVSPLUS370_x64\plugins


[C++ 2.5 Plugins (64 Bit)]
E:\AviSynth\AVSPLUS370_x64\plugins\defreq.dll  [2007-05-22]

[C++ 2.6 Plugins (64 Bit)]
E:\AviSynth\AVSPLUS370_x64\plugins\AddGrainC.dll  [1.8.3.0]
E:\AviSynth\AVSPLUS370_x64\plugins\avsresize.dll  [0.0.0.0]
E:\AviSynth\AVSPLUS370_x64\plugins\avstimer.dll  [2018-09-11]
E:\AviSynth\AVSPLUS370_x64\plugins\ConvertStacked.dll  [2021-01-11]
E:\AviSynth\AVSPLUS370_x64\plugins\DePan.dll  [2.13.1.6]
E:\AviSynth\AVSPLUS370_x64\plugins\DePanEstimate.dll  [2.10.0.4]
E:\AviSynth\AVSPLUS370_x64\plugins\DirectShowSource.dll  [2021-01-11]
E:\AviSynth\AVSPLUS370_x64\plugins\EEDI2.dll  [1.0.0.0]
E:\AviSynth\AVSPLUS370_x64\plugins\eedi3.dll  [0.9.2.3]
E:\AviSynth\AVSPLUS370_x64\plugins\ffms2.dll  [2020-08-22]
E:\AviSynth\AVSPLUS370_x64\plugins\fft3dfilter.dll  [2.8.0.0]
E:\AviSynth\AVSPLUS370_x64\plugins\ImageSeq.dll  [2021-01-11]
E:\AviSynth\AVSPLUS370_x64\plugins\KNLMeansCL.dll  [2021-04-19]
E:\AviSynth\AVSPLUS370_x64\plugins\masktools2.dll  [2.2.26.0]
E:\AviSynth\AVSPLUS370_x64\plugins\mvtools2.dll  [2.7.44.0]
E:\AviSynth\AVSPLUS370_x64\plugins\neo-dfttest.dll  [1.0.0.0]
E:\AviSynth\AVSPLUS370_x64\plugins\neo-fft3d.dll  [1.0.0.0]
E:\AviSynth\AVSPLUS370_x64\plugins\nnedi3.dll  [0.9.4.57]
E:\AviSynth\AVSPLUS370_x64\plugins\RawSourcePlus.dll  [1.0.0.0]
E:\AviSynth\AVSPLUS370_x64\plugins\RgTools.dll  [1.1.0.0]
E:\AviSynth\AVSPLUS370_x64\plugins\SangNom2.dll  [0.6.0.0]
E:\AviSynth\AVSPLUS370_x64\plugins\Shibatch.dll  [2021-01-11]
E:\AviSynth\AVSPLUS370_x64\plugins\TDeint.dll  [1.8.0.0]
E:\AviSynth\AVSPLUS370_x64\plugins\TimeStretch.dll  [2021-01-11]
E:\AviSynth\AVSPLUS370_x64\plugins\VDubFilter.dll  [2021-01-11]
E:\AviSynth\AVSPLUS370_x64\plugins\yadifmod2.dll  [0.2.7.0]

[Scripts (AVSI)]
E:\AviSynth\AVSPLUS370_x64\plugins\AiUpscale.avsi  [2020-07-25]
E:\AviSynth\AVSPLUS370_x64\plugins\colors_rgb.avsi  [2020-03-02]
E:\AviSynth\AVSPLUS370_x64\plugins\GMSD.avsi  [2021-04-06]
E:\AviSynth\AVSPLUS370_x64\plugins\IQA_downsample.avsi  [2021-03-27]
E:\AviSynth\AVSPLUS370_x64\plugins\MDSI.avsi  [2021-03-27]
E:\AviSynth\AVSPLUS370_x64\plugins\mtmodes.avsi  [2021-04-07]
E:\AviSynth\AVSPLUS370_x64\plugins\QTGMC.avsi  [2021-04-19]
E:\AviSynth\AVSPLUS370_x64\plugins\RoundHalfToEven.avsi  [2021-03-27]
E:\AviSynth\AVSPLUS370_x64\plugins\Zs_RF_Shared.avsi  [2021-04-19]

[Uncategorized DLLs (64 Bit)]
E:\AviSynth\AVSPLUS370_x64\plugins\libfftw3-3.dll  [2021-03-27]
E:\AviSynth\AVSPLUS370_x64\plugins\libfftw3f-3.dll  [2021-03-27]

[Uncategorized files]
E:\AviSynth\AVSPLUS370_x64\plugins\ffms2.lib  [2020-08-22]
E:\AviSynth\AVSPLUS370_x64\plugins\ffmsindex.exe  [2020-08-22]



[Plugin errors/warnings]
____________________________________________________________________________________________

Function duplicates:

"undefined" : "[InternalFunction]"
"Undefined" : "E:\AviSynth\AVSPLUS370_x64\plugins\Zs_RF_Shared.avsi"

____________________________________________________________________________________________

'E:/AviSynth/AVSPLUS370_x64/plugins/KNLMeansCL.dll' cannot be used as a plugin for AviSynth.
____________________________________________________________________________________________
zorr is offline   Reply With Quote
Old 20th April 2021, 22:25   #53  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Zorr,
Some plugs use the same dll via different names,
fftw3.dll
libfftw3f-3.dll

And a few months back, another plug used yet another name, I dont recall which plug it was.

EDIT: Here [used by KPassFilterCL, Passfilter.dll]:- https://forum.doom9.org/showthread.p...00#post1929800

Some more recent plugs can use either of the two first mentioned names.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 20th April 2021 at 22:29.
StainlessS is offline   Reply With Quote
Old 20th April 2021, 23:28   #54  |  Link
zorr
Registered User
 
Join Date: Mar 2018
Posts: 447
Quote:
Originally Posted by StainlessS View Post
Zorr,
Some plugs use the same dll via different names,
fftw3.dll
libfftw3f-3.dll
Yes it's probably something like that. Because for example FFT3DFilter is working and it's using the same fftw3 library.

Just to be clear, I have downloaded the latest available (v3.3.5) 64 bit dlls from http://www.fftw.org/install/windows.html. There's source available for 3.3.9 but seems there are no binaries for that. In the package there are 3 dll files:
Code:
libfftw3-3.dll
libfftw3f-3.dll
libfftw3l-3.dll
I took libfftw3-3.dll and renamed it to fftw3.dll and put it into windows/System32. Are you suggesting that I should take the same file, rename it to libfftw3f-3.dll and put it into System32 also? Note that the package itself contains a file with that name, so it must be a different dll right?

EDIT:
The only link to 64bit Defreq I was able to find was in this post.
Interestingly the package claims to contain x64 version of fftw3.dll but it seems to be x86 - I get "Avisynth open failure: Cannot load a 32 bit DLL in 64 bit Avisynth..." when it's placed into Avisynth plugins folder. If I place it only to System32 the error message is the original "Can not load FFTW3.DLL". I think this means Defreq is not looking for it at System32 at all, and instead looking for it in the plugins folder.

EDIT2:
I can't find x64 Quivers either, does anybody have a link?

EDIT3:
Ah, the Quivers are within ManyPlus plugin. And x64 version is available.

Last edited by zorr; 21st April 2021 at 01:27.
zorr is offline   Reply With Quote
Old 21st April 2021, 01:58   #55  |  Link
Atlantis
Registered User
 
Join Date: Feb 2002
Posts: 758
I see there are interest in this. So for research and testing purposes I post a longer clip for people who want to do academic stuff!
2 minutes, includes wave patterns, clean cuts and bad combed cuts.

https://www.mediafire.com/file/nk1gf.../clip.mkv/file
Atlantis is offline   Reply With Quote
Old 21st April 2021, 02:06   #56  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
by zorr
Quote:
libfftw3-3.dll and renamed it to fftw3.dll
Wrong one, remove it.
Code:
libfftw3-3.dll
libfftw3f-3.dll       # THIS ONE, Copy as is to x64 system32 and make another copy and rename to fftw3.dll also in system32 
libfftw3l-3.dll
EDIT: Remove this lot from plugins, [except ffmsindex.exe, if you use it via command line from plugins directory(ffms2 indexer)]
Code:
[Uncategorized DLLs (64 Bit)]
E:\AviSynth\AVSPLUS370_x64\plugins\libfftw3-3.dll  [2021-03-27]
E:\AviSynth\AVSPLUS370_x64\plugins\libfftw3f-3.dll  [2021-03-27]

[Uncategorized files]
E:\AviSynth\AVSPLUS370_x64\plugins\ffms2.lib  [2020-08-22]
E:\AviSynth\AVSPLUS370_x64\plugins\ffmsindex.exe  [2020-08-22]
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 21st April 2021 at 02:27.
StainlessS is offline   Reply With Quote
Old 21st April 2021, 05:47   #57  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Bit more tinker, Pre-scan on short bit of whole clip, to judge best thresholds to use for full clip.

Code:
#Avisource("clip3.mkv.avi") # Original Short clip
Avisource("clip.mkv.avi")   # Longer one, but still short piece of whole clip.
o=last
assumetff()

### Config ###
SUBS       = True
WRITE      = True
LPD_Th = 10  # RT_LumaPixelsDifferent() Threshold, if corresponding pixels more different than this then is counted
SHOWMINMAX = True  # Show Metric minimums where scenechange detected, AND metrics Maximums where NO Scenechange detected [tweak thresholds]
# Voting Thresholds, if above these then VOTE is for SceneChange.
V_YD_TH  = 32.0           # I've made these the average of MAX when NO Scenechage and MIN when SceneChange, as shown when SHOWMINMAX=True.
V_YCD_TH = 107.0          #   Ditto
V_YPD_TH = 162.0          #   Ditto,  # If you change LPD_Th, then re-scan and re-calc V_YPD_TH as Ave of YPD_MIN and YPD_MAX
                          #     Intent, allow choose best setting for metric pre-scan on shorter piece of your clip. Then do full scan to write files.
                          #     Can use Vdub2 Video Analysis pass for pre-scan and scan proper.
###
SFrames  = ".\SingleRate.txt"
DFramesE = ".\DoubleRateEven.txt"
DFramesO = ".\DoubleRateOdd.txt"
############################
############################
############################

if(WRITE) {
    SFrames  = SFrames.RT_GetFullPathName
    DFramesE = DFramesE.RT_GetFullPathName
    DFramesO = DFramesO.RT_GetFullPathName
    RT_fileDelete(SFrames)
    RT_fileDelete(DFramesE)
    RT_fileDelete(DFramesO)
}
YD_MIN  = 255.0
YCD_MIN = 512.0
YPD_MIN = 255.0
YD_MAX  = 0.0
YCD_MAX = 0.0
YPD_MAX = 0.0

COUNT = 0 # COUNT valid only on forward ONLY scan
SSS="""
    n = current_frame
    YD  = RT_LumaDifference(Last,Last,n=n,y=0,n2=n,y2=1,interlaced=true)    # Average Per Pixel Diff betwwen Even and Odd fields
    YC  = RT_LumaCorrelation(Last,Last,n=n,y=0,n2=n,y2=1,interlaced=True)   # Correlation Between Even and Odd fields
    YCD = (1.0-YC)*255.0                                                    # Difference by Correlation [0.0->255, max poss 512.0=-1, -ve correlation]
    YPD = RT_LumaPixelsDifferent(Last,Last,n=n,y=0,n2=n,y2=1,interlaced=true,Thresh=LPD_Th) # Population [0->255.0] where pixels different by LPD_Th or more
    VOTE_YD  = (YD  > V_YD_TH)   ? 1:0
    VOTE_YCD = (YCD > V_YCD_TH)  ? 1:0
    VOTE_YPD = (YPD > V_YPD_TH)  ? 1:0
    VOTE_CNT = VOTE_YD + VOTE_YCD + VOTE_YPD
    SC       = VOTE_CNT >= 2
    COUNT = (SC) ? COUNT + 1 : COUNT
    (SUBS)?RT_Subtitle("%d]\nYD =%7.3f\nYCD=%7.3f\nYPD=%7.3f\nVOTE_YD =%.1s\nVOTE_YCD=%.1s\nVOTE_YPD=%.1s\nVOTE_CNT=%d\nSceneChange=%s (COUNT=%d)",
        \ n,YD,YCD,YPD,VOTE_YD!=0,VOTE_YCD!=0,VOTE_YPD!=0,VOTE_CNT,SC,COUNT) : NOP
    if(WRITE && SC) {
        RT_WriteFile(SFrames,"%d",n,Append=True)
        RT_WriteFile(DFramesE,"%d",n*2,Append=True)
        RT_WriteFile(DFramesO,"%d",n*2+1,Append=True)
    }
    if(SHOWMINMAX) {
        if(SC) {
             YD_MIN = ( YD <  YD_MIN) ?  YD :  YD_MIN
            YCD_MIN = (YCD < YCD_MIN) ? YCD : YCD_MIN
            YPD_MIN = (YPD < YPD_MIN) ? YPD : YPD_MIN
        } else {
            YD_MAX  = ( YD >  YD_MAX) ?  YD :  YD_MAX
            YCD_MAX = (YCD > YCD_MAX) ? YCD : YCD_MAX
            YPD_MAX = (YPD > YPD_MAX) ? YPD : YPD_MAX
        }
        RT_Subtitle(" SC: VD_MIN = %7.3f : VCD_MIN = %7.3f : VPD_MIN = %7.3f\n" + \
                    "!SC: VD_MAX = %7.3f : VCD_MAX = %7.3f : VPD_MAX = %7.3f\n"   + \
                    "\a!SET: V_YD_TH= %7.3f : V_VCD_TH= %7.3f : V_VPD_TH= %7.3f",
                    \ YD_MIN,YCD_MIN,YPD_MIN,YD_MAX,YCD_MAX,YPD_MAX,
                    \ Round((YD_MIN+YD_MAX)/2.0),Round((YCD_MIN+YCD_MAX)/2.0),Round((YPD_MIN+YPD_MAX)/2.0),
                    \ align=1)
    }
    Return Last
"""
Scriptclip(SSS)
#StackHorizontal(o,Last)
Return last
Metrics on Final frame


EDIT: NOTED SceneChanges are of course mid frame (bottom field) scene changes. [the other scene changes are ignored, not detected]
(just for anybody thinking that this is a standard scene change detector, it aint)

EDIT: And the last of 3 detected mid frame scene changes in 3002 frames.


SingleRate.txt
Code:
492
581
1744
DoubleRateEven.txt
Code:
984
1162
3488
DoubleRateOdd.txt
Code:
985
1163
3489
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 21st April 2021 at 06:09.
StainlessS is offline   Reply With Quote
Old 21st April 2021, 19:00   #58  |  Link
Atlantis
Registered User
 
Join Date: Feb 2002
Posts: 758
I have to share another clip for completeness.

https://www.mediafire.com/file/hat1g...clip2.mkv/file

This is a dark clip where bad scene change detection is more difficult. This script did not work with this part of the video:

Code:
o=last

o
assumetff()
bwdif(field=3, edeint=nnedi3(field=3))
deint=last

deint
merge(selecteven, selectodd)
deintblend=last

deintblendhalf = deint.selecteven()

ConditionalFilter(deintblend, deintblendhalf, deintblend, "YDifferenceFromPrevious>19 && YDifferenceToNext>19")
Atlantis is offline   Reply With Quote
Old 21st April 2021, 21:38   #59  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,493
Had a stab at a hunch, more for fun than anything else, not intended to be a real solution (left is QTGMC output, right is my "filter"):

__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline   Reply With Quote
Old 21st April 2021, 22:27   #60  |  Link
Atlantis
Registered User
 
Join Date: Feb 2002
Posts: 758
Not enough!

Last edited by Atlantis; 21st April 2021 at 22:50.
Atlantis is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 14:33.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.