Recent

Author Topic: [solved] TProcess: Parameters.Add leads to empty Commandline  (Read 4643 times)

Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Nothing happens when I use the following code. The legacy method works well. Did I miss something?

Code: [Select]
  with TProcess.Create(nil) do
  try
//    CommandLine:='ffmpeg -r 2 -i /tmp/img%d.png -r 25 test.mpg'; //works
    Executable:='/usr/bin/ffmpeg'; //ffmpek > "executable not found"
    Parameters.Add('-r 2');
    Parameters.Add('-i '+GetTempDir+'img%d.png');
    Parameters.Add('-r 25');
    Parameters.Add('test.mpg');
    ShowMessage(CommandLine);  //empty
    Execute;
  finally
    Free; //TProcess
  end; //no output, no error
« Last Edit: May 12, 2014, 10:46:46 pm by Ocye »
Lazarus 1.7 (SVN) FPC 3.0.0

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: TProcess: Parameters.Add leads to empty Commandline
« Reply #1 on: May 12, 2014, 06:53:05 pm »
well commandline is a one way road it gives params and executable to TProcess but it does not reconstruct it self from the existing params you would have known that if you simple took a fast look on the class your self.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Re: TProcess: Parameters.Add leads to empty Commandline
« Reply #2 on: May 12, 2014, 07:20:29 pm »
Thank you for reply. But actually my question is why Parameters.Add() don't work. I have no clue what happens (nothing) and expected a Commandline generated from Paramaters (of course, it's not imperative). But there is nothing. So what's wrong with the code snippet?
Lazarus 1.7 (SVN) FPC 3.0.0

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12262
  • FPC developer.
Re: TProcess: Parameters.Add leads to empty Commandline
« Reply #3 on: May 12, 2014, 08:36:24 pm »

    Parameters.Add('-r 2');
    Parameters.Add('-i '+GetTempDir+'img%d.png');
    Parameters.Add('-r 25');

These are wrong, use one .add add for each item   add('-r')  and add('2'); etc.
 

Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Re: TProcess: Parameters.Add leads to empty Commandline
« Reply #4 on: May 12, 2014, 10:46:35 pm »
These are wrong, use one .add add for each item   add('-r')  and add('2'); etc.
I thought a parameter consists of switch plus value, but apparently there is no whitespace allowed. Now it works. Thanks a lot!
Lazarus 1.7 (SVN) FPC 3.0.0

 

TinyPortal © 2005-2018