kevev Posted December 7, 2022 Share Posted December 7, 2022 (edited) Howdy! I am attempting to parse the stderr output of ffmpeg and store it into an array that will be pushed to a combobox. I have the full output example below. Original input: [libndi_newtek @ 000001f53af6af40] Found 3 NDI sources: [libndi_newtek @ 000001f53af6af40] 'PC-NAME (Remote Connection 1)' 'ndi-app:PC-NAME%20(Remote%20Connection%201)' [libndi_newtek @ 000001f53af6af40] 'PC-NAME (NDI - Output 1)' '192.168.1.201:5961' [libndi_newtek @ 000001f53af6af40] 'ANOTHER-PC (NDI - Output 3)' '192.168.1.201:5962' dummy: Immediate exit requested Needed output: PC-NAME (Remote Connection 1) PC-NAME (NDI - Output 1) ANOTHER-PC (NDI - Output 3) My current code is here: $iPID = Run(@ComSpec & ' /C "ffmpeg.exe -hide_banner -f libndi_newtek -find_sources 1 -i dummy"', @ScriptDir, @SW_HIDE, $STDERR_CHILD) ProcessWaitClose($iPID) $sDirtyOutput = StderrRead($iPID) ;This one gives me the columns I want, but the strings are still surrounded by single quotes " ' ". ;$sOutput = StringRegExpReplace(StringRegExpReplace(StringRegExpReplace($sDirtyOutput, ".*Found\ \d\ NDI\ sources:", ""), "dummy:\ Immediate\ exit\ requested", ""), "\[.*\]", "") ; This one gives no output. $sOutput = StringRegExpReplace(StringRegExpReplace(StringRegExpReplace(StringRegExpReplace($sDirtyOutput, ".*Found\ \d\ NDI\ sources:", ""), "dummy:\ Immediate\ exit\ requested", ""), "\[.*\]", ""), "(?<=\047).*?(?=\047)", "") $aOutputArray = StringSplit($sOutput, @CRLF) GUICtrlSetData($aOutputArray, $sOutput & @CRLF) ;Remove blank lines from the Array. For $i = UBound($aOutputArray) - 1 To 0 Step -1 If $aOutputArray[$i] = "" Then _ArrayDelete($aOutputArray, $i) EndIf Next _ArrayDisplay($aOutputArray) The output I get is: '''' '''' '''' Edited December 7, 2022 by kevev More info Link to comment Share on other sites More sharing options...
Nine Posted December 7, 2022 Share Posted December 7, 2022 Maybe this : #include <Array.au3> Local $sText = "[libndi_newtek @ 000001f53af6af40] Found 3 NDI sources:" & @CRLF & _ "[libndi_newtek @ 000001f53af6af40] 'PC-NAME (Remote Connection 1)' 'ndi-app:PC-NAME%20(Remote%20Connection%201)'" & @CRLF & _ "[libndi_newtek @ 000001f53af6af40] 'PC-NAME (NDI - Output 1)' '192.168.1.201:5961'" & @CRLF & _ "[libndi_newtek @ 000001f53af6af40] 'ANOTHER-PC (NDI - Output 3)' '192.168.1.201:5962'" & @CRLF & _ "dummy: Immediate exit requested" Local $aArray = StringRegExp($sText,"'(PC-NAME.+?|ANOTHER-PC.+?)'", 3) _ArrayDisplay($aArray) Zedna 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
kevev Posted December 7, 2022 Author Share Posted December 7, 2022 1 hour ago, Nine said: Maybe this : #include <Array.au3> Local $sText = "[libndi_newtek @ 000001f53af6af40] Found 3 NDI sources:" & @CRLF & _ "[libndi_newtek @ 000001f53af6af40] 'PC-NAME (Remote Connection 1)' 'ndi-app:PC-NAME%20(Remote%20Connection%201)'" & @CRLF & _ "[libndi_newtek @ 000001f53af6af40] 'PC-NAME (NDI - Output 1)' '192.168.1.201:5961'" & @CRLF & _ "[libndi_newtek @ 000001f53af6af40] 'ANOTHER-PC (NDI - Output 3)' '192.168.1.201:5962'" & @CRLF & _ "dummy: Immediate exit requested" Local $aArray = StringRegExp($sText,"'(PC-NAME.+?|ANOTHER-PC.+?)'", 3) _ArrayDisplay($aArray) Thank You. I will not always get the same PC name. I really need the 2nd column text. Link to comment Share on other sites More sharing options...
Nine Posted December 8, 2022 Share Posted December 8, 2022 PC-NAME/ANOTHER-PC are always in upper case ? Rest are always in lower case ? #include <Array.au3> Local $sText = "[libndi_newtek @ 000001f53af6af40] Found 3 NDI sources:" & @CRLF & _ "[libndi_newtek @ 000001f53af6af40] 'PC-NAME (Remote Connection 1)' 'ndi-app:PC-NAME%20(Remote%20Connection%201)'" & @CRLF & _ "[libndi_newtek @ 000001f53af6af40] 'PC-NAME (NDI - Output 1)' '192.168.1.201:5961'" & @CRLF & _ "[libndi_newtek @ 000001f53af6af40] 'ANOTHER-PC (NDI - Output 3)' '192.168.1.201:5962'" & @CRLF & _ "dummy: Immediate exit requested" Local $aArray = StringRegExp($sText,"'([A-Z].+?)'", 3) _ArrayDisplay($aArray) If that does not work, please provide some REAL results that we can actually work with... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Musashi Posted December 8, 2022 Share Posted December 8, 2022 This should match any PC Name (regardless of capitalization) as long as the line structure follows your example. #include <Array.au3> Local $sText = "[libndi_newtek @ 000001f53af6af40] Found 3 NDI sources:" & @CRLF & _ "[libndi_newtek @ 000001f53af6af40] 'PC-NAME (Remote Connection 1)' 'ndi-app:PC-NAME%20(Remote%20Connection%201)'" & @CRLF & _ "[libndi_newtek @ 000001f53af6af40] 'PC-NAME (NDI - Output 1)' '192.168.1.201:5961'" & @CRLF & _ "[libndi_newtek @ 000001f53af6af40] 'ANOTHER-PC (NDI - Output 3)' '192.168.1.201:5962'" & @CRLF & _ "[libndi_newtek @ 000001f53af6af40] 'PC-Name2 (NDI - Output 3)' '192.168.1.201:5962'" & @CRLF & _ "[libndi_newtek @ 000001f53af6af40] 'Whatever PC-Name (NDI - Output 3)' '192.168.1.201:5962'" & @CRLF & _ "[libndi_newtek @ 000001f53af6af40] 'unknown' '192.168.1.201:5962'" & @CRLF & _ "dummy: Immediate exit requested" Local $aArray = StringRegExp($sText,"\].*?'(.+?)'", 3) _ArrayDisplay($aArray) spudw2k and Zedna 2 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
kevev Posted December 8, 2022 Author Share Posted December 8, 2022 Thank You both. Musashi's code is exactly what I needed. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now