Jump to content

StdoutRead to edit control. ( Solved! )


Recommended Posts

I'm in the process of building myself a front end for FFmpeg. I'm trying to get the output of the FFmpeg console window to an edit control.

I'm not able to get it to work and my brain can't see why right now. Would somebody help me out please.

#include <GUIConstantsEX.au3>
;Set OnEvent Mode
    opt("GUIOnEventMode", 1)
    
;Set Must Declare Vars
    AutoItSetOption("MustDeclareVars", 1)
    
;Declare Variables
    Global $frmMain
    
;Main form menu vars    
    Global $frmMainFileMenu
    Global $frmMainFileItemExit
    
;Main form source video
    Global $sourceVideoLabel
    Global $sourceVideoInput
    Global $sourceVideoBrowseBtn

    Global $ffmpegStdOutput

;FFMpeg Command Label
    Global $ffmpegCommandLabel
    
;Create GUI
    $frmMain = GUICreate("Web Video Encoder FF", 640, 480, (@DeskTopWidth - 640)/2, (@DeskTopHeight - 480)/2, -1, -1)
    GUISetOnEvent($GUI_EVENT_CLOSE, "ExitApp")
    
    $frmMainFileMenu = GUICtrlCreateMenu("&File")
    $frmMainFileItemExit = GUICtrlCreateMenuItem("E&xit", $frmMainFileMenu)
    GUICtrlSetOnEvent($frmMainFileItemExit, "ExitApp")
    
;Source Video Controls  
    $sourceVideoLabel = GUICtrlCreateLabel("Source Video: ", 5, 24, 70, 20, -1, -1)
    $sourceVideoInput = GUICtrlCreateInput("",80, 20, 500, 20, -1, -1)
    $sourceVideoBrowseBtn = GUICtrlCreateButton("Browse", 585, 20, 50, 20, -1, -1)
    GUICtrlSetOnEvent($sourceVideoBrowseBtn, "SelectSourceVideo")
    GUISetState(@SW_SHOW)

;fFFMpeg std Output Control
    $ffmpegStdOutput = GUICtrlCreateEdit("", 80, 100, 500, 150, -1, -1)
    
