Lazarus

Programming => General => Topic started by: nikel on September 22, 2020, 03:16:30 pm

Title: [Solved] Process pipe error
Post by: nikel on September 22, 2020, 03:16:30 pm
Hello, I'm trying to get some tags from mp3's, here's my code:

Code: Pascal  [Select][+][-]
  1. Path:=P;
  2.  
  3. TempStringlist:=TStringList.Create;
  4.  
  5. AProcess := TProcess.Create(nil);
  6. AProcess.Executable:= '/bin/sh'; // /bin/bash
  7. AProcess.Parameters.Add('-c');
  8. AProcess.Parameters.Add('ffprobe -loglevel error -show_entries format_tags=' + Request + ' -of default=noprint_wrappers=1:nokey=1 ' + Path);
  9. AProcess.Options := AProcess.Options + [poWaitOnExit, poUsePipes];
  10. AProcess.Execute;

I'm getting pipe error on some songs. Why does it happen?
Title: Re: Process pipe error
Post by: winni on September 22, 2020, 03:38:19 pm
Hi!

I have just no Lazarus at hand.
But as I remember  the size of the pipe is 1024 bytes.

Do some tags break this limit?

Winni
Title: Re: Process pipe error
Post by: marcov on September 22, 2020, 03:40:30 pm
Do you implement the so called long output scenario? This is always recommended when there are problems.

Or use runcommand, which implements this scenario.
Title: Re: Process pipe error
Post by: nikel on September 22, 2020, 04:55:58 pm
Thanks for the replies. How can I implement scenario, it's a console application.
Title: Re: Process pipe error
Post by: marcov on September 22, 2020, 04:57:46 pm
https://wiki.freepascal.org/Executing_External_Programs#Reading_large_output

or easier

https://wiki.freepascal.org/Executing_External_Programs#.28Process..29RunCommand
Title: Re: Process pipe error
Post by: nikel on September 22, 2020, 05:15:19 pm
This worked fine

Code: Pascal  [Select][+][-]
  1. Path:=P;
  2.  
  3. if RunCommand('/bin/bash',['-c','ffprobe -loglevel error -show_entries format_tags=' + Request + ' -of default=noprint_wrappers=1:nokey=1 ' + '"' + Path + '"'], Str) then
  4.    writeln(Str);
  5.  
  6. Result:=Str;
TinyPortal © 2005-2018