Skip to content

Development

34j edited this page Aug 25, 2022 · 33 revisions

Image Files To Fusion Composition

Strategy

There are two ways to create a fusion composition

  • Call the Fusion api.
  • Create the configuration file described below and import it.

Concerned by the lack of documentation for the fusion api, we decided to settle for the second method.

File format

DaVinci Resolve Fusion offers two ways to import/export node data. Both file formats can be opened in a text editor. The files are written in lua table format, and their contents are very similar, but the .settings file seems to be almost more "downward compatible".

  • .comp file

    This file contains information such as frames and animations and is specific to the project.

  • .settings file

    This file contains only node information and is suitable for use in multiple projects.

Thus, the .settings file is more consistent with our purpose. Note that .settings file can be imported by locating it to Edit folder and dragging it from ToolBox. A .settings file is usually written in the following format:

code
```lua
{
	Tools = ordered() {
		Group1 = GroupOperator {
			CtrlWZoom = false,
			Inputs = ordered() {
				Input1 = InstanceInput {
					SourceOp = "BrightnessContrast1",
					Source = "Input",
				}
			},
			Outputs = {
				Output1 = InstanceOutput {
					SourceOp = "Dissolve1",
					Source = "Output",
				}
			},
			ViewInfo = GroupInfo {
				Pos = { 897.666, 153.286 },
				Flags = {
					Expanded = true,
					AllowPan = false,
					AutoSnap = true,
					RemoveRouters = true
				},
				Size = { 298, 106.637, 149, 24.2424 },
				Direction = "Horizontal",
				PipeStyle = "Direct",
				Scale = 1,
				Offset = { -897.666, -153.286 }
			},
			Tools = ordered() {
				Dissolve1 = Dissolve {
					Transitions = {
						[0] = "DFTDissolve"
					},
					Inputs = {
						Mix = Input { Value = 0.9, },
						Background = Input {
							SourceOp = "Plasma1",
							Source = "Output",
						},
						Foreground = Input {
							SourceOp = "BrightnessContrast1",
							Source = "Output",
						},
					},
					ViewInfo = OperatorInfo { Pos = { 983.666, 167.983 } },
				},
				BrightnessContrast1 = BrightnessContrast {
					Inputs = {
						Input = Input {
							SourceOp = "MediaIn1",
							Source = "Output",
						},
					},
					ViewInfo = OperatorInfo { Pos = { 811.666, 202.195 } },
				},
				Plasma1 = Plasma {
					Inputs = {
						GlobalOut = Input { Value = 278, },
						Width = Input { Value = 1920, },
						Height = Input { Value = 1080, },
						UseFrameFormatSettings = Input { Value = 1, },
						["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
					},
					ViewInfo = OperatorInfo { Pos = { 857, 161.922 } },
				}
			},
		}
	}
}
```

This appears to be a bit cluttered. In fact, it is recommended to omit fields that are not needed in this way, as we have found that omitting some fields results in their default values. Note, however, that omitting ViewInfo will cause the nodes to be superimposed, which will reduce the ease of editing.

code
```lua
{
	Tools = ordered() {
		Group1 = GroupOperator {
			Inputs = ordered() {
				Input1 = InstanceInput {
					SourceOp = "BrightnessContrast1",
					Source = "Input",
				}
			},
			Outputs = {
				Output1 = InstanceOutput {
					SourceOp = "Dissolve1",
					Source = "Output",
				}
			},
			Tools = ordered() {
				Dissolve1 = Dissolve {
					Inputs = {
						Background = Input {
							SourceOp = "Plasma1",
							Source = "Output",
						},
						Foreground = Input {
							SourceOp = "BrightnessContrast1",
							Source = "Output",
						},
					},
				},
				BrightnessContrast1 = BrightnessContrast {
					Inputs = {
						Input = Input {
							SourceOp = "MediaIn1",
							Source = "Output",
						},
					},
				},
				Plasma1 = Plasma {
					Inputs = {
						Width = Input { Value = 1920, },
						Height = Input { Value = 1080, },
					},
				}
			},
		}
	}
}
```

Node structure

Strategy 1: Use expressions and merge

Expression is available only if you right-click on the label to bring up the menu and there is an item called "Expression". iif(expression, true_value, false_value)

  • Loader to load an image
Loader1 = Loader {
	Clips = {
		Clip {
			Filename = "(Filename)",
			FormatID = "PNGFormat",
		},
	},
},
  • Merge to merge images
Merge1 = Merge {
	Inputs = {
		Blend = Input { Expression = "iif( (Node).(Key) == 1, 1, 0)", },
		Background = Input {
			SourceOp = "(BackgroundSource)",
			Source = "Output",
		},
		Foreground = Input {
			SourceOp = "(ForegroundSource)",
			Source = "Output",
		},
	},
},
(Node) = (Any) {
	UserControls = ordered() {
		ComboBox1 = {
			LINKS_Name = "(Key(this name will be displayed))",
			LINKID_DataType = "Number",
			INPID_InputControl = "ComboControl",
			INP_Integer = true,
			INP_Default = 1,
			ICS_ControlPage = "User", 
			{ CCS_AddString = "option1" },
			{ CCS_AddString = "option2" },
			{ CCS_AddString = "option3" },
		},
		CheckBox1 = {
			LINKS_Name = "(Key(this name will be displayed))",
			LINKID_DataType = "Number",
			INPID_InputControl = "CheckboxControl",
			INP_Integer = true,
			INP_Default = 1,
			ICS_ControlPage = "User", 
		}
	}
}
  • GroupOperator or MacroOperator to gather all inputs. The difference between GroupOperator and MacroOperator seems to be whether the nodes inside can be edited from the editor or the inputs can be edited from the editor.
Root = (GroupOperator/MacroOperator) {
	Inputs = ordered() {
		Input1 = InstanceInput {
			SourceOp = "(Node)",
			Source = "(Key)",
		},
		Input2 = InstanceInput {
			SourceOp = "(Node)",
			Source = "(Key)",
			Default = 1,
		},
	},
	Outputs = { MainOutput1 = InstanceOutput {SourceOp = "", Source="Output"} },
	Tools = ordered() {},
}

Strategy 2: Generate compositions from scripts each time a combo box is edited

According to Fusion8_Scripting_Guide.pdf, Interactive Scripts, External Scripts, Events & Callbacks are the only script types that can edit inputs of compositions.

1. UI: UIManager, comp script
2. UI: Fusion Composition, button callbacks & events & comp script

In this case, UI cannot be dynamically changed, which may result in huge amount of comboboxes and checkboxes in some cases.

Psd To Png Files

psd2pngs (手前味噌)

> psd2pngs from.psd

ImageMagick

> convert from.psd -set filename:layers %l out-%[filename:layers].png

Problems (Critical)

  • Layer hierarchy is unknown
  • Encoding Problems
  • Cannot save a layer with a name that contains characters that cannot be used as a file name.

Lua

Code Style

luarocks

luarocks can be installed comparably easily by using

  • luarocks-*.*.*-win32.zip from here

To install packages which requires c compilation, below are also required

However, such packages (e.g. Lua File System, etc...) which requires compilation via luarocks do not work, probably because DaVinci Resolve does not use vanilla interpreter.

Encoding problems

use mediaStorage:GetFileList(folderPath) instead of io.popen("dir " .. folderPath .. "/b"):lines() to avoid encoding problems.

TTS

Software that unifies various TTS software products

Api references of TTS software products