Quick Start

NeroLINUX Advanced functions
35
the filename replaced by '$file'. Do not forget to include the quotation marks as
well. These are required in case the filename of your file contains spaces.
You must then parse the output of your program. Apart from a few mathematical
functions like abs, int, sqrt, sin, cos, tan and C-Style boolean operators,
NeroLINUX supports two powerful ways of retrieving your command line tool's
output:
getpos(y,x)
regexp('regular expression').
As the latter will always produce strings as its function result, you have to use the
strval('string') function to convert a string to a number. The basic idea of this
whole concept is that you can assemble the track length in Bytes from the output
generated by your external program using some mathematical function. For
example, if your command line tool will generate the following output if called with
tracksizetool -filename '$file':
Tracksizetool Version 1.03, Copyright 2001 by Arthur Dent
Playing time of file '/home/ghost/something.ext' is
00 Hours, 2 Minutes, 23 Seconds, 43 Frames
You can use the getpos() function to calculate the track size. To understand what
this function does,, imagine the output generated by tracksizetool as a grid of
numbers: getpos(3,1) will return '00' in our example. getpos(3,2) will return '2' and
getpos(3,3) will return '23'. Generally, getpos(y,x) will return the x-th number in
the y-th line of output. Consequently, we can get the number of frames with
getpos(3,4).
One frame is 1/75th of a second and 2354 Bytes of audio data. So if you know all
you need to know about our file now: the following function will resolve to our
track size in Bytes (for the 44.1kHz,16 Bit, Stereo stream required by
NeroLINUX):
((getpos(3,1)*3600+getpos(3,2)*60+getpos(3,3))*75+getpos(3,4))*2354
Enter this line into the last field of your file type registry entry and the process is
complete. On the other hand, not all command line tools will create output
parseable by the getpos(y,x) function. In this case, you need to use the regexp()
function. Suppose our output will look something like:
Tracksizetool Version 1.03, Copyright 2001 by Arthur Dent
Playing time of file '/home/ghost/some08minuteslongfile.ext' is 00:08:03.23
This is an example of a particularly awkard filename as it contains numbers as
well and will confuse getpos() when retrieving the different parts of our playing
time. So you use a regular expression for this. The result of the regexp('exp')
function is always the first part of the expression put into brackets, e.g.
regexp('.*:([0-9]*):.*') will return the minutes part of our playing time for the output
above as a string. Pass this through the strval() function and you have what you
want. For the example above, the track size calculation function will read
something like this:
((strval(regexp('.* is ([0-9]*):[0-9]*:[0-9]*.[0-9]*$'))*3600+strval(regexp('.* is [0-
9]*:([0-9]*):[0-9]*.[0-9]*$'))*60+strval(regexp('.* is [0-9]*:[0-9]*:([0-9]*).[0-
9]*$')))*75+strval(regexp('.* is [0-9]*:[0-9]*:[0-9]*.([0-9]*)$')))*2354