;FFMpeg Command Line
;$ffmpegCommandLabel = GUICtrlCreateLabel("Command: "& $openDialog, 5, 400, 600, 20, -1, -1)
    
    While 1
        Sleep(1000)
    WEnd
    
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Function:  Select Source Video. 
;           - Run ffmpeg to get input file info.
;           - Send ffmpeg output to edit control.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    Func SelectSourceVideo()
            Local $openDialog, $sourceFile, $ffmpegInputSwitch, $ffmpegScreenOut, $runFFmpeg, $STDERR_CHILD, $STDOUT_CHILD
            
            $openDialog = FileOpenDialog("Source Video", @MyDocumentsDir, "avi (*.avi)|mpeg (*.mpg;*.mpeg;*.mp4)", 1)
            If @error Then
                MsgBox(48, "No File Chosen", "No File Chosen.")
                Return
            EndIf
            
            $sourceFile = GUICtrlSetData($sourceVideoInput, $openDialog)
            $ffmpegInputSwitch = " -i " & $openDialog
            $runFFmpeg = Run(@comspec & " /k ffmpeg.exe" & $ffmpegInputSwitch, @ScriptDir & "\ffmpeg\", @SW_SHOW + $STDERR_CHILD + $STDOUT_CHILD)
    
            while 1
                $ffmpegScreenOut = StdoutRead($runFFmpeg, False, False)
                If @error = -1 Then ExitLoop
                GUICtrlSetData($ffmpegStdOutput, $ffmpegScreenOut & @CRLF)
            WEnd
                
    EndFunc
    
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Function: Exit Application
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    Func ExitApp()
        Exit
    EndFunc

P.S How do I color code Autoit code when pasted into the forum?

Edited by AndrewG
Link to comment
Share on other sites

Don't have the ffmpeg.exe, so just a guess

$ffmpegInputSwitch = " -i " & $openDialog
$runFFmpeg = Run(@ComSpec & " /k ffmpeg.exe" & $ffmpegInputSwitch, @ScriptDir & "\ffmpeg\", @SW_SHOW, $STDERR_CHILD + $STDOUT_CHILD)
$ffmpegScreenOut = ""
While 1
    $ffmpegScreenOut &= StdoutRead($runFFmpeg)
    If @error = -1 Then ExitLoop
WEnd
GUICtrlSetData($ffmpegStdOutput, $ffmpegScreenOut & @CRLF)

To highlight the au syntax use autoit and /autoit in brackets...

Best Regards

Link to comment
Share on other sites

Thank you for the help but unfortunately it di not solve the StdoutRead problem.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Function:  Select Source Video. 
;           - Run ffmpeg to get input file info.
;           - Send ffmpeg screen output to edit control.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    Func SelectSourceVideo()
            Local $openDialog, $sourceFile, $ffmpegInputSwitch, $ffmpegScreenOut, $runFFmpeg, $STDERR_CHILD, $STDOUT_CHILD
            
            $openDialog = FileOpenDialog("Source Video", @MyDocumentsDir, "avi (*.avi)|mpeg (*.mpg;*.mpeg;*.mp4)", 1)
            If @error Then
                MsgBox(48, "No File Chosen", "No File Chosen.")
                Return
            EndIf
            
            $sourceFile = GUICtrlSetData($sourceVideoInput, $openDialog)
            $ffmpegInputSwitch = " -i " & $openDialog
            $runFFmpeg = Run(@comspec & " /k ffmpeg.exe" & $ffmpegInputSwitch, @ScriptDir & "\ffmpeg\", @SW_SHOW, $STDERR_CHILD + $STDOUT_CHILD)
            
            $ffmpegScreenOut = ""
            
            while 1
                $ffmpegScreenOut &= StdoutRead($runFFmpeg)
                If @error = -1 Then ExitLoop
                
            WEnd
            GUICtrlSetData($ffmpegStdOutput, $ffmpegScreenOut & @CRLF)
                
    EndFunc
Edited by AndrewG
Link to comment
Share on other sites

Really, really strange :) ...

The output seems to be piped to StderrRead() ???? :o

Works if invoked in same dir as ffmpeg.exe, otherwise adjust the exe location accordingly...

#include<GUIConstants.au3>
#include<Constants.au3>

;Set OnEvent Mode
    opt("GUIOnEventMode", 1)
    
;Set Must Declare Vars
    AutoItSetOption("MustDeclareVars", 1)
    
;Declare Variables
    Global $frmMain
    
;Main form menu vars    
    Global $frmMainFileMenu
    Global $frmMainFileItemExit
    
;Main form source video
    Global $sourceVideoLabel
    Global $sourceVideoInput
    Global $sourceVideoBrowseBtn

    Global $ffmpegStdOutput

;FFMpeg Command Label
    Global $ffmpegCommandLabel
    
;Create GUI
    $frmMain = GUICreate("Web Video Encoder FF", 640, 480, (@DeskTopWidth - 640)/2, (@DeskTopHeight - 480)/2, -1, -1)
    GUISetOnEvent($GUI_EVENT_CLOSE, "ExitApp")
    
    $frmMainFileMenu = GUICtrlCreateMenu("&File")
    $frmMainFileItemExit = GUICtrlCreateMenuItem("E&xit", $frmMainFileMenu)
    GUICtrlSetOnEvent($frmMainFileItemExit, "ExitApp")
    
;Source Video Controls    
    $sourceVideoLabel = GUICtrlCreateLabel("Source Video: ", 5, 24, 70, 20, -1, -1)
    $sourceVideoInput = GUICtrlCreateInput("",80, 20, 500, 20, -1, -1)
    $sourceVideoBrowseBtn = GUICtrlCreateButton("Browse", 585, 20, 50, 20, -1, -1)
    GUICtrlSetOnEvent($sourceVideoBrowseBtn, "SelectSourceVideo")
    GUISetState(@SW_SHOW)

;fFFMpeg std Output Control
    $ffmpegStdOutput = GUICtrlCreateEdit("", 80, 100, 500, 150, -1, -1)
    
;FFMpeg Command Line
;$ffmpegCommandLabel = GUICtrlCreateLabel("Command: "& $openDialog, 5, 400, 600, 20, -1, -1)
    
    While 1
        Sleep(1000)
    WEnd
    
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Function:    Select Source Video.
;            - Run ffmpeg to get input file info.
;            - Send ffmpeg output to edit control.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    Func SelectSourceVideo()
            Local $openDialog, $sourceFile, $ffmpegInputSwitch, $ffmpegScreenOut, $runFFmpeg
            
            $openDialog = FileOpenDialog("Source Video", @MyDocumentsDir, "avi (*.avi)|mpeg (*.mpg;*.mpeg;*.mp4)", 1)
            If @error Then
                MsgBox(48, "No File Chosen", "No File Chosen.")
                Return
            EndIf
            
            $sourceFile = GUICtrlSetData($sourceVideoInput, $openDialog)
            $ffmpegInputSwitch = " -i """ & $openDialog & """"
            
            $runFFmpeg = Run(FileGetShortName(@ScriptDir & "\ffmpeg.exe") & $ffmpegInputSwitch, '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
            
            $ffmpegScreenOut = ""
            while 1
                $ffmpegScreenOut &= StderrRead($runFFmpeg)
                If @error Then ExitLoop
            WEnd
            GUICtrlSetData($ffmpegStdOutput, GUICtrlRead($ffmpegStdOutput) & $ffmpegScreenOut & @CRLF)
        EndFunc
        
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Function: Exit Application
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    Func ExitApp()
        Exit
    EndFunc
Edited by KaFu
Link to comment
Share on other sites

Really, really strange :) ...

The output seems to be piped to StderrRead() ???? :o

Works if invoked in same dir as ffmpeg.exe, otherwise adjust the exe location accordingly...

#include<GUIConstants.au3>
#include<Constants.au3>

;Set OnEvent Mode
    opt("GUIOnEventMode", 1)
    
;Set Must Declare Vars
    AutoItSetOption("MustDeclareVars", 1)
    
;Declare Variables
    Global $frmMain
    
;Main form menu vars    
    Global $frmMainFileMenu
    Global $frmMainFileItemExit
    
;Main form source video
    Global $sourceVideoLabel
    Global $sourceVideoInput
    Global $sourceVideoBrowseBtn

    Global $ffmpegStdOutput

;FFMpeg Command Label
    Global $ffmpegCommandLabel
    
;Create GUI
    $frmMain = GUICreate("Web Video Encoder FF", 640, 480, (@DeskTopWidth - 640)/2, (@DeskTopHeight - 480)/2, -1, -1)
    GUISetOnEvent($GUI_EVENT_CLOSE, "ExitApp")
    
    $frmMainFileMenu = GUICtrlCreateMenu("&File")
    $frmMainFileItemExit = GUICtrlCreateMenuItem("E&xit", $frmMainFileMenu)
    GUICtrlSetOnEvent($frmMainFileItemExit, "ExitApp")
    
;Source Video Controls    
    $sourceVideoLabel = GUICtrlCreateLabel("Source Video: ", 5, 24, 70, 20, -1, -1)
    $sourceVideoInput = GUICtrlCreateInput("",80, 20, 500, 20, -1, -1)
    $sourceVideoBrowseBtn = GUICtrlCreateButton("Browse", 585, 20, 50, 20, -1, -1)
    GUICtrlSetOnEvent($sourceVideoBrowseBtn, "SelectSourceVideo")
    GUISetState(@SW_SHOW)

;fFFMpeg std Output Control
    $ffmpegStdOutput = GUICtrlCreateEdit("", 80, 100, 500, 150, -1, -1)
    
;FFMpeg Command Line
;$ffmpegCommandLabel = GUICtrlCreateLabel("Command: "& $openDialog, 5, 400, 600, 20, -1, -1)
    
    While 1
        Sleep(1000)
    WEnd
    
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Function:    Select Source Video.
;            - Run ffmpeg to get input file info.
;            - Send ffmpeg output to edit control.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    Func SelectSourceVideo()
            Local $openDialog, $sourceFile, $ffmpegInputSwitch, $ffmpegScreenOut, $runFFmpeg
            
            $openDialog = FileOpenDialog("Source Video", @MyDocumentsDir, "avi (*.avi)|mpeg (*.mpg;*.mpeg;*.mp4)", 1)
            If @error Then
                MsgBox(48, "No File Chosen", "No File Chosen.")
                Return
            EndIf
            
            $sourceFile = GUICtrlSetData($sourceVideoInput, $openDialog)
            $ffmpegInputSwitch = " -i """ & $openDialog & """"
            
            $runFFmpeg = Run(FileGetShortName(@ScriptDir & "\ffmpeg.exe") & $ffmpegInputSwitch, '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
            
            $ffmpegScreenOut = ""
            while 1
                $ffmpegScreenOut &= StderrRead($runFFmpeg)
                If @error Then ExitLoop
            WEnd
            GUICtrlSetData($ffmpegStdOutput, GUICtrlRead($ffmpegStdOutput) & $ffmpegScreenOut & @CRLF)
        EndFunc
        
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Function: Exit Application
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    Func ExitApp()
        Exit
    EndFuncoÝ÷ Ûú®¢×¶¸w*.®Ê%ºØ¨©ÝÜ(®K©äʯz¼¦¹È_¢¼¨º»bå¡jج¶÷Þ­éÜy·­Áç§J×hºÔ^iÖ§u+]zºÑy§H¶¸vë"ay+]zºÑy§_ºw-âl¯z»"¢z¶¬r¸©µ©ÝÜ(®GÂ+a¢ëiºÛbayì^{azƦyØ«Jèáj÷­Â(ëb¢{¢wÝ8ZK¢»az¥¥«­¢+Ø¥¹±Õ±ÐíU%
½¹ÍѹÑÍ`¹ÔÌÐì(¥¹±Õ±Ðí
½¹ÍѹÑ̹ÔÌÐì(íMÐ=¹Ù¹Ð5½(%½ÁÐ ÅÕ½ÐíU%=¹Ù¹Ñ5½ÅÕ½Ðì°Ä¤($(íMÐ5ÕÍбÉYÉÌ(%Õѽ%ÑMÑ=ÁÑ¥½¸ ÅÕ½Ðí5ÕÍѱÉYÉÌÅÕ½Ðì°Ä¤($(í±ÉYÉ¥±Ì(%±½°ÀÌØíɵ5¥¸($(í5¥¸½É´µ¹ÔÙÉÌ$(%±½°ÀÌØíɵ5¥¹¥±5¹Ô(%±½°ÀÌØíɵ5¥¹¥±%ѵá¥Ð($(í5¥¸½É´Í½ÕÉÙ¥¼(%±½°ÀÌØíͽÕÉY¥½1°(%±½°ÀÌØíͽÕÉY¥½%¹ÁÕÐ(%±½°ÀÌØíͽÕÉY¥½  ɽÝÍ    Ѹ((%±½°ÀÌØíµÁMÑ=ÕÑÁÕÐ((í5Á
½µµ¹1°(%±½°ÀÌØíµÁ
½µµ¹1°($(í
ÉÑU$($ÀÌØíɵ5¥¸ôU%
ÉÑ ÅÕ½Ðí]Y¥¼¹½ÈÅÕ½Ðì°ØÐÀ°ÐàÀ°¡Í­Q½Á]¥Ñ ´ØÐÀ¤¼È°¡Í­Q½Á!¥¡Ð´ÐàÀ¤¼È°´Ä°´Ä¤(%U%MÑ=¹Ù¹Ð ÀÌØíU%}Y9Q}
1=M°ÅÕ½Ðíá¥ÑÁÀÅÕ½Ðì¤($($ÀÌØíɵ5¥¹¥±5¹ÔôU%
Ñɱ
ÉÑ5¹Ô ÅÕ½ÐìµÀí¥±ÅÕ½Ðì¤($ÀÌØíɵ5¥¹¥±%ѵá¥ÐôU%
Ñɱ
ÉÑ5¹Õ%Ñ´ ÅÕ½ÐíµÀíá¥ÐÅÕ½Ðì°ÀÌØíɵ5¥¹¥±5¹Ô¤(%U%
ÑɱMÑ=¹Ù¹Ð ÀÌØíɵ5¥¹¥±%ѵá¥Ð°ÅÕ½Ðíá¥ÑÁÀÅÕ½Ðì¤($(íM½ÕÉY¥¼
½¹Ñɽ±Ì$($ÀÌØíͽÕÉY¥½1°ôU%
Ñɱ
ÉÑ1° ÅÕ½ÐíM½ÕÉY¥¼èÅÕ½Ðì°Ô°ÈаÜÀ°ÈÀ°´Ä°´Ä¤($ÀÌØíͽÕÉY¥½%¹ÁÕÐôU%
Ñɱ
ÉÑ%¹ÁÕÐ ÅÕ½ÐìÅÕ½Ðì°àÀ°ÈÀ°ÔÀÀ°ÈÀ°´Ä°´Ä¤($ÀÌØíͽÕÉY¥½   ɽÝÍ    ѸôU%
Ñɱ
ÉÑ    ÕÑѽ¸ ÅÕ½Ðí   ɽÝÍÅÕ½Ðì°ÔàÔ°ÈÀ°ÔÀ°ÈÀ°´Ä°´Ä¤(%U%
ÑɱMÑ=¹Ù¹Ð ÀÌØíͽÕÉY¥½    ɽÝÍ    Ѹ°ÅÕ½ÐíM±ÑM½ÕÉY¥¼ÅÕ½Ðì¤(%U%MÑMÑÑ¡M]}M!=¤((í5ÁÍÑ=ÕÑÁÕÐ
½¹Ñɽ°($ÀÌØíµÁMÑ=ÕÑÁÕÐôU%
Ñɱ
ÉѥРÅÕ½ÐìÅÕ½Ðì°àÀ°ÄÀÀ°ÔÀÀ°ÄÔÀ°´Ä°´Ä¤($(í5Á
½µµ¹1¥¹($ìÀÌØíµÁ
½µµ¹1°ôU%
Ñɱ
ÉÑ1° ÅÕ½Ðí
½µµ¹èÅÕ½ÐìµÀìÀÌØí½Á¹¥±½°Ô°ÐÀÀ°ØÀÀ°ÈÀ°´Ä°´Ä¤($(%]¡¥±Ä($%M±À ÄÀÀÀ¤(%]¹($(ìììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììì(íչѥ½¸è%M±ÐM½ÕÉY¥¼¸(ì$$$´IÕ¸µÁѼХ¹ÁÕÐ¥±¥¹¼¸(ì$$$´M¹µÁÍɸ½ÕÑÁÕÐѼ¥Ð½¹Ñɽ°¸(ìììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììì(%Õ¹M±ÑM½ÕÉY¥¼ ¤($$%1½°ÀÌØí½Á¹¥±½°ÀÌØíͽÕÉ¥±°ÀÌØíµÁ%¹ÁÕÑMÝ¥Ñ °ÀÌØíµÁMɹ=ÕаÀÌØíÉÕ¹µÁ($$$($$$ÀÌØí½Á¹¥±½ô¥±=Á¹¥±½ ÅÕ½ÐíM½ÕÉY¥¼ÅÕ½Ðì°5å½Õµ¹ÑͥȰÅÕ½ÐíÙ¤ ¨¹Ù¤¥ñµÁ ¨¹µÁ쨹µÁ쨹µÀФÅÕ½Ðì°Ä¤($$%%ÉɽÈQ¡¸($$$%5Í ½à Ðà°ÅÕ½Ðí9¼¥±
¡½Í¸ÅÕ½Ðì°ÅÕ½Ðí9¼¥±
¡½Í¸¸ÅÕ½Ðì¤($$$%IÑÕɸ($$%¹%($$$($$$ÀÌØíͽÕÉ¥±ôU%
ÑɱMÑÑ ÀÌØíͽÕÉY¥½%¹ÁÕаÀÌØí½Á¹¥±½¤($$$ÀÌØíµÁ%¹ÁÕÑMÝ¥Ñ ôÅÕ½Ð쵤ÅÕ½ÐìµÀìÀÌØí½Á¹¥±½($$$ÀÌØíÉÕ¹µÁôIÕ¸¡½µÍÁµÀìÅÕ½Ðì½µÁ¹áÅÕ½ÐìµÀìÀÌØíµÁ%¹ÁÕÑMÝ¥Ñ °MÉ¥ÁѥȵÀìÅÕ½ÐìÀäÈíµÁÀäÈìÅÕ½Ðì°M]}!%°ÀÌØíMQII}
!%1¬ÀÌØíMQ=UQ}
!%1¤(($$%Ý¡¥±Ä($$$$ÀÌØíµÁMɹ=ÕÐôÀÌØíµÁMɹ=ÕеÀìMÑÉÉI ÀÌØíÉÕ¹µÁ¤($$$%%ÉɽÈQ¡¸á¥Ñ1½½À($$%]¹($$%U%
ÑɱMÑÑ ÀÌØíµÁMÑ=ÕÑÁÕаÀÌØíµÁMɹ=ÕеÀì
I1¤(%¹Õ¹($(ìììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììì(íչѥ½¸èá¥ÐÁÁ±¥Ñ¥½¸(ìììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììììì(%Õ¹á¥ÑÁÀ ¤($%á¥Ð(%¹Õ¹
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...