Sign in to follow this  
Followers 0
georgetaupobungy

trying to get stdout from console to log

1 post in this topic

Hey all, im new to autoit, and i have had a contractor develop a script for me.

Ive succesfully made  changes to it recently. But today i really want to be able to add a log for the console output... and a better error log.

The script is used to record video via ffmpeg on the command line.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>
#include <Constants.au3>
#include <ScrollBarConstants.au3>
#include <Date.au3>
#include <Process.au3>

$Form1 = GUICreate("oct - test", 288,140, 192, 124)
$Edit1 = GUICtrlCreateLabel("", 22, 20, 225, 35)
$Edit2 = GUICtrlCreateLabel("", 22,360,280,600 )
GUICtrlSetFont($Edit1, 15)
GUICtrlSetData(-1, "")
$recordBungy = GUICtrlCreateButton("Bungy", 23, 65, 75, 25, 0)
$recordSwing = GUICtrlCreateButton("Swing", 103, 65, 75, 25, 0)
$stop = GUICtrlCreateButton("Stop", 186, 65, 75, 25, 0)
$taskKill = GUICtrlCreateButton("End Process", 23, 100, 75, 25, 0)
Local $killffmpeg,$CloseProcess,$NotRecording

GUICtrlSetState($stop, $GUI_DISABLE)
GUISetState(@SW_SHOW)
WinSetOnTop ("oct - test", "", 1)
GUICtrlSetData($Edit1, "Select Record Input")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
         Case $recordBungy
            Record_Bungy()
         Case $recordSwing
            Record_Swing()
          Case $taskKill
            Task_kill()
        Case $stop
            ConsoleWrite("Don't know how to stop")

    EndSwitch
WEnd

 Func Record_Bungy()
   GUICtrlSetState($recordSwing, $GUI_DISABLE)
   GUICtrlSetState($recordBungy, $GUI_DISABLE)
   GUICtrlSetState($stop, $GUI_ENABLE)
   $ping = Run(@ComSpec & ' /c  ' & 'C:\mPower\tools\ffmpeg -rtbufsize 2000M -f dshow -video_size 1920x1080 -framerate 25 -pixel_format uyvy422 -i video="Decklink Video Capture":audio="Decklink Audio Capture" -vcodec mpeg4 -b:v 8000k -vf "yadif:0:0:0" -filter:v scale=1280:720  D:\mPower\dropbox\bungy\bungy.'&@HOUR&'.'&@MIN&'.mp4', @TempDir, $STDOUT_CHILD )
   FileWriteLine ("C:\mpower\BungyLog.txt",@CRLF & "Recording Started " & @MDAY & "/" & @MON & " " & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF)

  While 1 ;ProcessExists ($ping)
      if not ProcessExists($ping) then ExitLoop
      GUICtrlSetColor($Edit1, 0xFF0000)
      GUICtrlSetData($Edit1, "Recording... Bungy")
        
      If @error Then ExitLoop
         If GUIGetMsg() = $stop Then
            $CloseProcess = ControlSend(@comspec,"","","q")
            GUICtrlSetState($stop, $GUI_DISABLE)
            FileWriteLine ("C:\mpower\BungyLog.txt","Stop was pushed at: " & @HOUR & ":" & @MIN & ":" & @SEC & "and returned with " & $CloseProcess)
            Sleep(2000)
            Call ("reset_UI")
            ExitLoop
         EndIf
        local $settop = WinSetOnTop ("C:\Windows\system32\cmd.exe", "", 1)

   WEnd
   FileWriteLine ("C:\mpower\bungyLog.txt", $ping & @CRLF & $CloseProcess & @CRLF & "End of recording"  )
 EndFunc

 Func Record_Swing()
   GUICtrlSetState($recordSwing, $GUI_DISABLE)
   GUICtrlSetState($recordBungy, $GUI_DISABLE)
   GUICtrlSetState($stop, $GUI_ENABLE)
   $ping = Run(@ComSpec & ' /c  ' & 'C:\mPower\tools\ffmpeg -rtbufsize 2000M -f dshow -video_size 1920x1080 -framerate 25 -pixel_format uyvy422 -i video="Decklink Video Capture":audio="Decklink Audio Capture" -vcodec mpeg4 -b:v 8000k -vf "yadif:0:0:0" -filter:v scale=1280:720  D:\mPower\dropbox\swing\swing.'&@HOUR&'.'&@MIN&'.mp4', @TempDir)
   FileWriteLine ("C:\mpower\SwingLog.txt",@CRLF & "Recording Started " & @MDAY & "/" & @MON & " " & @HOUR & ":" & @MIN  & "" & @SEC & @CRLF)
   While 1
      If not ProcessExists($ping) then ExitLoop
      GUICtrlSetColor($Edit1, 0xFF0000)
      GUICtrlSetData($Edit1, "Recording... Swing")
         If @error Then ExitLoop
            If GUIGetMsg() = $stop Then
            $CloseProcess = ControlSend(@comspec,"","","q")
            GUICtrlSetState($stop, $GUI_DISABLE)
            FileWriteLine ("C:\mpower\SwingLog.txt","Stop was pushed at: " & @HOUR & ":" & @MIN & ":" & @SEC &  " " &"and returned with " & $CloseProcess)
            Sleep(2000)
            Call ("reset_UI")
         ExitLoop
      EndIf
      local $settop = WinSetOnTop ("C:\Windows\system32\cmd.exe", "", 1)
   WEnd
   FileWriteLine ("C:\mpower\SwingLog.txt", $ping & @CRLF & $CloseProcess & @CRLF & "End of recording"  )
EndFunc

 Func Task_kill()
   ;kill ffmpeg if it gets stuck running, not allowing further video' s to be captured
   While Processexists("ffmpeg.exe")
         processclose ( "ffmpeg.exe" )
   WEnd
   ConsoleWrite("FFMPEG was force stopped at "& @MDAY & "/" & @MON & " " & @HOUR & ":" & @MIN & " ")
   FileWriteLine ("C:\mpower\ffmpegkill.txt","FFMPEG was force stopped at "& @MDAY & "/" & @MON & " " & @HOUR & ":" & @MIN & " " )
 EndFunc

func reset_UI()
   GUICtrlSetData($Edit1, "Recording Stopped")
   GUICtrlSetColor($Edit1, 000000)
   GUICtrlSetState($recordBungy, $GUI_ENABLE)
   GUICtrlSetState($recordSwing, $GUI_ENABLE)
EndFunc

ive tried to get the stdout output but cant get that going without throwing errors.

"C:mpowertoolsRecordScriptsRecordAutoClosetest.au3" (56) : ==> Subscript used on non-accessible variable.:

If you guys can help me, it be awesome, i am still learning and after posting i will continue reading forums and documentation.

As im going im hoping to get closer so ill add to this post if i figure it out.

thankyou

George

Share this post


Link to post
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
Sign in to follow this  
Followers 0