[Update] Saver Tools - Loader from Saver and Saver Manager scripts  [SUBMITTED]

Moderator: SecondMan

User avatar
Movalex
Fusioneer
Posts: 108
Joined: Fri Nov 03, 2017 5:36 am
Answers: 2
Been thanked: 22 times
Contact:

[Update] Saver Tools - Loader from Saver and Saver Manager scripts

#1

Post by Movalex » Thu Mar 21, 2019 1:49 pm

Literally create Loader from Saver. Works with multiple savers selected.
Loader is created next to the Saver's position.
If the Saver has image sequence with no number padding (0000), default padding is created.
If file is a container (mov, avi, mp4, mxf) — original name is used.
P.S. Kudos to @Egert#6282 from "Pirates of ConFusion" for original idea and base algorithm.
Attachments
com.AlexBogomolov.LoaderFromSaver.zip
(3.91 KiB) Downloaded 4 times
Last edited by Movalex on Thu Mar 21, 2019 3:40 pm, edited 1 time in total.

User avatar
Midgardsormr
Fusionator
Posts: 1053
Joined: Wed Nov 26, 2014 8:04 pm
Answers: 1
Location: Los Angeles, CA, USA
Been thanked: 61 times
Contact:

Re: Loader from Saver script

#2

Post by Midgardsormr » Thu Mar 21, 2019 2:40 pm

Pro tip: Put it on a button on your Saver. Here's ours:

Code: Select all

