How can i get the output to my TMemo lazarus / 21-General ---------------------------------------------------------------------- mathias63 · 2025-09-01 15:19 Hello again i did some code to open up my rtsp stream with ffplay after a button click, that now works good, but i would allso like to have the output written in a tmemo, to read eventually errors when connecting to it. So this is my code so far in a click button event: RunProgram := TProcess.Create(nil); RunProgram.CommandLine := ('/bin/ffplay -rtsp_transport tcp -i rtsp://myuser:mypass@192.168.0.50:554'); RunProgram.Execute; RunProgram.Free; I have tried some examples that i found on internet, but i dont really get any output, and the app freezes. If some one could tell me i would be happy... /Mathias ---------------------------------------------------------------------- jamie · 2025-09-01 18:09 you need to run the code within a TTHREAD object so you can sit there without locking up the rest of your code. ---------------------------------------------------------------------- mathias63 · 2025-09-01 18:28 Quote from: jamie on September 01, 2025, 08:09:40 pmyou need to run the code within a TTHREAD object so you can sit there without locking up the rest of your code. Thanks for your answer. I have no clue how or what threads does then, i only made some apps long ago in delphi (maybe 20 years ago). But now try using linux and Lazarus. But will try google it and see if i can understand how to do this. ---------------------------------------------------------------------- jamie · 2025-09-01 18:34 https://www.sigmdel.ca/michel/program/fpl/yweather/process_thread_en.h tml Look there, scroll down. Jamie ---------------------------------------------------------------------- n7800 · 2025-09-01 20:01 See also: https://wiki.freepascal.org/Executing_External_Programs#Read ing_large_output ---------------------------------------------------------------------- mathias63 · 2025-09-01 21:18 Thanks for tips but still feels a bit hard to understand what i need to do ....if i just could download the most simple project with a form, a Tmemo, and button that starts another app and write the output in a TMemo or similar would help so i can just try change some code for my needs. ---------------------------------------------------------------------- mathias63 · 2025-09-01 22:17 Quote from: n7800 on September 01, 2025, 10:01:00 pmSee also: https:// wiki.freepascal.org/Executing_External_Programs#Reading_large_output I was trying this on a new project, but now i have no clue how do i get the output to the TMemo? ---------------------------------------------------------------------- egsuh · 2025-09-02 02:33 Instead of      with TStringList.Create do LoadfromStream in following, Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   // Or the data can be shown on screen  with TStringList.Create do  begin    OutputStream.Position := 0; // Required to make sure all data is copied from the start    LoadFromStream(OutputStream);    writeln(Text);    writeln('--- Number of lines = ', Count, '----');  Free  end; something like this:     OutputStream.Position := 0;     Memo1.Lines.LoadFromStream(OutputStream); ---------------------------------------------------------------------- Thausand · 2025-09-02 08:00 Quote from: mathias63 on September 01, 2025, 05:19:02 pmI have tried some examples that i found on internet, but i dont really get any output, and the app freezes. Example make wrong use TProcess options (https://www.freepascal.org/docs- html/fcl/process/tprocess.commandline.html read deprecate is for Linux because no work). Make use parameters https://www.freepascal.org/docs- html/fcl/process/tprocess.parameters.html QuoteIf some one could tell me i would be happy... Quote from: mathias63 on September 01, 2025, 11:18:42 pmThanks for tips but still feels a bit hard to understand what i need to do ....if i just could download the most simple project with a form, a Tmemo, and button that starts another app and write the output in a TMemo or similar would help so i can just try change some code for my needs. Is no simple answer, you see when get there but can make very simple example. Quote from: egsuh on September 02, 2025, 04:33:19 amsomething like this: No work for ffplay output because output have many begin of line rewrite. Is continue output until finish (or error). Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$mode objfpc}{$h+}uses  cthreads, sysutils, sockets, ctypes, process, pipes; // is idea not mefunction GetLocalIPString: string;const  GDNS_ADDR = '127.0.0.1';  GDNS_PORT = 53;var  sockErr  : cint    = 0;  fail     : boolean = false;  socket   : cint;  IPAddr   : TInetSockAddr;  HostAddr : TSockAddr;  namelen  : cuint32;begin  result := '';   socket := fpsocket(AF_INET, SOCK_DGRAM, 0);  fail := (socket = -1);   if not fail then  begin    IPAddr.sin_family      := AF_INET;    IPAddr.sin_port        := htons(GDNS_PORT);    IPAddr.sin_addr.s_addr := StrToHostAddr(GDNS_ADDR).s_addr;     fail := (fpConnect(socket,@IPAddr,SizeOf(IPAddr)) <> 0);    if not fail then  begin      namelen := SizeOf(HostAddr);      fail := (fpgetsockname(socket, @HostAddr, @namelen) <> 0);      if not fail then      begin        result := NetAddrToStr(HostAddr.sin_addr);      exit;      end;    end  end;   if fail then  begin    // have error raise    sockerr := socketError;    writeln('error local get IP- Address: ', sockerr);    halt(255);  end;end; procedure Log(S: string);begin  writeln(S);  // or write memo(.lines)end; procedure Log(S: string; const A: array of const);begin  Log(Format(S, A));end; procedure RunFFPlay;var  LocalIP    : string;  FFPlayProc : TProcess;  Answer     : string;  Count      : LongInt;begin  localIP:= GetLocalIPString;  Log('IP-Address = %s',[LocalIP]);   FFPlayProc:= TProcess.Create(nil);  try    FFPlayProc.Executable:= 'ffplay';    FFPlayProc.Parameters.Add('-i');    FFPlayProc.Parameters.Add('rtsp://' + localIP + ':8090/live');     FFPlayProc.Options:=[poUsePipes, poStderrToOutPut];    FFPlayProc.Execute;     // have output FFPlay    Log('start FFPlay loop');    while FFPlayProc.Running or (FFPlayProc.Output.NumBytesAvailable>0) do    begin      if FFPlayProc.Output.NumBytesAvailable>0 then      begin        Count:= FFPlayProc.Output.NumBytesAvailable;        SetLength(Answer,Count);         Count:= FFPlayProc.Output.Read(Answer[1],Count);        Log(Answer);        Sleep(1);        // can have stop while boolean    end;    end;    Log('stop FFPlay loop');  finally    FFPlayProc.Free;  end;end; .... RunFFPlay;..  If want GUI work then make RunFFPlay in TProcess of own. ---------------------------------------------------------------------- Thaddy · 2025-09-02 10:32 Quote from: jamie on September 01, 2025, 08:09:40 pmyou need to run the code within a TTHREAD object so you can sit there without locking up the rest of your code. Or use TProcessAsync. ---------------------------------------------------------------------- marcov · 2025-09-02 11:33 See https://forum.lazarus.freepascal.org/index.php?topic=62855.0 ---------------------------------------------------------------------- mathias63 · 2025-09-02 19:57 Thanks for answers...takes some time for me to get used to lazarus, will see if i can fix this in the future. ---------------------------------------------------------------------- mathias63 · 2025-09-02 20:54 Thanks Thausand! i  will try that code tomorrow and see if it works ---------------------------------------------------------------------- Thausand · 2025-09-03 01:13 Quote from: mathias63 on September 02, 2025, 10:54:03 pmThanks Thausand! i  will try that code tomorrow and see if it works Make note and change parameters for ffplay because example use parameters for work my configuration. Link marcov also good because example make process output and store in memo. ---------------------------------------------------------------------- Jurassic Pork · 2025-09-03 21:33 hello, have a look here The example project use TprocessEx  from processutils unit of the fpcupdeluxe project  and displays output in a Tmemo from a command line in RealTime. Friendly, J.P ---------------------------------------------------------------------- Thausand · 2025-09-05 03:59 Quote from: Jurassic Pork on September 03, 2025, 11:33:59 pmhello, have a look here The example project use TprocessEx  from processutils unit of the fpcupdeluxe project  and displays output in a Tmemo from a command line in RealTime. Friendly, J.P Hello Jurassic Pork, That look interrest so I make look. I have download https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/tag/v2.4.0f and look processutils then I confuse because not read TprocessEx inside. Can please make verificate if I blind or TprocessEx no exist ? Thank you advance. @mathias63 When have read link marcov then have good see memo write not same terminal write and make implement process write memo have emulate terminal. That is why write before no easy and see when have simple example work first. Memo string confuse output normal and need work (but see self first what and why). ---------------------------------------------------------------------- Jurassic Pork · 2025-09-05 05:32 Quote from: Thausand on September 05, 2025, 05:59:14 amThat look interrest so I make look. I have download https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/tag/v2.4.0f and look processutils then I confuse because not read TprocessEx inside. Can please make verificate if I blind or TprocessEx no exist ? Thank you advance. Hello Thausand, it seems that TProcessEx class has gone from the processutils.pas  since April 2020. The last processutils.pas file with TProcessEx class is here In my project, i use a processutils.pas older than this one (2018) if you want to know the reason why TProcessEx has gone, ask the question to DonAlfredo in the forum ThirdParty/fpcupdeluxe Friendly, J.P ---------------------------------------------------------------------- marcov · 2025-09-05 14:00 Quote from: Jurassic Pork on September 05, 2025, 07:32:43 amif you want to know the reason why TProcessEx has gone, ask the question to DonAlfredo in the forum ThirdParty/fpcupdeluxe Probably it was no longer needed since 3.2.0 and later have an improved TProcess that can do similar things. ---------------------------------------------------------------------- Thausand · 2025-09-05 16:25 Quote from: Jurassic Pork on September 05, 2025, 07:32:43 amHello Thausand, it seems that TProcessEx class has gone from the processutils.pas  since April 2020. The last processutils.pas file with TProcessEx class is here In my project, i use a processutils.pas older than this one (2018) Ok, thank much for explain Jurassic Pork. I get why is missing and me no blind is joy  Quoteif you want to know the reason why TProcessEx has gone, ask the question to DonAlfredo in the forum ThirdParty/fpcupdeluxe Not real important and know why. Program make evolve and change. I Think I try last version for improve/upgrade code then there nothing. Now I try with you attachment. Very many thank. ---------------------------------------------------------------------- avra · 2025-09-07 14:06 If you have some long running process and want live output to TMemo: https://bitbucket.org/avra/ct2laz/src/28d3e2a51140104fd68f07fc23da59ff 740ba299/utils.pas?at=master#utils.pas-307