I want to start gstreamer and make one picture. After this the gstreamer pipeline should be shut down.
My problem is, the gstreamer pipeline is still exists and every try there is a new one. Actual the sample works with installed gstreamer and a USB V4L Kamera.
How can i shutdown the pipeline too ?!
BTW: V4L is not possible because the cameras are only working with gstreamer (GigE, USB3,...).
procedure TFormVideoTmp.SnapShot();
const
BUF_SIZE = 2048; // Buffer size for reading the output in chunks
var
AProcess: TProcess;
BytesRead: longint;
Buffer: array[1..BUF_SIZE] of byte;
i,found: Integer;
line: String;
finish: boolean;
begin
AProcess := TProcess.Create(nil);
AProcess.Executable := '/bin/sh';
AProcess.Parameters.Add('-c');
AProcess.Parameters.Add('/usr/bin/gst-launch-1.0 -v v4l2src ! identity silent=false ! jpegenc ! filesink location=/tmp/test.jpg');
// AProcess.Parameters.Add('/usr/bin/gst-launch-1.0 -v tcambin ! identity silent=false ! jpegenc ! filesink location=/tmp/test.jpg');
AProcess.Options := [poUsePipes];
AProcess.Execute;
finish := false;
repeat
BytesRead := AProcess.Output.Read(Buffer, BUF_SIZE);
Line := '';
for i := 1 to BytesRead do begin
Line := Line + chr(Buffer[i]);
end;
found := Pos('dts',Line);
if (found > 0) and (BytesRead > (found+4+18)) then begin
finish:= true;
end;
if (BytesRead = 0) then begin
finish:= true;
end;
until finish; // Stop if no more data is available or dts found
if AProcess.Terminate(0) then
writeln('Teminate ok')
else
writeln('Terminate NOK');
AProcess.Free;
end;