Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2008-11

Cannot run mplayer with TProcess when options is poUsePipes in Windows

8 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Dusan Halicky

Following code works in linux, but not in windows. In windows program freeze, or I don't see mplayer. Thanks.

program bug;
{$mode objfpc}{$H+}
uses
  Classes, SysUtils, Process;
begin
  with TProcess.Create(nil) do
  try
    //Options := [];            // this work on both Windows and Linux
    Options := [poUsePipes];  // this doesn't work in Windows but works in Linux
    CommandLine := 'mplayer -slave -quiet final.avi';
    Execute;
    writeln('press enter to exit');
    readln;
  finally
    Free;
  end;
end.
Henry Vermaak
to Dusan Halicky

2008/11/10 Dusan Halicky :

Show quoted text 16 lines
Following code works in linux, but not in windows. In windows program freeze, or I don't see mplayer. Thanks. program bug; {$mode objfpc}{$H+} uses Classes, SysUtils, Process; begin with TProcess.Create(nil) do try //Options := []; // this work on both Windows and Linux Options := [poUsePipes]; // this doesn't work in Windows but works in Linux CommandLine := 'mplayer -slave -quiet final.avi';

is there an mplayer.exe in a directory on the path (or windows directory)?

henry

Vincent Snijders
to Dusan Halicky: Following code works in linux, but not in windows. In windows program freeze, or I don't…
Dusan Halicky wrote 23 lines
Following code works in linux, but not in windows. In windows program freeze, or I don't see mplayer. Thanks. program bug; {$mode objfpc}{$H+} uses Classes, SysUtils, Process; begin with TProcess.Create(nil) do try //Options := []; // this work on both Windows and Linux Options := [poUsePipes]; // this doesn't work in Windows but works in Linux CommandLine := 'mplayer -slave -quiet final.avi'; Execute; writeln('press enter to exit'); readln; finally Free; end; end.

Maybe you need to add poNoConsole?

Vincent

Dusan Halicky
> is there an mplayer.exe in a directory on the path (or windows directory)?

yes. (when I remove poUsePipes the video plays normally)

> Maybe you need to add poNoConsole?

I still can't see a video (nor audio) with this option, however it helps a little (application dont freeze after end with this option)

Any other hints? Thanks.

Vincent Snijders
to Dusan Halicky
Dusan Halicky wrote 10 lines
>> is there an mplayer.exe in a directory on the path (or windows directory)? yes. (when I remove poUsePipes the video plays normally) >> Maybe you need to add poNoConsole? I still can't see a video (nor audio) with this option, however it helps a little (application dont freeze after end with this option) Any other hints? Thanks.

Make sure that mplayer isn't waiting for you read the output pipe.

Vincent

Dusan Halicky
to Vincent Snijders

Well. The only way how to make mplayer visible is read all data from output

repeat
  i := Output.Read(buf[0],100);
until i<0;

but since my program is console application, it stay blocked on the last read from output and do not continue to application main loop None of these are problems on linux, it appears only on windows. Any ideas?

2008/11/10 Vincent Snijders :

Show quoted text 21 lines
Dusan Halicky schreef: >>> >>> is there an mplayer.exe in a directory on the path (or windows >>> directory)? > > yes. (when I remove poUsePipes the video plays normally) > >>> Maybe you need to add poNoConsole? > > I still can't see a video (nor audio) with this option, however it > helps a little (application dont freeze after end with this option) > > Any other hints? Thanks. Make sure that mplayer isn't waiting for you read the output pipe. Vincent _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Vincent Snijders
to Dusan Halicky
Dusan Halicky wrote 12 lines
Well. The only way how to make mplayer visible is read all data from output repeat i := Output.Read(buf[0],100); until i<0; but since my program is console application, it stay blocked on the last read from output and do not continue to application main loop None of these are problems on linux, it appears only on windows. Any ideas?

Maybe linux performs a non-blocking read (and returns 0) and windows performs a blocking read. You can check if there is output using NumBytesAvailable: http://lazarus-ccr.sourceforge.net/docs/fcl/pipes/tinputpipestream.numbytesavailable.html

Vincent

Dusan Halicky
to Vincent Snijders
> You can check if there is output using NumBytesAvailable:

Ok, This thing now works (I've also try this but I "accidentaly" checked NumBytesAvailable after read, it must be checked before read)

Thanks, It works now !!!