Recent

Author Topic: RunCommandIndir passes commandline parameters with quotes. How to manage?  (Read 3970 times)

anna

  • Sr. Member
  • ****
  • Posts: 426
I need to run ffplay.exe [https://www.videohelp.com/software?d=ffmpeg-3.0-win32-static.7z].
I code something like this:
Code: [Select]
RunCommandIndir('I:\170724190300_ffplay_euronews\bin',I:\170724190300_ffplay_euronews\bin\ffplay.exe,['-i '+ 'http://euronews-ru-p9-cdn.hexaglobe.net/b0cdf3de7985b6e1e0a829499e4bdbae/5977a4f4/euronews/euronews-euronews-website-web-responsive-2/ewnsabrrupri_rus.smil/ewnsabrrupri_rus_540p.m3u8', outputstring_ );
 

In debugger I see CreateProcessA with variable CommandLine which contains quote before -i and at the end of the line. This gives an error. If I break on CreateProcessA and replace 22 (quote) on 20 (space) , ffplay.exe starts and plays video but with black command line window.
« Last Edit: July 25, 2017, 10:28:02 pm by anna »
WinXP SP3 Pro Russian 32-bit (5.1.2600)

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Maybe:
Code: [Select]
RunCommandIndir('I:\170724190300_ffplay_euronews\bin',I:\170724190300_ffplay_euronews\bin\ffplay.exe,['-i ', 'http://euronews-ru-p9-cdn.hexaglobe.net/b0cdf3de7985b6e1e0a829499e4bdbae/5977a4f4/euronews/euronews-euronews-website-web-responsive-2/ewnsabrrupri_rus.smil/ewnsabrrupri_rus_540p.m3u8'], outputstring_ );

(just separate the parameters with a comma, don't join them yourselve)

Sorry, cannot test myself, don't have a Windows computer currently.

Bart

anna

  • Sr. Member
  • ****
  • Posts: 426
Thank you. Yes, commandline parameters separated by comma  are passed without quotes. But console window is still empty. When I run ffplay.exe due to bat-file there is some data in console window:
WinXP SP3 Pro Russian 32-bit (5.1.2600)

anna

  • Sr. Member
  • ****
  • Posts: 426
It seems RunCommandIndir waits until the external application is closed. How to force it to return before termination of the external applicaiton?
WinXP SP3 Pro Russian 32-bit (5.1.2600)

molly

  • Hero Member
  • *****
  • Posts: 2330
Not sure if you also wish for your ffplay process to run after your own program finished.

In that case you could perhaps have a look at the run detached example in the wiki.

anna

  • Sr. Member
  • ****
  • Posts: 426
I have replaced RunCommandIndir by WinAPI CreateProcessA. RunCommandIndir is useless and hard to understand . I needed start external application (with its own current dir) and immediately return, then close my application leaving the external  working.

Moreover, it seems RunCommandIndir directs output data to outputstring variable, so the ffplay's console window is empty.
« Last Edit: July 26, 2017, 07:18:25 am by anna »
WinXP SP3 Pro Russian 32-bit (5.1.2600)

Cyrax

  • Hero Member
  • *****
  • Posts: 836
Use TProcess class to run your programs and capture their outputs.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11452
  • FPC developer.
I have replaced RunCommandIndir by WinAPI CreateProcessA. RunCommandIndir is useless and hard to understand . I needed start external application (with its own current dir) and immediately return, then close my application leaving the external  working.

Runcommand* are simplified usage scenarios of TProcess condensed as easy to use functions.  TProcess is a CreateProcess + pipes wrapper (on Windows)
 

 

TinyPortal © 2005-2018