Table of Contents
Functions
All these functions will manipulate character strings to fit your needs. Functions can use into conditional node and populate variable node and keep the result in a variable.
There are 3 groups of functions :
- Other functions
Other Functions
$exists
- This is a file function that will tell if file(s) exists. Returns the amount of files found and and 0 if it there is no match. Support recursing and returning a file list in array.
Usage:
$exists(input string = “string/%variable%”)
$exists(“C:\Windows\explorer.exe”) 1
$exists(“C:\Windows\system32\win*”) 98
$exists("\\NAS\MOVIES\ORIGINAL\FILM1.MXF",1 ,1) \\NAS\MOVIES\ORIGINAL\FILM1.MXF
(First “,1” tell the function to output ONE file, which is the first match it can find. Second “,1” tells the function to look into subfolders.)
$exists("\\NAS\MOVIES\ORIGINAL\FILM*.MXF",2 ,1) [“\\NAS\\MOVIES\\ORIGINAL\\FILM1.MXF”,“\\NAS\\MOVIES\\ORIGINAL\\FILM2.MXF”,“\\NAS\\MOVIES\\ORIGINAL\\FILM3.MXF”]
“,2” tells the function to return an array (list) of matches.
“,3” tells the function to return a basic string list of files separated with an <enter>.
$base64
- Encodes the input UTF-8 string as terminated base64 string.
Usage:
$base64(input string =“string/%variable%”)
$base64(“FFAStrans”)= RkZBU3RyYW5z
$base64dec
- Decodes the input base 64 encoded string to a UTF-8 string.
Usage :
$base64dec(input string =“string/%variable%”)
$base64dec(“RkZBU3RyYW5z”) FFAStrans
$jsonencode, $jsonget and $jsonput
- $jsonencode : Converts the input string to an JSON friendly string.
- $jsonget : Retrieves the value from a JSON object key. The first argumenst accept a string or a variable representing a valid JSON string. In the second section you refer to the object/key/array you want to get.
- $jsonput : Puts a value to a JSON object. The first arguments accept a string or a variable representing a valid JSON string. If and empty string is used FFAStrans will create a new json object. The second argument refer to the object/key/array you want put the value. Third argument is the value to put in the json object. Note that this parameter will return the new updated or created json string object.
Understanding FFAStrans JSON functions :
Usages:
$jsonencode(input string = “string/%variable%”)
$jsonget(input string = “string/%variable%”[, input string = “string/%variable%”])
$jsonput(input string =“string/%variable%”, input string = “string/%variable%”, input string = “string/%variable%”)
$jsonencode(“D:\My\Media\folder”) D:\\My\\Media\\folder
$jsonencode('Hello “World”') Hello \“World\”
$jsonget('{“things”:{“myStuff”:“some other stuff”}}', “things.myStuff”) some other stuff
jsonget Usage Example to retrieve values from ffprobe:
$jsonget('%s_info_ffprobe%', 'streams[1].format_name') mov,mp4,m4a,3gp,3g2,mj2
You can use online tools to generate the selection string (streams[1].format_name) like this: http://jsonpathfinder.com/ Best Practice is to use a Write File Processor and write %s_info_ffprobe% to a file. This gives you the full JSON structure of your file. You can use the resulting JSON in above mentioned online tools.
$readarray
- Returns an instance from a valid array which must be in the form of “[“data”, data, etc…]”. All JSON formated data is valid. By default the function will return the first instance. If none is found it will return an empty string: “”.
This can be used in combination with another processor which generates JSON on output, for example loudness filter or in combination again with a HTTP Get processor that receives JSON data from a 3rdparty API.
Usage:
$readarray(input string = “string/%variable%”[, input integer = integer/%variable%])
$readarray(“[23, 55.5, 19]”, 2) 55.5
$readarray('[“make”, “my”, “day”]', 3) day
$regext
- This is regular expression function. It extracts text based on recognition patterns. It uses the Perl Compatible Regular Expressions (PCRE) engine. http://www.pcre.org/
Usage :
$regext(input string = “string/%variable%”, pattern = “string/%variable%”)
$regext(“<Duration value=“1214”/>”, “<Duration value=”(\d+)“/>”) 1214
$regext(“TVShow_EP0013.mxf”, “/(EP\d{4})/”) EP0013
$hex and $dec
- $hex : Converts a decimal integer to hexadecimal number.
- $dec : Converts a hexadecimal number to decimal integer. Function accepts both quoted and unquoted input.
Usages :
$hex(input integer = integer/%variable%)
$dec(input string/integer = “string”/integer/%variable%)
$hex(8) 8 $hex(15) f
$dec(8) 8 $dec(“f”) 15
$guid
- Returns a random GUID/UUID.
Usage :
$guid()
$guid() bc067580-f7de-4e12-9f84-7e905bd60378
$xxhash
- Returns an eight character hash for any file. Must include full path. The hash is created using Yann Collet's xxHash which is very fast and suits large video files.
Usage :
$xxhash(input string = “string/%variable%”)
$xxhash(“x:\path\to\file.mxf”) 61abf926
$read
- Reads the contents of any file. Function supports all kinds of files, not just text based.
Usage :
$read(input string = “string/%variable%”)
$read(“metadata.xml”)
$urlencode
- Converts the input string to an URL friendly string.
Usage :
$urlencode(input string = “string/%variable%”)
$urlencode(“FFAStrans is #supercool!”) FFAStrans%20is%20%23supercool!
$week
- Returns the week number from the date specified in the parameters. If no date is specified, the function returns the current week number.
Usage :
$week([input number=YEAR/“%variable%”, input number=MONTH/“%variable%”, input number=MONTH DAY/“%variable%”])
$week(2020, 10, 15) 42
$weekday
- Returns the week day number from the date specified in the parameters. If no date is specified, the function returns the current week day number.
Usage :
$weekday([input number=YEAR/“%variable%”, input number=MONTH/“%variable%”, input number=MONTH DAY/“%variable%”])
$weekday(2020, 10, 15) 5
$lookup
- Loopup table for mapping data to other data. The function will only operate on array formated strings.
Usage :
$lookup(input array =“REFERENCE/%variable%”, inputarray =“TABLE/%variable%”, input string =“SEARCH/%variable%”)
$lookup('[“joe”, “bill”, “greg”]', '[“lucy”, “evy”, “jane”]', “evy”) bill
$lookuprep
- Loopup table for replacing strings with strings from lookup tables.
Usage :
$lookuprep(input array =“REFERENCE/%variable%”, input array =“TABLE/%variable%”, input string =“SEARCH/%variable%”)
$lookuprep('[“joe”, “bill”, “greg”]', '[“lucy”, “evy”, “jane”]', “lucylindajane”) joelindagreg
$foreach
- This function will iterate and perform the desired operation on each data value. The result of each iteration will be put back into the array and presented as the new resulting array. Please note that the special keyword “%$%” represents unique data value of each iteration. The special keyword “%i%” represents each iteration number.
Usage :
$foreach(input string =“string/%variable%”, input string =“OPERATION/%variable%”)
$foreach('[“jack”, “joe”, “jill”, “jane”, “james”, “jules”]', '$triml(“%$%”, 2)') [“ck”, “e”, “ll”, “ne”, “mes”, “les”]
$foreach('[“jack”, “joe”, “jill”, “jane”, “james”, “jules”]', '%i% - %$%') [“1 - jack”, “2 - joe”, “3 - jill”, “4 - jane”, “5 - james”, “6 - jules”]
$foreach('[10, 11, 12, 10, 20, -6]', '%$%-%i%') [9, 9, 9, 6, 15, -12]
$sort
- Sorts an array formated string or a regular string. String sorting use crlf as base separator but a custom separator can be specified.
Usage :
$sort(input string/array =“string/%variable%”[, input string =“SEPARATOR/%variable%”])
$sort(“[6,2,4,3,5]”) [2,3,4,5,6]
$sort('[“jack”, “joe”, “jill”, “jane”, “james”, “jules”]') [“jack”, “james”, “jane”, “jill”, “joe”, “jules”]
$stringf
- This function works very much like the printf() function in C. It shares the same notation. The difference is that if you have multiple arguments you need to put them in an array.
Usage :
$stringf(input string =“string/%variable%”, input data/array =“ARGUMENTS/%variable%”)
$stringf('%05d', 12) 00012
$stringf('%02i\%02i\%04i', '[1,8,2021]') 01\08\2021
$fsize
- Get file size in bytes.
Usage :
$fsize(input string =“string/%variable%”)
$fsize(“D:\Replace spaces in filename”) 57162
$fext
- Get file extension.
Usage :
$fext(input string =“string/%variable%”)
$fext(“D:\Replace spaces in filename.mp4”) mp4
$fname
- Get file name.
Usage :
$fname(input string =“string/%variable%”)
$fname(“D:\my_file.mxf”) my_file
$fpath
- Get file path.
Usage :
$fpath(input string =“string/%variable%”)
$fpath(“D:\cool folder\right_here\my_file.mxf”) D:\cool folder\right_here
$fdrive
- Get drive path.
Usage :
$fdrive(input string =“string/%variable%”)
$fdrive(“D:\cool folder\right_here\my_file.mxf”) D:
$asplit
- Splits an array string into a delimited string using the optional separator. Default separator is \r\n (carriage return and line feed).
Usage :
$asplit(input string/array =“string/%variable%”[, input string =“SEPARATOR/%variable%”])
$asplit(“[6,2,4,3,5]”, “|”) 6|2|3|4|5
$asplit('[“jack”, “joe”, “jill”, “jane”, “james”, “jules”]')
jack
joe
jill
jane
james
jules
$ffconcat
- Creates a ffconcat version 1.0 compatible string for use with encoder input.
Usage :
$ffconcat(input string/array =“string/%variable%”)
$ffconcat('[“c:\myClips\video1.mov”, “c:\myClips\video1.mov”, “c:\myClips\video3.mov”]')
ffconcat version 1.0
file 'c:\myClips\video1.mov'
file 'c:\myClips\video2.mov'
file 'c:\myClips\video3.mov'
$owner
- Find the domain owner of a file.
Usage :
$owner(input string =“string/%variable%”)
$owner(“D:\cool folder\right_here\my_file.mxf”) domain/ElonMusk
$waccess
- Check if user running the ffastrans system has write access to the specified folder.
Usage :
$waccess(input string =“string/%variable%”)
$waccess(“D:\cool folder\right_here”) 1
$dateweek
- Finds the date (year_month_mday) of any given year, week number, week day number and week start day.
Usage :
dateweek(input integer = integer/%variable%[, input integer = integer/%variable%, input integer = integer/%variable%, input string =“string/%variable%”])
(find date of week no. 35, the second day of the week starting on monday) $dateweek(1973, 35, 2, 'mon') 1973_08_28
$timecalc
- Calculates a new date/time by adding/subtracting a specified number of time intervals from an initial date/time.
y = year, M = month, d = day, w = week, h = hour, m = minute, s = second
Usage :
$timecalc(input integer = integer/%variable%[, input integer = integer/%variable%, input integer = integer/%variable%, input string =“string/%variable%”])
(add 60 days) $timecalc('d', 60, '2019/11/24') 2020_01_23
(add 3 hours) $timecalc('h', 3, '2019/11/24 22:35:00') 2019_11_25 01:35:00
$shortcut
- Parse the shortcut (Windows) or alias (MAC) and return the actual file path.
Usage :
$shortcut(input string =“string/%variable%”)
$shortcut(“c:\users\myname\desktop\cool video.mkv - Shortcut.lnk”) \\server\some_share\projects\REALITY_SHOW\my video files\cool video.mkv