Guten Morgen, jetzt habe ich mal einiges rumgebastelt und wollte Euch das Resultat mal posten.
Und Ihr müsstet noch eine Datei mit dem Namen "Daten.txt" anlegen, mit folgendem Inhalt:
Code: Select all
#NoEnv
#Warn
#SingleInstance, Force
SetWorkingDir %A_ScriptDir%
SetBatchLines -1
Menu, Tray, Icon, %A_Comspec%
Process, Priority,,High
CPX:="cp" . DllCall("GetOEMCP", "UInt") ;- get CODEPAGE e.g. cp850 / use CP850 below in function RunCmd
cmdx= ;ping www.autohotkey.com -n 4
Gui, Font, s9, Consolas
gui, add, button, x10 y5 h24 w120 vVideo gVideo, Video auswählen
Gui, Add, Edit, x140 y6 w750 vVideoEdit
Gui, Add, Text,x10 y280, Output
Gui, Add, Edit, x10 y300 w880 -Wrap +HScroll R15 HwndhEdit1, % Format("{:81}", "")
ControlGetPos,,,W,,,ahk_id %hEdit1%
Gui, Add, Text,x10 y40, Command Line
Gui, Add, Edit, x10 y60 -Wrap vEingabe HwndhEdit2 w%W%,%cmdx%
Gui, Add, GroupBox, cRed x-1 y572 w903 h30
Gui, Add, Text, x10 y583, Zeit:
Gui, Add, Text, x50 y583 w160 vZeit1
Gui, Add, Text, x350 y583, Auflösung:
Gui, Add, Text, x425 y583 w160 vDaten1
Gui, Add, Text, x740 y583, FPS:
Gui, Add, Text, x772 y583 w160 vFPS1
gui, Add, Button, x10 y550 gEncoderStart, Encoder starten
gui, Add, Button, x774 y550 gEncoderStop, Encoder stoppen
Gui, Add, ActiveX, x300 y90 w242 h200 vWMP, WMPLayer.OCX
Gui, Show, h600 w900, Video Converter - Echtzeit Ausgabe
return
Video:
Thread, NoTimers
FileSelectFile, VideoDatei
WMP.Url := VideoDatei
;Hallo :="image_%%05d.png"
FileDelete, video.bat
FileAppend, ; Das Komma ist in diesem Fall erforderlich.
(
bin\mediainfo --Inform=file://e:\test\media\Daten.txt "%VideoDatei%" > Info.txt
), video.bat
runwait, %comspec% /c video.bat, ,hide
FileReadLine, Zeit, Info.txt, 1
FileReadLine, Aufloesung, Info.txt, 3
FileReadLine, FPS, Info.txt, 5
Wert := Round(FPS,-0)
Thread, NoTimers, false
GuiControl, , VideoEdit, "%VideoDatei%"
GuiControl, , Eingabe, bin\HandBrakeCLI.exe -i "%VideoDatei%" -e x264 -q 22 -r, --rate %Wert% -E, --aencoder aac -B 160 -o "%VideoDatei%"-neu.mp4
GuiControl, , Zeit1, %Zeit%
GuiControl, , Daten1, %Aufloesung% Pixel
GuiControl, , fps1, %Wert% Bilder/Sekunde
return
RunCMD:
SB_SetText("", 3)
GuiControlGet, Cmd,, %hEdit2%
GuiControl, Disable, Button1
ExitCode := RunCMD(A_Comspec . " /c " . Cmd)
SB_SetText("`tExitCode : " ErrorLevel, 3)
GuiControl, Enable, Button1
Edit_Append(hEdit2,"")
GuiControl, Focus,Edit2
Return
;------------------------------
#IfWinActive RunCMD() ahk_class AutoHotkeyGUI
Esc::
GuiControl, Focus,Edit2
Edit_Append(hEdit2,"")
If (A_Args.RunCMD.PID)
{
A_Args.RunCMD.PID := 0
Return
}
SB_SetText("", 3)
GuiControl,,Edit1
GuiControl,,Edit2
Return
;------------------------------
#IfWinActive
RunCmd_Output(Line, LineNum) {
Global
If ( SubStr(Line,-1)!="`r`n" )
Line .= "`r`n"
Edit_Append(hEdit1, Line)
}
Edit_Append(hEdit, Txt) { ; Modified version by SKAN
Local ; Original by TheGood on 09-Apr-2010 @ autohotkey.com/board/topic/52441-/?p=328342
L := DllCall("SendMessage", "Ptr",hEdit, "UInt",0x0E, "Ptr",0 , "Ptr",0) ; WM_GETTEXTLENGTH
DllCall("SendMessage", "Ptr",hEdit, "UInt",0xB1, "Ptr",L , "Ptr",L) ; EM_SETSEL
DllCall("SendMessage", "Ptr",hEdit, "UInt",0xC2, "Ptr",0 , "Str",Txt) ; EM_REPLACESEL
}
;===================================================================================================
;RunCMD(CmdLine, WorkingDir:="", Codepage:="CP0", Fn:="RunCMD_Output") { ; RunCMD v0.94
RunCMD(CmdLine, WorkingDir:="", Codepage:="CP850", Fn:="RunCMD_Output") {
Local ; RunCMD v0.94 by SKAN on D34E/D37C @ autohotkey.com/boards/viewtopic.php?t=74647
Global A_Args ; Based on StdOutToVar.ahk by Sean @ autohotkey.com/board/topic/15455-stdouttovar
Fn := IsFunc(Fn) ? Func(Fn) : 0
, DllCall("CreatePipe", "PtrP",hPipeR:=0, "PtrP",hPipeW:=0, "Ptr",0, "Int",0)
, DllCall("SetHandleInformation", "Ptr",hPipeW, "Int",1, "Int",1)
, DllCall("SetNamedPipeHandleState","Ptr",hPipeR, "UIntP",PIPE_NOWAIT:=1, "Ptr",0, "Ptr",0)
, P8 := (A_PtrSize=8)
, VarSetCapacity(SI, P8 ? 104 : 68, 0) ; STARTUPINFO structure
, NumPut(P8 ? 104 : 68, SI) ; size of STARTUPINFO
, NumPut(STARTF_USESTDHANDLES:=0x100, SI, P8 ? 60 : 44,"UInt") ; dwFlags
, NumPut(hPipeW, SI, P8 ? 88 : 60) ; hStdOutput
, NumPut(hPipeW, SI, P8 ? 96 : 64) ; hStdError
, VarSetCapacity(PI, P8 ? 24 : 16) ; PROCESS_INFORMATION structure
If not DllCall("CreateProcess", "Ptr",0, "Str",CmdLine, "Ptr",0, "Int",0, "Int",True
,"Int",0x08000000 | DllCall("GetPriorityClass", "Ptr",-1, "UInt"), "Int",0
,"Ptr",WorkingDir ? &WorkingDir : 0, "Ptr",&SI, "Ptr",&PI)
Return Format("{1:}", "", ErrorLevel := -1
,DllCall("CloseHandle", "Ptr",hPipeW), DllCall("CloseHandle", "Ptr",hPipeR))
DllCall("CloseHandle", "Ptr",hPipeW)
, A_Args.RunCMD := { "PID": NumGet(PI, P8? 16 : 8, "UInt") }
, File := FileOpen(hPipeR, "h", Codepage)
, LineNum := 1, sOutput := ""
While (A_Args.RunCMD.PID + DllCall("Sleep", "Int",0))
and DllCall("PeekNamedPipe", "Ptr",hPipeR, "Ptr",0, "Int",0, "Ptr",0, "Ptr",0, "Ptr",0)
While A_Args.RunCMD.PID and (Line := File.ReadLine())
sOutput .= Fn ? Fn.Call(Line, LineNum++) : Line
A_Args.RunCMD.PID := 0
, hProcess := NumGet(PI, 0)
, hThread := NumGet(PI, A_PtrSize)
, DllCall("GetExitCodeProcess", "Ptr",hProcess, "PtrP",ExitCode:=0)
, DllCall("CloseHandle", "Ptr",hProcess)
, DllCall("CloseHandle", "Ptr",hThread)
, DllCall("CloseHandle", "Ptr",hPipeR)
, ErrorLevel := ExitCode
Return sOutput
}
EncoderStart:
Gui, Submit, nohide
goto, RunCMD
return
;Bitrate:
;Gui, Submit, nohide
;GuiControl, , Eingabe, bin\ffmpeg -y -i "%VideoDatei%" -threads 16 -b:v %Bitrate%k -r %FPS3% -c:a mp3 -ar 48000 -b:a 160k -bufsize 4096k -maxrate 2000k "%VideoDatei%"-neu.mp4
;return
EncoderStop:
run, TASKKILL /IM HandBrakeCLI.exe /F /T, , Hide
return
GuiClose:
run, TASKKILL /IM HandBrakeCLI.exe /F /T, , Hide
FileDelete, video.bat
FileDelete, Info.txt
ExitApp