User Tools

Site Tools


functions:other_functions

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 :

  1. 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.

Usage:
$exists(input string = “string/%variable%”)

$exists(“C:\Windows\explorer.exe”) 1

$exists(“C:\Windows\system32\win*”) 98


$base64

TODO: seems to be broke currently


$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.
That this does not produce any JSON data structure but one can use the result as a “Value” in a JSON data structure. This can be used in order to produce a JSON string for further automatic processing, e.g. send a POST request to some 3rdparty API using the HTTP Request processor. Or to write a JSON File using the Write File processor.
  • $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!


                                                                                                          Back to top

functions/other_functions.txt · Last modified: 2021/03/05 14:18 by benjamin