simple real-time logging ffmpeg with Tprocess - example lazarus / 21-General ---------------------------------------------------------------------- john60 · 2023-05-23 15:48 Maybe this will help someone - just my take on it: using lazarus 2.2.0 - FPC 3.2.2   Standard Tprocess I have this integrated into my toolkit and it runs fine there Even using the Line filterFFMPEGoutput(outStr) which does some filtering on the log output before display into synEdit - speed is no different to running in a dos batch file and no windoze locking up (hints and buttons etc)  all work fine. Using Nvenc I get 10x speed when re-compressing video Using x264 about 2.4x Setting Tprocess to realtime or high makes no difference - I expect ffmpeg is running at lower speed than my system or whatever. The abort stuff can be ignored as can the filer line (Just send 'output' to your destination there.) I didn't get on well with TAsyncProcess - and didn't see the need for memory streams etc as in other examples but perhaps this makes it cleared what those are actually doing in the background. Anyway - enjoy. 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 // OutStr and myStr are TString// For TProcess options I haveproc.Options := [ poUsePipes,poStdErrToOutPut,poNoConsole,poRunIdle ]; // BUF_SIZE = 2048 - The loop seldom exceeds 1024 bytes if ever.(May be system/application dependent)proc.Execute;WHILE proc.Running doBEGIN//abortstuff     application.ProcessMessages;     if userAbort = true then processAbort(locData);              // include some debug info if aborting//end abortstuff//Read current pipe data into buffer and process it     BytesRead := proc.Output.Read(buffer,proc.Output.NumBytesAvailable); //Get process output byte count data into the buffer     if BytesRead >0  then                                              //or nothing to do     BEGIN       for k := 1 to BytesRead do                       // Read the buffer 1 byte at a time         begin              myStr := myStr + chr(buffer[k]);          // just add to the string - if a partial string was already in it - it will be completed              if chr(Buffer[k]) = #13 then              // Using this line to judge EOL for my current OS (windoze)              begin                outStr := '';                for j := 1 to length(myStr) do                 // The j loop simply chops out extra #10#13 outherwise output is double spaced                  if (myStr[j] = #10) or (myStr[j] = #13) then   // could be done a shade quicker but this keeps things clearer maybe                     continue                                    // especially since #13#10 could be split across the partial string boundry for myStr                  else                      outStr := outStr + myStr[j];                filterFFMPEGoutput(outStr);             //if a full line - output it - or if filtered etc. do that              myStr := '';                              // ... if full line completed clear the string otherwise the partial line is ...            end;//#13                                   // ... left for completion next "while proc.running" loop.              application.ProcessMessages;         end;//k     END;//>0END;//WHILE runningfrmJs.synEDdataFFMPEG.Lines.Add(#10#13 + '*** END OF FILE ***' + #10#13#10#13 ); // just a notice for logging clarity john