It works perfect, but only for the first encode. When I get to the second file in the loop and a new instance of handbrakecli.exe the GUI stops updating. It isn't throwing any errors though so I know I am getting close
Code:
#include GetFileList.ahk
#include attachconsole.ahk
#include ConsoleSend.ahk
;#include SimpleArray_v3_Release.ahk
;#include ParseOutput.ahk
DllCall("FreeConsole")
source_dir = x:\rips ;Source Directory
dest_dir = x:\finished_rips ;destionation directory
del = 0 ;delete source (1 yes, 2 no)
query = -f mkv -p -e x264 -q 0.595 -a 1 -E ac3 -B 160 -R 0 -6 dpl2 -D 1 -U -F --markers="C:\Users\Cole\AppData\Local\Temp\%SOURCE%-chapters.csv" -x ref=4:mixed-refs=1:bframes=6:b-pyramid=1:weightb=1:deblock=-2,-1:trellis=1:analyse=all:8x8dct=1:me=umh:subq=9:psy-rd=1,1:merange=32:no-fast-pskip=1:no-dct-decimate=1:direct=auto
hb_path = C:\Program Files (x86)\HandBrake\handbrakeCLI.exe ; Path to Handbrake CLI
hb_priority = Low ; Sets process priority (Normal|High|Low|BelowNormal|AboveNormal)
dest_ext = mkv ; Sets your destination extension (ie m4v, mkv, avi)
file_size_error = 750 ;Min File Size Beofre Error
Gui, Color, Default, 000000
Gui, Add, Progress, w400 h20 cBlue vMyProgress
Gui, Add, Edit, x10 y25 w400 h50 cFFFFFF vRepConsole,
Gui, Show, , ConvertRips By Cole
DllCall("AllocConsole")
GetFileList_ISO(source_dir)
GetFileList_VTS(source_dir)
GetNumFiles()
;Loop Through ISO Files
loopcount := 0
Loop, %count_ISO%
{
sleep, 3000
While encode_running = 1
{
sleep 5000
Gosub, updateGui
Process, Exist, handbrakecli.exe
If !ErrorLevel
{
encode_running := 0
GuiControl, , RepConsole, Encoding %source_a% Finished
sleep 3000
}
}
loopcount++
loop_source := file_list_ISO%loopcount%
loop_name := mv_name_ISO%loopcount%
loop_dest = %dest_dir%\%loop_name%\%loop_name%.%dest_ext%
encode(loop_source, loop_dest, hb_path, query)
}
;Loop Through VTS Files
loopcount := 0
Loop, %count_VTS%
{
sleep, 3000
While encode_running = 1
{
sleep 5000
Gosub, updateGui
Process, Exist, handbrakecli.exe
If !ErrorLevel
{
encode_running := 0
GuiControl, , RepConsole, Encoding %source_a% Finished
sleep 3000
}
}
loopcount++
loop_source := file_list_VTS%loopcount%
loop_name := mv_name_VTS%loopcount%
loop_dest = %dest_dir%\%loop_name%\%loop_name%.%dest_ext%
encode_running :=0
encode(loop_source, loop_dest, hb_path, query)
}
;Encode
Encode(source_a, dest_a, hb_path, query) ;Start hbcli and get text from console
{
global
DllCall("FreeConsole")
encode_running := 1
GuiControl, , RepConsole, Encoding %source_a%
Run, % hb_path . " -i """ . source_a . """ -o """ . dest_a . """ " . query . " -L",, min, HB_PID
Process, Priority, %HB_PID%, %hb_priority% ; Runs handbrakeCLI and sets priority
WinWait, ahk_pid %HB_PID%
AttachConsole(HB_PID)
Return
}
;Parse Query (takes out -v if exists) ;for future use (do before releasing)
;ParseQuery(query)
;{
;StringReplace, query, query, "-v",, 1
;Return query
;}
UpdateGui: ;Update GUI and parse text from console
text := GetConsoleText()
If text = %prevText%
Return
prevText := text
;text_pos := InStr(text, "Encoding: task")
;text_pos := RegExMatch(text, "Encoding: task")
StringGetPos, p_comp_L, text, Encoding: task, R1
p_comp_L := p_comp_L+28
StringMid, p_comp, text, %p_comp_L%, 5 , L
StringGetPos, fps_L, text, `% (, R1
fps_L := fps_L+7
StringMid, fps, text, %fps_L%, 4 , L
StringGetPos, afps_L, text, avg, R1
afps_L := afps_L+8
StringMid, afps, text, %afps_L%, 4 , L
StringGetPos, ETA_L, text, ETA, R1
ETA_L := ETA_L+8
StringMid, ETA, text, %ETA_L%, 9 , L
GuiControl,, MyProgress, % p_comp
GuiControl, , RepConsole, FPS:%fps% AVG FPS:%afps% ETA:%ETA%
return
Thanks Lexikos, without your help I would have stopped improving this project. And please excuse my messy code,