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 > VapourSynth

Reply
 
Thread Tools Search this Thread Display Modes
Old 9th May 2020, 10:28   #1  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,718
Semi-automatic way to tweak thscd1 and thscd2 in mvtools?

As the VS version of mvtools does not have the MShow functionality to visualize the motion vectors, I'm having problems tweaking the scene change threshold parameters. Noisy or material having a lot of fast movement is troublesome as they usually require raising the thresholds, otherwise they detect a lot of scene changes in places where it's not true.

I came up with an idea to do the degraining with a range of values for thscd1 or thscd2, maybe with 10 point steps or so. Use MakeDiff to extract the difference between the original and degrained clip. Display the different results along with the original in the same frame (downscaled or simply just cut a small part of the frame to show because you can easily see if no noise is removed).

Could someone help me with scripting this visualization, please? Or port MShow
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 9th May 2020, 10:49   #2  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
you don't need mshow to check if scene change detections worked properly. simply print _SceneChangePrev and _SceneChangeNext frame properties.
feisty2 is offline   Reply With Quote
Old 9th May 2020, 13:03   #3  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,718
Quote:
Originally Posted by feisty2 View Post
you don't need mshow to check if scene change detections worked properly. simply print _SceneChangePrev and _SceneChangeNext frame properties.
Cheers, didn't remember/know that there's a function in the pack to provide this info
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 9th May 2020, 17:15   #4  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,718
I've worked it over like this, getting the property value for different thscd values. But I'm stumped with the current frame number, which is needed in get_frame. How do I get that one?

Code:
thscd = 100
sc = []
while thscd < 400 :
    finalclip = core.mv.SCDetection(src, fv1, thscd1=thscd, thscd2=80)
    scframe = finalclip.get_frame(n)
    sc.append(scframe.props['_SceneChangePrev'])
    thscd += 10
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 9th May 2020, 17:45   #5  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
why don't you print frame properties directly on your video clip?
you can then check them in the preview window of vsedit
feisty2 is offline   Reply With Quote
Old 9th May 2020, 18:01   #6  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,718
I was thinking of printing the result of all tests in the same frame along with the corresponding thscd value. Or is it possible with FrameProps?
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 9th May 2020, 18:38   #7  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 321
to print just a frame with that thscd:
thscd = 45
src = core.text.FrameNum(src, alignment=7)
src = core.text.Text(src, str(thscd), alignment=8)
_Al_ is offline   Reply With Quote
Old 9th May 2020, 18:43   #8  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,718
The problem is printing all values in the same frame. In that example, I would check thscd between 100-400 in steps of 10 and print the result of each of them in the same frame. In a real case, I'd probably have a range over 240-350 or something like that.
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 9th May 2020, 18:49   #9  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
trivial stuff, learn a bit of python
feisty2 is offline   Reply With Quote
Old 9th May 2020, 18:50   #10  |  Link
ChaosKing
Registered User
 
Join Date: Dec 2005
Location: Germany
Posts: 1,795
Quote:
Originally Posted by Boulder View Post
I've worked it over like this, getting the property value for different thscd values. But I'm stumped with the current frame number, which is needed in get_frame. How do I get that one?

Code:
thscd = 100
sc = []
while thscd < 400 :
    finalclip = core.mv.SCDetection(src, fv1, thscd1=thscd, thscd2=80)
    scframe = finalclip.get_frame(n)
    sc.append(scframe.props['_SceneChangePrev'])
    thscd += 10
Look also how to use frameeval

Simple example for detecting a blinking clock. (n is your current frame number)
https://forum.doom9.org/showthread.p...19#post1906719

http://www.vapoursynth.com/doc/functions/frameeval.html


or if you just want to "scan" the whole video before filtering

Code:
for i in range(clip.num_frames):
    clip.get_frame(i)
Example: https://gist.github.com/dubhater/3a2...ek-test-py-L38
__________________
AVSRepoGUI // VSRepoGUI - Package Manager for AviSynth // VapourSynth
VapourSynth Portable FATPACK || VapourSynth Database
ChaosKing is online now   Reply With Quote
Old 9th May 2020, 19:02   #11  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
I don't wanna write the code cuz it's boring, but basically you do the following

1. let n = 0
2. evaluate the clip with mv.SCDetection
3. attach scd1_n, scd2_n as frame props
4. let _SceneChangePrev_n = _SceneChangePrev, _SceneChangeNext_n = _SceneChangeNext
5. attach _SceneChangePrev_n, _SceneChangeNext_n as frame props
6. erase _SceneChangePrev, _SceneChangeNext from frame props
7. n = n + 1
8. repeat 2. ~ 7. with different scd1 and scd2
9. print all frame props
feisty2 is offline   Reply With Quote
Old 9th May 2020, 19:21   #12  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 321
Do you want to print frame value together with all possible props['_SceneChangePrev'] values in one frame from that loop?
then put those values directly in that sc list right away,
text.Text() accepts new lines


to generate n for each frame it is up to you as Chaos King says, if using FrameEval and put you loop thing in it, where n is passed for your convenience

Code:
def using_eval(n, clip):
    thscd = 100
    sc = []
    while thscd < 400 :
        finalclip = core.mv.SCDetection(clip, fv1, thscd1=thscd, thscd2=80)
        scframe = finalclip.get_frame(n)
        sc.append(   str(thscd) + ' ,   ' + str(scframe.props['_SceneChangePrev']) )
        thscd += 10
    return core.text.Text( clip, '\n'.join(sc), alignment=7)
src = core.text.FrameNum(src,  alignment=8)
out = core.std.FrameEval(src, functools.partial(using_eval, clip=src))
oh, that is not going to work, because finalclip will be always the same, or maybe yes, try it, I cannot test it using mvtools now

Last edited by _Al_; 10th May 2020 at 03:52.
_Al_ is offline   Reply With Quote
Old 9th May 2020, 21:18   #13  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,718
Thanks everyone, I'll do some testing tomorrow when I have more time.
It would be easy if the current frame number could be extracted like clip width or height but looks like it needs some more complex ways.
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 10th May 2020, 10:38   #14  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,718
Quote:
Originally Posted by _Al_ View Post
oh, that is not going to work, because finalclip will be always the same, or maybe yes, try it, I cannot test it using mvtools now
To me it looks like it works perfectly It is just surprising to see how low you can set thscd1 and/or thscd2 before false scene changes are appearing in the list. I think that it was quite different with the old Avisynth toolset.

Need to test some more, I think I should try to find a nice baseline for my needs.
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder 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 12:07.


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