Autor Beitrag
MDX
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 595
Erhaltene Danke: 4

Windows 8.1, Linux Debian 8, Android Lollipop
Delphi, PHP, Java (Android)
BeitragVerfasst: Sa 21.03.09 04:44 
Hallo, liebe DF Community: wie bereits hier schon nebenbei geschrieben:

Wenn man ein Video encodieren lassen will, erscheint ein Hinweis Fenster und mit WaitForSingleObject wird auf das Ende von ffmpeg gewartet.
Nach dem Encodieren soll sich das Fenster wieder schließen!
Bei mir (WinVista 32 Bit - ~ 12 Ghz - 4GB Ram) funktioniert das auch ohne Probleme.
Bei meinem Laptop (WinVista 32 Bit - ~ 4.5 Ghz - 4 GB Ram), schließt sich das Hinweisfenster nicht, auch wenn der Prozess (ffmpeg.exe) schon nicht mehr läuft!

Hat jmd. eine Idee???

(Das WaitForSingleObject ist in ne andere Funktion gepackt, wens Interessiert!)

THX schonmal
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19315
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 21.03.09 06:10 
Wie sieht denn der Code aus? Welchen Timeout hast du angegeben?

Auf Anhieb fällt mir dazu allgemein nichts weiter ein. Bei mir hat das immer geklappt, wenn ich WaitForSingleObject benutzt habe.
MDX Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 595
Erhaltene Danke: 4

Windows 8.1, Linux Debian 8, Android Lollipop
Delphi, PHP, Java (Android)
BeitragVerfasst: Sa 21.03.09 13:12 
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
function ExecAndWait(const Filename, Params: string; WindowState: word): boolean;
{$IFDEF WIN32}
var
  SUInfo: TStartupInfo;
  ProcInfo: TProcessInformation;
  CmdLine: string;
begin
  CmdLine := '"' + Filename + '" ' + Params;
  FillChar(SUInfo, SizeOf(SUInfo), #0);
  with SUInfo do begin
    cb := SizeOf(SUInfo);
    dwFlags := STARTF_USESHOWWINDOW;
    wShowWindow := WindowState;
  end;
  Result := CreateProcess(NIL, PChar(CmdLine), NILNIL, FALSE,
                          CREATE_NEW_CONSOLE or
                          NORMAL_PRIORITY_CLASS, NIL,
                          PChar(ExtractFilePath(Filename)),
                          SUInfo, ProcInfo);

  { Wait for it to finish. }
  if Result then
    WaitForSingleObject(ProcInfo.hProcess, INFINITE);
{$ELSE}
var
  InstanceID : THandle;
  Buff: array[0..255of char;
begin
  StrPCopy(Buff, Filename + ' ' + Params);
  InstanceID := WinExec(Buff, WindowState);
  if InstanceID < 32 then
  { a value less than 32 indicates an Exec error }
    Result := FALSE
  else begin
    Result := TRUE;
    repeat
      Application.ProcessMessages;
    until Application.Terminated or
          (GetModuleUsage(InstanceID) = 0);
  end;
end;


Das istz die Funktion, die so aufgerufen wird:
ausblenden Delphi-Quelltext
1:
 ExecAndWait(ExtractFilePath(ParamStr(0))+'data/ffmpeg.exe''PARAMETER ZUM ENCODIEREN' , sw_hide);					


Vllt. werdet ihr/ wirst du ja daraus schlauer =)
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19315
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 21.03.09 16:03 
Hmm, auf den ersten Blick fällt mir da auch nichts auf.

Du könntest einfach mal andere Varianten ausprobieren. Auch wenn ich diese eigentlich für recht gut gehalten hätte, aber andererseits blockiert die auch dein Programm. Hier findest du z.B. auch nicht blockierende:
www.swissdelphicente...y/showcode.php?id=93