Hi everyone,
I've been doing a lot of video encoding lately and all the little manual edits to the avisynth scripts to adjust filters to different content were rather tedious.
So I was thinking of making a RM skin as a GUI with dials for certain parameters.
But how?
I've created a bunch of rm skins in the past, but only by using existing plug-ins that provided data about cpu, gpu ... the usual stuff.
I'd need the script to open the .avs file, go to a certain line and either change a specific value or, in case it's simpler that way, replace the whole line.
I've read somewhere that there's a "writetofile" function in rm, but the forum search didn't turm up anything useful.
Big Thx in advance.
It is currently March 29th, 2024, 7:44 am
Rainmeter for changing parameters in .avs file (AVISYNTH)?
-
- Posts: 26
- Joined: October 14th, 2014, 11:15 pm
-
- Rainmeter Sage
- Posts: 16110
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Rainmeter for changing parameters in .avs file (AVISYNTH)?
Yes, there is, the !WriteKeyValue bang, but using it Rainmeter can write only to .ini formatted file, replacing / adding some options.protator wrote: ↑January 6th, 2019, 5:43 am I'd need the script to open the .avs file, go to a certain line and either change a specific value or, in case it's simpler that way, replace the whole line.
I've read somewhere that there's a "writetofile" function in rm, but the forum search didn't turm up anything useful.
Otherwise maybe with .lua support. But it's not easy at all.
How does a such file looks like and what would you like to write there?
-
- Posts: 26
- Joined: October 14th, 2014, 11:15 pm
Re: Rainmeter for changing parameters in .avs file (AVISYNTH)?
This would be a worst case scenario:
There's nothing exiting going on in these scripts, at most one or two global variables (like increasing the allocated ram in this case) followed by calls for the desired filter plug-ins and whatever variables they have.
For just a bit of color correction a script could be as short as this:
It should be possible to spread the filter parameters out so there are lines with just the lone values.
But just being able to toggle a filter on or off by adding/deleting a "#" to/from a line would already be a big QoL feature.
No more copy/past'ing stuff together from sample scripts, just one script with all my fav filters in it and a rm skin with a bunch of badly labled buttons^^... that'd be a good start.
Code: Select all
SetMemoryMax(1024)
SetMTMode(5,4)
Tweak(sat=1.02,cont=1.03).distributor()
SetMTMode(1)
AutoAdjust(auto_balance=true,chroma_limit=1.02,balance_str=0.02,use_dither=false,threads_count=2).distributor()
SetMTMode(2)
KNLMeansCL(d=1,a=2,s=4,h=1.0,channels="y",wmode=0,wref=1.0,device_type="gpu",device_id=1,info=false).distributor()
aWarpSharp2(thresh=190,blur=15,type=1,depth=2).distributor()
MSmooth(threshold=1,strength=1,chroma=true,highq=true).distributor()
aWarpSharp2(thresh=190,blur=15,type=1,depth=4).distributor()
FastLineDarkenMOD(strength=50,luma_cap=255,threshold=3,thinning=0).distributor()
SetMTMode(5)
DCTFilter(1,1,1,1,1,1,1,0).distributor()
SetMTMode(2)
maa2(mask=1,chroma=false,ss=2.0,aa=48,aac=16,threads=3,show=0).distributor()
return(last)
For just a bit of color correction a script could be as short as this:
Code: Select all
SetMTMode(5,4)
Tweak(sat=1.02,cont=1.03).distributor()
return(last)
But just being able to toggle a filter on or off by adding/deleting a "#" to/from a line would already be a big QoL feature.
No more copy/past'ing stuff together from sample scripts, just one script with all my fav filters in it and a rm skin with a bunch of badly labled buttons^^... that'd be a good start.
-
- Rainmeter Sage
- Posts: 16110
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Rainmeter for changing parameters in .avs file (AVISYNTH)?
Let's clarify a few thing first:
- Not sure what you mean by:
Is the # character the commenting out character in these scripts? Would you like to add / remove a such character in front of some lines? Have I understood well what you would like to achieve?
-
- Rainmeter Sage
- Posts: 7029
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Rainmeter for changing parameters in .avs file (AVISYNTH)?
balala wrote: ↑January 6th, 2019, 8:32 am Yes, there is, the !WriteKeyValue bang, but using it Rainmeter can write only to .ini formatted file, replacing / adding some options. Otherwise maybe with .lua support. But it's not easy at all.
I think this might be much easier to achieve than expected. One could just use the !WriteKeyValue bang in a Rainmeter skin to write this in an .ini format file, e.g. [!WriteKeyValue SomeRandomSectionName SomeKeyNameOrRowNumberID SomeKeyValueAkaAvsRowContent "SomeIniFile"]. This would create (or rather update) that .ini file into something like:protator wrote: ↑January 6th, 2019, 10:10 am This would be a worst case scenario:But just being able to toggle a filter on or off by adding/deleting a "#" to/from a line would already be a big QoL feature.Code: Select all
SetMemoryMax(1024) SetMTMode(5,4) Tweak(sat=1.02,cont=1.03).distributor() SetMTMode(1) AutoAdjust(auto_balance=true,chroma_limit=1.02,balance_str=0.02,use_dither=false,threads_count=2).distributor() SetMTMode(2) KNLMeansCL(d=1,a=2,s=4,h=1.0,channels="y",wmode=0,wref=1.0,device_type="gpu",device_id=1,info=false).distributor() aWarpSharp2(thresh=190,blur=15,type=1,depth=2).distributor() MSmooth(threshold=1,strength=1,chroma=true,highq=true).distributor() aWarpSharp2(thresh=190,blur=15,type=1,depth=4).distributor() FastLineDarkenMOD(strength=50,luma_cap=255,threshold=3,thinning=0).distributor() SetMTMode(5) DCTFilter(1,1,1,1,1,1,1,0).distributor() SetMTMode(2) maa2(mask=1,chroma=false,ss=2.0,aa=48,aac=16,threads=3,show=0).distributor() return(last)
No more copy/past'ing stuff together from sample scripts, just one script with all my fav filters in it and a rm skin with a bunch of badly labled buttons^^... that'd be a good start.
Code: Select all
[SomeRandomSectionName]
Row001=AutoAdjust(auto_balance=true,chroma_limit=1.02,balance_str=0.02,use_dither=false,threads_count=2).distributor()
Row002=SetMTMode(2)
............................
Since Protator said that he created other skins as well, I assumed he would know how to implement this in detail. Of course, he should know the basics on batch commands - if not, there is always Google and StackOverflow ready to help with it...
So yes, it can be done. No Lua bull... you know what I mean.
-
- Rainmeter Sage
- Posts: 16110
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Rainmeter for changing parameters in .avs file (AVISYNTH)?
Yep, maybe this might be a solution as well. It's a bit weird in my opinion, but might work.Yincognito wrote: ↑January 7th, 2019, 6:52 pm I think this might be much easier to achieve than expected. One could just use the !WriteKeyValue bang in a Rainmeter skin to write this in an .ini format file, e.g. [!WriteKeyValue SomeRandomSectionName SomeKeyNameOrRowNumberID SomeKeyValueAkaAvsRowContent "SomeIniFile"]. This would create (or rather update) that .ini file into something like:
And then, just use the RunCommand plugin to execute a batch file (aka a .bat or .cmd) by setting the RunCommand's measure Parameter=SomeBatchFile.cmd. That batch file would have to change the previous .ini file's extension to an .avs one, remove the "[SomeRandomSectionName]" and "Row001=" strings from the file's contents and then execute the script. A button in the skin that would do the latter would bear a name like "Commit Changes And Run" or something like that. Voila!Code: Select all
[SomeRandomSectionName] Row001=AutoAdjust(auto_balance=true,chroma_limit=1.02,balance_str=0.02,use_dither=false,threads_count=2).distributor() Row002=SetMTMode(2) ............................
Since Protator said that he created other skins as well, I assumed he would know how to implement this in detail. Of course, he should know the basics on batch commands - if not, there is always Google and StackOverflow ready to help with it...
So yes, it can be done. No Lua bull... you know what I mean.
Let's wait for protator's reply, to see what he think about these solutions. Then we'll see...
-
- Rainmeter Sage
- Posts: 7029
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Rainmeter for changing parameters in .avs file (AVISYNTH)?
Here is a very basic sample skin (it only writes stuff to a AVSScript.avs file in the @Resources folder of the current skin):
No need to change file's extension to .avs, Rainmeter can write to it as it is. One could use [!WriteKeyValue "" "" "#Row001#" "#@#AVSScript.avs"] to create an empty section "[]" and rows that have no key name on them, but that would make identifying rows more difficult. I've included this method in the skin, but it's commented. It's tested and it works with rows like "AutoAdjust(auto_balance=true,chroma_limit=1.02,balance_str=0.02,use_dither=false,threads_count=2).distributor()" that use multiple "=" and stuff.
To remove the "[Section]" and "Row001=" strings from the file, a batch along the lines of this or this would do the trick. Of course, it would have to be adapted for the needs of this task.
No need to change file's extension to .avs, Rainmeter can write to it as it is. One could use [!WriteKeyValue "" "" "#Row001#" "#@#AVSScript.avs"] to create an empty section "[]" and rows that have no key name on them, but that would make identifying rows more difficult. I've included this method in the skin, but it's commented. It's tested and it works with rows like "AutoAdjust(auto_balance=true,chroma_limit=1.02,balance_str=0.02,use_dither=false,threads_count=2).distributor()" that use multiple "=" and stuff.
To remove the "[Section]" and "Row001=" strings from the file, a batch along the lines of this or this would do the trick. Of course, it would have to be adapted for the needs of this task.
You do not have the required permissions to view the files attached to this post.
Last edited by Yincognito on January 7th, 2019, 7:46 pm, edited 1 time in total.
-
- Rainmeter Sage
- Posts: 16110
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Rainmeter for changing parameters in .avs file (AVISYNTH)?
In the meantime, one more question: if no .lua script used, how will know Rainmeter what to write back into the file? Because protator initially asked to:
I think Rainmeter natively can't do this: can't read the content of the file, add a character to certain lines, then write back everything.
-
- Rainmeter Sage
- Posts: 7029
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Rainmeter for changing parameters in .avs file (AVISYNTH)?
Well, as far as I understood, the OP already has some "standard" script in mind when doing this, so it would be all about changing some values in an already typical line. So, the line AutoAdjust(auto_balance=true,chroma_limit=1.02,balance_str=0.02,use_dither=false,threads_count=2).distributor() would probably stay the same, except you change a few variables there and it would become AutoAdjust(auto_balance=false,chroma_limit=5.02,balance_str=1.02,use_dither=true,threads_count=1).distributor() or something.balala wrote: ↑January 7th, 2019, 7:40 pm In the meantime, one more question: if no .lua script used, how will know Rainmeter what to write back into the file? Because protator initially asked to:
I think Rainmeter natively can't do this: can't read the content of the file, add a character to certain lines, then write back everything.
Oh, but it actually can ... if you set the section name to [Variables] and load it in the skin with a @IncludeVariables=FileName and only then modifying things with !WriteKeyValue-s. A bit of a back-reference, but theoretically doable. Am I right, my friend?
-
- Rainmeter Sage
- Posts: 16110
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Rainmeter for changing parameters in .avs file (AVISYNTH)?
Doing it this way, yes, it can be done, but later processing is required, as yourself wrote, to remove section and option names.Yincognito wrote: ↑January 7th, 2019, 7:57 pm Oh, but it actually can ... if you set the section name to [Variables] and load it in the skin with a @IncludeVariables=FileName and only then modifying things with !WriteKeyValue-s. A bit of a back-reference, but theoretically doable. Am I right, my friend?
Question is if it worth?