Skip to content

Commit d5e7369

Browse files
author
John Andrews
committed
docs
1 parent 171f4bb commit d5e7369

33 files changed

+363
-184
lines changed

docs/Plugins/BasicNodes/Basic-Nodes.md

Lines changed: 0 additions & 28 deletions
This file was deleted.

docs/Plugins/BasicNodes/Function-Node.md

Lines changed: 0 additions & 137 deletions
This file was deleted.

docs/Plugins/VideoNodes/Video-Encode.md

Lines changed: 0 additions & 12 deletions
This file was deleted.

docs/Plugins/VideoNodes/Video-Nodes.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

docs/_includes/sidebar.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
<div class="side-bar">
2+
<div class="pages">
3+
{% for page in site.pages %}
4+
{% endfor %}
5+
</div>
26
<div class="plugins">
37
{% for plugin in site.plugins %}
8+
{% if plugin.sub and plugin.sub != current_sub %}
9+
<ul>
10+
{% elsif !plugin.sub and current_sub %}
11+
</ul>
12+
{% assign current_sub = '' %}
13+
{% endif %}
14+
415
{% if plugin.plugin %}
516
<li>
617
<a href="/plugins/{{ plugin.plugin | replace: " ", "" }}/nodes/{{ plugin.name | replace: " ", "" }}">{{ plugin.name }}</a>
@@ -14,6 +25,10 @@
1425
{% assign current_plugin = plugin.name %}
1526
{% endif %}
1627
{% endfor %}
28+
29+
{% if current_sub %}
30+
</ul>
31+
{% endif %}
1732
{% if current_plugin %}
1833
</ul>
1934
{% endif %}

docs/_plugins/BasicNodes/index.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,31 @@ layout: default
44
description: Index file for Basic nodes that provide the basic functionality to FileFlows
55
---
66