{
	Tools = ordered() {
		Saver1 = Saver {
			CtrlWZoom = false,
			Inputs = {
				ProcessWhenBlendIs00 = Input { Value = 0, },
				Clip = Input {
					Value = Clip {
						Length = 0,
						Saving = true,
						TrimIn = 0,
						ExtendFirst = 0,
						ExtendLast = 0,
						Loop = 1,
						AspectMode = 1,
						Depth = 1,
						TimeCode = 0,
						GlobalStart = -2000000000,
						GlobalEnd = 0
					},
				},
				OutputFormat = Input { Value = FuID { "DPXFormat" }, },
				["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
				["DPXFormat.BypassConversion"] = Input { Value = 1, },
				["DPXFormat.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
			},
			ViewInfo = OperatorInfo { Pos = { 55, 16.5 } },
			UserControls = ordered() {
				MakeLoader = {
					BTNCS_Execute = "						args = { tool = comp.ActiveTool }\n						comp:RunScript(\"S:/net_exe/BlackMagic/fusion9/scripts/Tool/buttonScripts/Saver_MakeLoader_v03.lua\", args)\n					",
					LINKS_Name = "Make Loader",
					INPID_InputControl = "ButtonControl",
					ICS_ControlPage = "File"
				}
			}
		}
	}
}

Obviously you'd want to change that path.

User avatar
SirEdric
Fusionator
Posts: 1820
Joined: Tue Aug 05, 2014 10:04 am
Answers: 2
Real name: Eric Westphal
Been thanked: 97 times
Contact:

Re: [Submission] Loader from Saver script

#3

Post by SirEdric » Thu Mar 21, 2019 10:45 pm

Midgardsormr wrote:
Thu Mar 21, 2019 2:40 pm
Obviously you'd want to change that path.
Or stash the actual script inside the tool's CustomData and call it directly from there...:-)

User avatar
Midgardsormr
Fusionator
Posts: 1053
Joined: Wed Nov 26, 2014 8:04 pm
Answers: 1
Location: Los Angeles, CA, USA
Been thanked: 61 times
Contact:

Re: [Submission] Loader from Saver script

#4

Post by Midgardsormr » Fri Mar 22, 2019 7:57 am

You can actually run even a very long script entirely from within the BTNCS_Execute attribute (enclose it in [[ ]] instead of quotations to make your life easier), and I used to do it that way (I believe there's an example on this forum somewhere). Ultimately, though, I found that it's easier to maintain an external script that just gets called from the button.

User avatar
Movalex
Fusioneer
Posts: 108
Joined: Fri Nov 03, 2017 5:36 am
Answers: 2
Been thanked: 22 times
Contact:

Re: [Submission] Loader from Saver script

#5

Post by Movalex » Fri Mar 22, 2019 9:38 am

Wow, thanks!
Actually I thought about creating of UI and a .setting file to accompany this script. Setting for a Saver (kind of a macro) with a button already assigned. UI saver manager for selecting all savers (probably someone will want to create loader from all savers?), deactivating unselected... Something like this:
Attachments
saver_manager.lua
(2.28 KiB) Downloaded 1 time
Screenshot 2019-03-22 19.38.37.png
Screenshot 2019-03-22 19.38.37.png (41.67 KiB) Viewed 319 times

User avatar
Midgardsormr
Fusionator
Posts: 1053
Joined: Wed Nov 26, 2014 8:04 pm
Answers: 1
Location: Los Angeles, CA, USA
Been thanked: 61 times
Contact:

Re: [Submission] Loader from Saver script

#6

Post by Midgardsormr » Fri Mar 22, 2019 11:52 am

You might be interested in some other variations, too. Here's a routine to connect your Loader to everything downstream the Saver was connected to:

Code: Select all

			inputs = tool.Output:GetConnectedInputs()
			myloader = comp:AddTool("Loader", posx+1, posy - 1)
			for i, input in ipairs(inputs) do
				input:ConnectTo(myloader.Output)
			end

This disables all unselected Savers and stores their original passthrough state in their CustomData:

Code: Select all

local savers = c:GetToolList(false, "Saver")

if savers then
	for i,s in pairs(savers) do
	
		-- Store passthrough state of existing savers in custom data
		local sattrs = s:GetAttrs()
		savers[i]:SetData("passthrough", sattrs.TOOLB_PassThrough)
		
		-- Disable all savers
		s:SetAttrs({TOOLB_PassThrough = true})
	end
end

comp.ActiveTool:SetAttrs({TOOLB_PassThrough = false})

And this one re-enables Savers that the previous code turned off, then disables the active Saver:

Code: Select all

			local savers = composition:GetToolList(false, "Saver")
			for i,s in pairs(savers) do
				local sattrs = s:GetAttrs()
				check = savers[i]:GetData("passthrough")
				if check == false then
					s:SetAttrs({TOOLB_PassThrough = false})
				end
				tool:SetAttrs({TOOLB_PassThrough = true})
			end

To add User Controls to a node by script:

Code: Select all

	local ctrls = table.ordered()

	-- Add the Re-Enable Other Savers button
	ctrls.PT = {
		LINKID_DataType = "Number",
		INP_Default = 0,
		INPID_InputControl = "ButtonControl",
 		BTNCS_Execute = [[
				--script goes here
		]],
		LINKS_Name = "Re-Enable Other Savers",
		ICS_ControlPage = "File",
		}
	
	-- Add the Make Loader button
	
	ctrls.ML = {
		LINKID_DataType = "Number",
		INP_Default = 0,
		INPID_InputControl = "ButtonControl",
 		BTNCS_Execute = [[
				--script goes here
		]],
		LINKS_Name = "Make Loader",
		ICS_ControlPage = "File",
	}
	
	exrsv.UserControls = ctrls
	-- Force interface refresh.
	
	refresh = NewLoader:Refresh()


Those are the useful pieces of a Make Precomp script I use. I didn't share the entire script because large portions of it are unique to the Muse pipeline, and it won't work outside our environment.

User avatar
Movalex
Fusioneer
Posts: 108
Joined: Fri Nov 03, 2017 5:36 am
Answers: 2
Been thanked: 22 times
Contact:

Re: [Submission] Loader from Saver script

#7

Post by Movalex » Fri Mar 22, 2019 11:54 am

This is huge! Thanks a bunch, I will look at this definitely!

User avatar
Movalex
Fusioneer
Posts: 108
Joined: Fri Nov 03, 2017 5:36 am
Answers: 2
Been thanked: 22 times
Contact:

Re: [Submission] Loader from Saver script  [SUBMITTED]

#8

Post by Movalex » Sat Mar 30, 2019 3:27 pm

Here's what I ended with so far.

Image

The saver manager UI works with any composition tab opened.
The button 'Solo selected' will disable all unselected savers, while enables all selected if necessary. So, IMHO, no need to use custom 'passthrough' data for this task.
You can create Saver with button assigned to launch Loader creation script with CreateSaverPlus script.

Any suggestions?
Attachments
saver tools reactor.zip
(11.89 KiB) Downloaded 4 times

User avatar
Midgardsormr
Fusionator
Posts: 1053
Joined: Wed Nov 26, 2014 8:04 pm
Answers: 1
Location: Los Angeles, CA, USA
Been thanked: 61 times
Contact:

Re: [Submission] Loader from Saver script

#9

Post by Midgardsormr » Sat Mar 30, 2019 5:13 pm

Very nice!

User avatar
Movalex
Fusioneer
Posts: 108
Joined: Fri Nov 03, 2017 5:36 am
Answers: 2
Been thanked: 22 times
Contact:

Re: [Submission] Loader from Saver script

#10

Post by Movalex » Sat Mar 30, 2019 5:15 pm

Thanks for help!

User avatar
SecondMan
Site Admin
Posts: 3415
Joined: Thu Jul 31, 2014 5:31 pm
Answers: 3
Location: Vancouver, Canada
Been thanked: 78 times
Contact:

Re: [Submission] Saver Tools - Loader from Saver and Saver Manager scripts

#11

Post by SecondMan » Sun Mar 31, 2019 12:10 am

And these versions are now available in Reactor! :cheer:

Added in 1 minute 29 seconds:
I've also adjusted the topic title to reflect the actual submission.

User avatar
Movalex
Fusioneer
Posts: 108
Joined: Fri Nov 03, 2017 5:36 am
Answers: 2
Been thanked: 22 times
Contact:

Re: [Submission] Saver Tools - Loader from Saver and Saver Manager scripts

#12

Post by Movalex » Fri May 03, 2019 12:19 pm

I'm currently thinking about adding new script ( or a couple of them) to this Saver manager tool. But I need advice.

There's a cool script created a decade ago by Tim Little (and discussed here: viewtopic.php?p=5467#p5467)
It basically sets saver ranges as Blend keys for each saver. I added a couple of changes and would like to 'Reactorize' it. But now I have a concern if this approach really works.
It's said if the Saver's blend is 0 and set to be not processed, Fusion should not calculate anything in this case, and this can significantly speed up rendering of multiple savers. But when I tried this script on a comp with 5 savers, it seemed did not work, and Fusion still processed the frames on Savers with Blend 0.
Is it possible that this trick does not work any more in Fusion9, or am I doing something incorrectly?

  1. --[[
  2. -------------------------------------------------------------------------------------------------------------------------
  3. SaverRanges
  4.  
  5. this script animates the range in which the saver is active
  6.  
  7. it builds a list of all savers in the comp and let the user deside which should be active and in which range
  8. by default all savers are active (besides if the are in passthrough or not) and the renderange is the comp renderrange
  9.  
  10. v0.2.3 Use all or only selected savers - Alex Bogomolov
  11. v0.2.2 Fusion9 compatibility 3/4/2019 - Alex Bogomolov
  12. v0.2.1 01.09.2008
  13.     fixed bug for creating a keyframe at current time with blend = 0
  14. v0.2 inital release 27.03.2008
  15.     added setting of new renderrange in conjunction with ranges of savers
  16.     (min renderstart becomes renderrange start and max renderend becomes renderrange end)
  17.     added check if start < end
  18. v0.1 inital release 26.03.2008 by Tim Little
  19.  
  20. -------------------------------------------------------------------------------------------------------------------------
  21. --]]
  22.  
  23. fusion = Fusion()
  24. cmp = fusion:GetCurrentComp()
  25. all_savers = bmd.GetSavers(cmp)
  26.  
  27.  
  28. function if_selected(cmp)
  29.     sel_savers = cmp:GetToolList(true, 'Saver')
  30.     if #sel_savers > 0 then
  31.         print(#sel_savers .. ' savers selected')
  32.         return sel_savers
  33.     end
  34.     return all_savers
  35. end
  36.  
  37. function main(savers)
  38.     local attrs = cmp:GetAttrs()
  39.     local prefs = fusion:GetPrefs()
  40.  
  41.     local RenderStart = attrs.COMPN_RenderStartTime
  42.     local RenderEnd = attrs.COMPN_RenderEndTime
  43.     local GlobalStart = attrs.COMPN_GlobalStart
  44.  
  45.     local dialog = {}
  46.     local dialogcounter = 1
  47.     cmp:StartUndo("SaverRangesScript")
  48.  
  49.     for i, v in pairs(savers) do
  50.         dialog[dialogcounter] = {"process"..i, Name= "Process: "..v:GetAttrs().TOOLS_Name, "Checkbox", Default=1, NumAcross=2}
  51.         dialog[dialogcounter+1] = {"renderrange"..i, Name="RenderRange", "Position", Default = {RenderStart, RenderEnd} }
  52.         dialogcounter = dialogcounter + 2
  53.     end
  54.     dialog[dialogcounter+1] = {"",  "Text", Lines = 0, ReadOnly=true}
  55.     dialog[dialogcounter+2] = {"newrange", Name= "Set new renderrange?", "Checkbox", Default=1, NumAcross=2}
  56.  
  57.     ask = cmp:AskUser("Savers", dialog)
  58.  
  59.     if ask == nil then print("cancelled") return end
  60.  
  61.     local RenderEndNew = ask.renderrange1[2]
  62.     local RenderStartNew = ask.renderrange1[1]
  63.  
  64.  
  65.     for i, v in pairs(savers) do
  66.         local processVar = "process"..i
  67.         local renderrangeVar = "renderrange"..i
  68.         local start = ask[renderrangeVar][1]
  69.         local ende = ask[renderrangeVar][2]
  70.         if start > ende then
  71.             a = start
  72.             start = ende
  73.             ende = a
  74.         end
  75.         if ask[processVar] == 0 then
  76.             v:SetAttrs({TOOLB_PassThrough = true})
  77.         end
  78.         if ask[processVar] == 1 then
  79.             v:SetAttrs({TOOLB_PassThrough = false})
  80.             v.ProcessWhenBlendIs00 = 0
  81.             v:AddModifier('Blend', 'BezierSpline')
  82.             if ((attrs.COMPN_CurrentTime > start) and (attrs.COMPN_CurrentTime < ende)) then
  83.                 v.Blend[attrs.COMPN_CurrentTime] = 1
  84.             elseif attrs.COMPN_CurrentTime > ende then
  85.                 v.Blend[attrs.COMPN_CurrentTime] = 0
  86.             elseif attrs.COMPN_CurrentTime < start then
  87.                 v.Blend[attrs.COMPN_CurrentTime] = 0
  88.             end
  89.             v.Blend[start - 1] = 0
  90.             v.Blend[start] = 1
  91.             v.Blend[ende] = 1
  92.             v.Blend[ende+1] = 0
  93.             if ende > RenderEndNew then RenderEndNew = ende end
  94.             if start < RenderStartNew then RenderStartNew = start end
  95.         end
  96.     end
  97.     if ask.newrange == 1 then
  98.         cmp:SetAttrs({COMPN_RenderStart = RenderStartNew})
  99.         cmp:SetAttrs({COMPN_RenderEnd = RenderEndNew})
  100.     end
  101.     cmp:EndUndo(true)
  102. end
  103.  
  104. if #all_savers == 0 then
  105.     print('no savers in this comp')
  106. else
  107.     savers = if_selected(cmp)
  108.     main(savers)
  109. end
Attachments
AnimateSaverRanges.lua
(3.92 KiB) Not downloaded yet

User avatar
intelligent machine
Fusionista
Posts: 403
Joined: Fri May 13, 2016 10:01 pm
Answers: 2
Location: Austin, Texas, USA
Been thanked: 29 times
Contact:

Re: [Submission] Saver Tools - Loader from Saver and Saver Manager scripts

#13

Post by intelligent machine » Fri May 03, 2019 12:43 pm

I don't know about the saver trick but you can also put a dissolve right before the saver and key to 1 or 0 and feed in a simple background to the background (0) input.


User avatar
SecondMan
Site Admin
Posts: 3415
Joined: Thu Jul 31, 2014 5:31 pm
Answers: 3
Location: Vancouver, Canada
Been thanked: 78 times
Contact:

Re: [Update] Saver Tools - Loader from Saver and Saver Manager scripts

#14

Post by SecondMan » Sun Jun 23, 2019 11:20 am

Update to Saver tools available on Reactor now.
you can now convert any Saver node to a Saver Plus, which will now have Solo and Create Loader buttons. Later I will add Version UP/Down buttons there. Click on saver node and choose Script -- Tool -- Convert to saver plus
Also fixed the bug with Saver Manager which prevented to install the script on Mac