Jump to content

Gstreamer automation?


Burgs
 Share

Recommended Posts

Greetings,

  I would like to be able to write a script to send commands to the console for creation of Gstreamer pipelines.  I was thinking of something similar to this:

Local $iPID = Run("C:\Windows\System32\cmd", "", @SW_MAXIMIZE)  ;THIS OPENS THE CONSOLE...!!!

 if $iPID == 0 Then ConsoleWrite(@CRLF & "I DID NOT OPEN CMD...error: " & @error & @CRLF)
 if $iPID <> 0 Then ConsoleWrite(@CRLF & "I OPENED CMD...!!!" & @CRLF)

$hCmd = WinGetHandle("C:\WINDOWS\system32\cmd.exe")

 if $hCmd <> 0 Then
 WinActivate($hCmd)  ;ensure command console is active...

 $sOutput = Send("cd C:\gstreamer\1.0\x86_64\bin" & @CRLF, $SEND_RAW)
 $sOutput = Send("gst-launch-1.0 videotestsrc ! autovideosink" & @CRLF, $SEND_RAW)

 Sleep(3000)
 ControlSend($hCmd, "", "", "exit" & @CR)
 EndIf  ;$hCmd NOT "0"...

I don't really know if this is the best way to open the console and send commands into it.  I'm also not sure about how to best catch any errors that may occur...likely this needs to be accomplished with the STDOUTREAD command however I've not had experience using it before and therefore would appreciate some advice that anybody may offer. 

Basically I'm seeking guidance on how to best automate the opening of the console, sending lines of commands to be executed, and handling any potential errors in the execution of those commands...I thank you in advance.  Regards.

Link to comment
Share on other sites

$sFilePath = "C:\gstreamer\1.0\x86_64\bin\"

Local $iPID = Run($sFilePath & "gst-launch-1.0 videotestsrc ! autovideosink" , $sFilePath, @SW_HIDE, $STDOUT_CHILD)

; Wait until the process has closed using the PID returned by Run.
ProcessWaitClose($iPID)

; Read the Stdout stream of the PID returned by Run.
Local $sOutput = StdoutRead($iPID)

This would be the way to run apps from the command line...

Link to comment
Share on other sites

You can also combine commands with cmd using & or &&, example:

#include <AutoItConstants.au3>

Example()

Func Example()
    Local $iPID = Run(@ComSpec & ' /C CD "C:\gstreamer\1.0\x86_64\bin"&&gst-launch-1.0 videotestsrc ! autovideosink', "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD))
    ProcessWaitClose($iPID)
    Local $sOutput = StdoutRead($iPID)
        If StringStripWS($sOutput, 8) <> "" Then ConsoleWrite("##### StdOut #####" & @CRLF & $sOutput & @CRLF)
    Local $sStdErr = StderrRead($iPID)
        If StringStripWS($sStdErr, 8) <> "" Then ConsoleWrite("##### StdErr #####" & @CRLF & $sStdErr & @CRLF)
EndFunc   ;==>Example

 

Link to comment
Share on other sites

Greetings,

  Thank you for the replies, much appreciated.

  @Nine why does your "Run" command not reference/call any command to open the console window?  I mean how does AutoIT know the stated command you wrote is to be executed in the console?

  @Subz would I also be able to write the command alternatively as indicated in the documentation...using Run(@ComSpec & " /c " & 'commandName', "", @SW_HIDE)   ...therefore it would read:

  Run(@ComSpec & " /c" & 'C:\gstreamer\1.0\x86_64\bin & gst-launch-1.0 videotestsrc ! autovideosink', "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD))   ....?  does the "&" provide an attached 'second line' to be executed following the command before the "&" ('C:\gstreamer\1.0\x86_64\bin')...?

  Are the "STDERR_CHILD" and "STDOUT_CHILD" just regular strings?  Therefore I could examine them with "StringInStr" for keywords such as "prerolling" or "error"...OR do I need to accomplish that using the "StderrRead" and "StdoutRead" which will produce the readable string(s)...?

  Thanks again for the responses and sorry for my additional questions...I'm just trying to wrap my head around this.

Regards

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...