7-
These are basic file processing nodes
7+
Basic Nodes are core nodes and provide basic functionality to a flow
8+
9+
Including
10+
* Input File
11+
* A basic input file node which is a starting point of a flow
12+
* Copy File
13+
* Copies a file to another location
14+
* Delete Source Directory
15+
* Deletes the source directory of the file being processed. Include options to only delete if empty
16+
* Move File
17+
* Moves a file to another location
18+
* File Extension
19+
* Logical node that can test if a file has a particular extension
20+
* File Size
21+
* Logical node that cant test if a file is a certain file size
22+
* Function
23+
* A node that lets the user provide their own logic to test. This is a javascript code block
24+
* Log
25+
* Lets you log a message to the flow log
26+
* Pattern Match
27+
* Logical node that tests the working file and the original file against a regular expression. Uses a c# regular expression.
28+
* Pattern Renamer
29+
* Logical node that will replace text in the filename with using regular expressions or basic strings. You can specify multiple patterns to replace. For example
30+
![image](https://user-images.githubusercontent.com/958400/143516676-9a41524d-bcef-4430-9745-34c9ebf45ac9.png)
31+
* Renamer
32+
* Logical node that will rename the file. Can use variables using the '{' key to use variables from other nodes and also common variables.
33+
* Replace Original
34+
* Logical node that will replace the original file of the flow with the current working file. If the current working file has a different extension than the original, the working extension will be used, eg "MyFile.avi" will become "MyFile.mkv"

docs/_plugins/BasicNodes/nodes/Function.md

Lines changed: 137 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,140 @@ description: Node that executes javascript functions
55
plugin: Basic Nodes
66
---
77

8-
This a test function thing
8+
The function node allows you to use custom javascript code to process within the flow.
9+
10+
It can let you make decision paths based on previous nodes, compute variables for future nodes, log information, and many more features.
11+
12+
## Return codes
13+
* Return 1+ to specify which output is to be called. Define the number of outputs using the "Outputs" fields. This will add more output connections to the node
14+
* Return 0 to complete the flow successfully. This will immediately stop the flow and mark it as successful
15+
* Return -1 to indicate an error and stop the flow. This will mark the flow as unsuccessful.
16+
17+
## Variables
18+
It includes the "Variables" object which exposes variables from the flow. And you can set future variables for the flow in here
19+
20+
```js
21+
Varabiles.MyFutureVariable = 'to be used in another flow node';
22+
23+
// an example of variables from a 'Video Input' node
24+
let video = Variables.vi.VideoInfo.VideoStreams[0];
25+
// or a safe way to get that incase any of those objects are null
26+
let video = Variables.vi?.VideoInfo?.VideoStreams[0];
27+
if(!video) return -1; // video was null
28+
```
29+
30+
31+
## Logging
32+
The "Log" object lets you log messages to the flow log
33+
```js
34+
Logger.ILog('an information log message');
35+
Logger.WLog('an warning log message');
36+
Logger.ELog('an error log message');
37+
Logger.DLog('an debug log message');
38+
```
39+
40+
## Flow object
41+
The "Flow" object lets you perform actions on the flow, it exposes helper methods to the code.
42+
```js
43+
// will create a directory if it does not already exist
44+
// if it does exist this function simply returns
45+
// its a safe way to ensure a directory exists
46+
Flow.CreateDirectoryIfNotExists(path);
47+
48+
// return the size in bytes as a number
49+
Flow.GetDirectorySize(path);
50+
51+
// gest/sets a parameter value with a given key
52+
Flow.SetParameter(key, value);
53+
Flow.GetParameter(key);
54+
55+
// maps a path to the local processing node
56+
Flow.MapPath(path);
57+
58+
// moves the working file to the destination file
59+
Flow.MoveFile(destination);
60+
61+
// this will reset the working file to the original File,
62+
// this lets you effectively reprocess the original file.
63+
// Useful if you want to perform multiple operations on the same file
64+
Flow.ResetWorkingFile();
65+
66+
// Sets the current working file to the file passed in
67+
// dont delete is a boolean that if true will not delete the current working file
68+
// note: if the current working file is the original file, it will NEVER be deleted
69+
Flow.SetWorkingFile(filename, dontDelete);
70+
71+
// returns a new GUID as string
72+
Flow.NewGuid();
73+
74+
// the temporary path, property NOT a function
75+
Flow.TempPath
76+
77+
// Get a toolpath from the toolname, the toolname is case insensitive
78+
Flow.GetToolPath(toolname);
79+
80+
// Execute a process and capture the output
81+
// you can use arguments for a string argument list, or argumentList which is an string array and will escape the arguments for you correctly
82+
// timeout is optional, number of seconds to wait before killing the process
83+
// returns ProcessResults
84+
// Completed:bool; // if the process ran to completion or timedout/was canceled
85+
// ExitCode:number; // the exit code of the process, may be null
86+
// Output:string; // the output, if error output was detected this will contain that output
87+
// StandardOutput: string; // the standard output from the process
88+
// StandardError: string; // the standard error from the process if any
89+
Flow.Execute({command:'somecommand.exe', arguments: '-a -b -c', argumentList: ['can', 'use', 'instead of arguments'], timeout: 0, workingDirectory: 'optional'});
90+
```
91+
92+
93+
## Samples
94+
95+
Different outputs based on file size
96+
```js
97+
if(Variables.file.Size > 10_000_000_000) // 10GB
98+
return 1; // output 1
99+
if(Variables.file.Size > 2_000_000_000) // 2GB
100+
return 2; // output 2
101+
102+
let reducedSize = (Variables.file.Size / Variables.file.Orig.Size) * 100;
103+
if(reducedSize < 10)
104+
return 0; // its too small, something went wrong
105+
106+
return 3; // output 3
107+
```
108+
109+
Example showing using the Flow.Execute
110+
```js
111+
// define the output file, in the temp directory with a guid as the name
112+
let output = Flow.TempPath + '/' + Flow.NewGuid() + '.mkv';
113+
// get the ffmpeg tool path
114+
let ffmpeg = Flow.GetToolPath('ffmpeg');
115+
// execute the process and capture the result
116+
let process = Flow.Execute({
117+
command: ffmpeg,
118+
argumentList: [
119+
'-i',
120+
Variables.file.FullName,
121+
'-c:v',
122+
'libx265',
123+
'-c:a',
124+
'copy',
125+
output
126+
]
127+
});
128+
129+
// log the standard output/error if found
130+
if(process.standardOutput)
131+
Logger.ILog('Standard output: ' + process.standardOutput);
132+
if(process.starndardError)
133+
Logger.ILog('Standard error: ' + process.starndardError);
134+
135+
// check the exit code of the process
136+
if(process.exitCode !== 0){
137+
Logger.ELog('Failed processing ffmpeg: ' + process.exitCode);
138+
return -1;
139+
}
140+
141+
// update the working file to the newly created file from ffmpeg
142+
Flow.SetWorkingFile(output);
143+
return 1;
144+
```

0 commit comments

Comments
 (0)