[Lazarus] Command line interpretation on Linux console program...

Bo Berglund bo.berglund at gmail.com
Thu Apr 11 22:03:55 CEST 2019


I have a project where I am creatinmg a video splitting utility using
FPC 3.0.4 and Lazarus 2.0.0 calling ffmpeg via RunCommandIndir()
defined in the Process library unit.

The project contains both a GUI and a command line version of the
utility, so all manipulation functions are contained in a separate
unit used by both versions and both Windows and Linux.
I have a strange problem with the command line utility...

When I try to debug it there are two different, but possibly related
problems:

1) When I enter a file name as ~/Videos/input.mp4 then FileExists()
reports that the file does not exist even though I can clearly see it.
If I instead use /home/user/Videos/input.mp4 then it will see it
properly. Same if I use the syntax ./filename.mp4 when the file is in
the current dir.
Why does FileExists() not recognize ~ as shorthand for the home dir?
It is rather inconvenient to be forced to use the longer paths...

2) Another issue concerns the parsing of command line parameters.
Originally I had set it up to use ; as separator for the two time
values of a clip, starttime and duration (in seconds) as follows:
t1234;500 for a duration 500 s clip starting at 1234 s into the source
video.
But for some reason the ParamCount variable contains 3 when the
command line looks like this:

videosplitcmb -x -iorg.mp4 -t0;1768 -t2420;2972 -otest4.mp4

There should really be 5 parameters: -t, -i, -t, -t, -o

Why is ; treated as some kind of block for the command line parsing?

I have had to temporarily replace ; with _ in order to test my
program...


-- 
Bo Berglund
Developer in Sweden



More information about the lazarus mailing list