Enumeration #Window_0 EndEnumeration Enumeration #Frame3D_1 #Frame3D_2 #Text_3 #encodingmode #Text_5 #preset #Text_7 #tuning #input #Button_10 #String_11 #Frame3D_12 #Text_13 #Text_14 #String_15 #audiocodec #Text_17 #audiobitrate #Text_20 #channels #start #bitrate #addjob #Frame3D_22 #autocrop #Panel_0 #joblist #inputbutton #outputfile #crop #deletejob #beforeresize #x264way #x264mod #afterresize #resizer #avsmt #avsmtvalue #resize #leftcrop #rightcrop #bottomcrop #preview #normalize #topcrop EndEnumeration Define.l Event, EventWindow, EventGadget, EventType, EventMenu Global leftcrop.l,topcrop.l,rightcrop.l,bottomcrop.l,width.l,height.l,encostring.s,passx.l,theight.l,twidth.l,framerate.f,dss.l,bitrate.f Global crop_Tooltip Global resize_Tooltip Global beforeresize_Tooltip Global afterresize_Tooltip Global info.STARTUPINFO info\cb =SizeOf(STARTUPINFO) info\dwFlags =1 Global processinfo.PROCESS_INFORMATION Procedure GadgetBalloonToolTip(WindowNumber.l, GadgetNumber.l, Text.s) Protected Tooltip.l, Balloon.TOOLINFO Tooltip = CreateWindowEx_(0, "ToolTips_Class32", "", #WS_POPUP | #TTS_NOPREFIX | #TTS_BALLOON, 0, 0, 0, 0, WindowID(WindowNumber), 0, GetModuleHandle_(0), 0) SendMessage_(Tooltip, #TTM_SETTIPTEXTCOLOR, GetSysColor_(#COLOR_INFOTEXT), 0) SendMessage_(Tooltip, #TTM_SETTIPBKCOLOR, GetSysColor_(#COLOR_INFOBK), 0) SendMessage_(Tooltip, #TTM_SETMAXTIPWIDTH, 0, 180) Balloon\cbSize = SizeOf(TOOLINFO) Balloon\uFlags = #TTF_IDISHWND | #TTF_SUBCLASS If IsGadget(GadgetNumber) Balloon\hwnd = GadgetID(GadgetNumber) Balloon\uId = GadgetID(GadgetNumber) Else Balloon\hwnd = GadgetNumber Balloon\uId = GadgetNumber EndIf Balloon\lpszText = @Text SendMessage_(Tooltip, #TTM_ADDTOOL, 0, @Balloon) ProcedureReturn Tooltip EndProcedure Procedure ChangeGadgetBalloonToolTip(Tooltip.l, GadgetNumber.l, Text.s) Protected Balloon.TOOLINFO Balloon\cbSize = SizeOf(TOOLINFO) Balloon\uFlags = #TTF_IDISHWND | #TTF_SUBCLASS If IsGadget(GadgetNumber) Balloon\hwnd = GadgetID(GadgetNumber) Balloon\uId = GadgetID(GadgetNumber) Else Balloon\hwnd = GadgetNumber Balloon\uId = GadgetNumber EndIf Balloon\lpszText = @Text SendMessage_(Tooltip, #TTM_ADDTOOL, 0, @Balloon) EndProcedure Procedure FreeBalloonTooltip(Tooltip.l) DestroyWindow_(Tooltip.l) EndProcedure Global ver.s ver.s="v.0.1."+Str(#pb_editor_buildcount)+"."+Str(#pb_editor_compilecount) Procedure OpenWindow_Window_0() If OpenWindow(#Window_0, 410, 295, 435, 330, "MicroX264 "+ver.s, #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar) Frame3DGadget(#Frame3D_1, 5, 5, 426, 80, "Select your input file...") StringGadget(#input, 10, 25, 365, 20, "") ButtonGadget(#inputbutton, 385, 25, 40, 20, "...") StringGadget(#outputfile, 10, 55, 365, 20, "", #PB_String_ReadOnly) ButtonGadget(#start, 10, 300, 100, 20, "Start Queue") DisableGadget(#start,1) ButtonGadget(#addjob, 120, 300, 100, 20, "Add Job") ButtonGadget(#deletejob, 325, 300, 100, 20, "Delete all Jobs") PanelGadget(#Panel_0,10, 95, 420, 200) AddGadgetItem(#Panel_0, -1, "X264 Parameters") Frame3DGadget(#Frame3D_2, 5, 10, 210, 135, "X264 Parameters") TextGadget(#Text_3, 10, 30, 85, 20, "Encoding Mode:") ComboBoxGadget(#encodingmode, 100, 30, 100, 20) AddGadgetItem(#encodingmode,-1,"1 pass") AddGadgetItem(#encodingmode,-1,"2 pass") AddGadgetItem(#encodingmode,-1,"CRF Mode") AddGadgetItem(#encodingmode,-1,"QP Mode") AddGadgetItem(#encodingmode,-1,"1 pass + CRF Mode") SetGadgetState(#encodingmode,2) TextGadget(#Text_5, 10, 60, 85, 20, "Preset:") ComboBoxGadget(#preset, 100,60, 100, 20) AddGadgetItem(#preset,-1,"No Preset") AddGadgetItem(#preset,-1,"ultrafast") AddGadgetItem(#preset,-1,"veryfast") AddGadgetItem(#preset,-1,"faster") AddGadgetItem(#preset,-1,"fast") AddGadgetItem(#preset,-1,"medium") AddGadgetItem(#preset,-1,"slow") AddGadgetItem(#preset,-1,"slower") AddGadgetItem(#preset,-1,"veryslow") AddGadgetItem(#preset,-1,"placebo") SetGadgetState(#preset,5) TextGadget(#Text_7, 10, 90, 85, 20, "Tuning:") ComboBoxGadget(#tuning, 100, 90, 100, 20) AddGadgetItem(#tuning,-1,"none") AddGadgetItem(#tuning,-1,"Film") AddGadgetItem(#tuning,-1,"Animation") AddGadgetItem(#tuning,-1,"Grain") AddGadgetItem(#tuning,-1,"PSNR") AddGadgetItem(#tuning,-1,"SSIM") AddGadgetItem(#tuning,-1,"Fastdecode") AddGadgetItem(#tuning,-1,"Zerolatency") AddGadgetItem(#tuning,-1,"Touhou") SetGadgetState(#tuning,0) TextGadget(#Text_14, 10, 120, 85, 20, "Bitrate/CRF:") StringGadget(#bitrate, 100, 115, 100, 20, "18") TextGadget(#PB_Any, 10, 152, 75, 20, "Custom X264:") ComboBoxGadget(#x264mod,90,150,320,20,#PB_ComboBox_Editable) Frame3DGadget(#Frame3D_12, 220, 10, 190, 105, "Audio Parameters") TextGadget(#Text_13, 230, 30, 70, 20, "Audio Codec:") ComboBoxGadget(#audiocodec, 300, 30, 95, 20) AddGadgetItem(#audiocodec,-1,"None") AddGadgetItem(#audiocodec,-1,"Aac") AddGadgetItem(#audiocodec,-1,"Ogg Vorbis") SetGadgetState(#audiocodec,0) TextGadget(#Text_17, 230, 60, 80, 20, "Quality:") SpinGadget(#audiobitrate, 300, 60, 95, 20,0,100,#PB_Spin_Numeric) SetGadgetState(#audiobitrate,35) CheckBoxGadget(#normalize,230,90,80,20,"Normalize") ;- Avisynth AddGadgetItem(#Panel_0, -1, "AviSynth") Frame3DGadget(#PB_Any, 5, 5, 405, 75, "Resizing") TextGadget(#PB_Any, 10, 20, 60, 20, "Round Crop:") StringGadget(#leftcrop, 75, 20, 22, 20, "0") StringGadget(#topcrop, 97, 20, 22, 20, "0") StringGadget(#rightcrop, 119, 20, 22, 20, "0") StringGadget(#bottomcrop, 141, 20, 22, 20, "0") ButtonGadget(#autocrop,170,20,70,20,"Autocrop") ButtonGadget(#preview,170,45,70,20,"Preview") TextGadget(#PB_Any, 10, 45, 60, 20, "Resize:") StringGadget(#resize, 75, 45, 85, 20, "") TextGadget(#PB_Any, 250, 20, 50, 20, "Resizer:") ComboBoxGadget(#resizer, 300, 20, 100, 20) AddGadgetItem(#resizer,-1,"BicubicResize") AddGadgetItem(#resizer,-1,"BilinearResize") AddGadgetItem(#resizer,-1,"BlackmanResize") AddGadgetItem(#resizer,-1,"GaussResize") AddGadgetItem(#resizer,-1,"LanczosResize") AddGadgetItem(#resizer,-1,"Lanczos4Resize") AddGadgetItem(#resizer,-1,"PointResize") AddGadgetItem(#resizer,-1,"Spline16Resize") AddGadgetItem(#resizer,-1,"Spline36Resize") AddGadgetItem(#resizer,-1,"Spline64Resize") SetGadgetState(#resizer,4) CheckBoxGadget(#avsmt,250,50,60,20,"MT mode:") StringGadget(#avsmtvalue,315,50,40,20,"2,0") Frame3DGadget(#PB_Any, 5, 85, 405, 65, "Filters") TextGadget(#PB_Any, 10, 105, 90, 20, "Before Resize:") TextGadget(#PB_Any, 10, 125, 60, 20, "After Resize:") TextGadget(#PB_Any, 10,155,90,20,"Process input with:") ComboBoxGadget(#x264way,110,152,190,20) AddGadgetItem(#x264way,-1,"Avisynth (avs2yuv)") AddGadgetItem(#x264way,-1,"lavf (need X264 with lavf support)") AddGadgetItem(#x264way,-1,"ffms (need X264 with ffms support)") AddGadgetItem(#x264way,-1,"avs (need X264 with avs support)") AddGadgetItem(#x264way,-1,"auto (need X264 with auto support)") SetGadgetState(#x264way,0) ComboBoxGadget(#beforeresize, 85, 100, 310, 20,#PB_ComboBox_Editable) AddGadgetItem(#beforeresize,-1,"") AddGadgetItem(#beforeresize,-1,"Yadif()") AddGadgetItem(#beforeresize,-1,"tfm(last).tdecimate()") AddGadgetItem(#beforeresize,-1,"EditMe") SetGadgetState(#beforeresize,0) ComboBoxGadget(#afterresize, 85, 125, 310, 20, #PB_ComboBox_Editable) AddGadgetItem(#afterresize,-1,"") AddGadgetItem(#afterresize,-1,"Hqdn3d()") AddGadgetItem(#afterresize,-1,"EditMe") SetGadgetState(#afterresize,0) ;- job list AddGadgetItem(#Panel_0, -1, "Works List") EditorGadget(#joblist, 5, 15, 400, 130) GadgetBalloonToolTip(#Window_0, #x264mod, "These parameters will be added to encoding mode, preset (if selected), tuning and bitrate") GadgetBalloonToolTip(#Window_0, #joblist, "This is the list of encoding jobs") GadgetBalloonToolTip(#Window_0, #inputbutton, "Select input file") GadgetBalloonToolTip(#Window_0, #start, "Start queue jobs") GadgetBalloonToolTip(#Window_0, #addjob, "Add current encoding to job list") GadgetBalloonToolTip(#Window_0, #deletejob, "Delete all queue jobs") GadgetBalloonToolTip(#Window_0, #normalize, "Allow audio normalizing") GadgetBalloonToolTip(#Window_0, #audiobitrate, "This value is the quality of audio"+Chr(10)+"The more the better") GadgetBalloonToolTip(#Window_0,#audiocodec, "Select audio codec") x264mod_Tooltip = GadgetBalloonToolTip(#Window_0, #x264mod, "Custom X264 command line") GadgetBalloonToolTip(#Window_0,#bitrate,"Specify bitrate or CRF to use"+Chr(10)+"Only when using avs2yuv you can specify final size by putting a M at left of final size. Like 700M , for 700 MB final file with automatic bitrate computing") GadgetBalloonToolTip(#Window_0,#tuning,"Select type of tuning to use") GadgetBalloonToolTip(#Window_0,#preset,"Select encoding preset"+Chr(10)+"Select No Preset for specifing full command line in Custom X264") GadgetBalloonToolTip(#Window_0,#encodingmode,"Select kind of encoding") afterresize_Tooltip = GadgetBalloonToolTip(#Window_0, #afterresize, "This line will be written in avs after the resize") beforeresize_Tooltip = GadgetBalloonToolTip(#Window_0, #beforeresize, "This string will be written before resize, you can edit it") GadgetBalloonToolTip(#Window_0,#x264way,"Only avs2yuv allow resizing, crop and filters") GadgetBalloonToolTip(#Window_0,#avsmtvalue, "Specify MT values") GadgetBalloonToolTip(#Window_0,#avsmt, "Activate MultiThread mode on Avisynth. For avs2yuv only") GadgetBalloonToolTip(#Window_0,#resizer, "Select resizer to use. Only for avs2yuv") preview_Tooltip = GadgetBalloonToolTip(#Window_0,#preview, "Click here for preview") autocrop_Tooltip = GadgetBalloonToolTip(#Window_0,#autocrop, "Click here for autocrop") leftcrop_Tooltip = GadgetBalloonToolTip(#Window_0, #leftcrop, "Left crop value") topcrop_Tooltip = GadgetBalloonToolTip(#Window_0, #topcrop, "Top crop value") rightcrop_Tooltip = GadgetBalloonToolTip(#Window_0, #rightcrop, "Rigth crop value") bottomcrop_Tooltip = GadgetBalloonToolTip(#Window_0, #bottomcrop, "Bottom crop value") resize_Tooltip = GadgetBalloonToolTip(#Window_0, #resize, "Insert resize as width,height. Ex. 1920,1080") EndIf EndProcedure Global inputfile.s,here.s,queue.l,workpath.s here.s=GetPathPart(ProgramFilename()) Procedure x264lavf() workpath.s=GetPathPart(inputfile.s)+Mid(GetFilePart(inputfile.s),0,Len(GetFilePart(inputfile.s))-1-Len(GetExtensionPart(inputfile.s))) CreateDirectory(GetPathPart(inputfile.s)+Mid(GetFilePart(inputfile.s),0,Len(GetFilePart(inputfile.s))-1-Len(GetExtensionPart(inputfile.s)))) workpath.s=workpath.s+"\" leftcrop.l=Val(GetGadgetText(#leftcrop)) topcrop.l=Val(GetGadgetText(#topcrop)) rightcrop.l=Val(GetGadgetText(#rightcrop)) bottomcrop.l=Val(GetGadgetText(#bottomcrop)) If GetGadgetText(#resize)<>"" If CountString(GetGadgetText(#resize),",")=1 width.l=Val(StringField(GetGadgetText(#resize),1,",")) height.l=Val(StringField(GetGadgetText(#resize),2,",")) EndIf EndIf If GetGadgetText(#x264way)="avs (need X264 with avs support)" encostring.s=Chr(34)+here.s+"application\x264.exe"+Chr(34)+" --demuxer avs "+Chr(34)+inputfile.s+Chr(34)+" " EndIf If GetGadgetText(#x264way)="auto (need X264 with auto support)" encostring.s=Chr(34)+here.s+"application\x264.exe"+Chr(34)+" --demuxer auto "+Chr(34)+inputfile.s+Chr(34)+" " EndIf If GetGadgetText(#x264way)="lavf (need X264 with lavf support)" encostring.s=Chr(34)+here.s+"application\x264.exe"+Chr(34)+" --demuxer lavf "+Chr(34)+inputfile.s+Chr(34)+" " EndIf If GetGadgetText(#x264way)="ffms (need X264 with ffms support)" encostring.s=Chr(34)+here.s+"application\x264.exe"+Chr(34)+" --demuxer ffms "+Chr(34)+inputfile.s+Chr(34)+" " EndIf If passx.l=1 : encostring.s=encostring.s+"--bitrate "+GetGadgetText(#bitrate)+" " : EndIf If passx.l=2 : encostring.s=encostring.s+"--pass 1 --bitrate "+GetGadgetText(#bitrate)+" " : EndIf If passx.l=3 : encostring.s=encostring.s+"--pass 2 --bitrate "+GetGadgetText(#bitrate)+" " : EndIf If passx.l=4 : encostring.s=encostring.s+"--crf "+GetGadgetText(#bitrate)+" ": EndIf If passx.l=5 : encostring.s=encostring.s+"--crf "+GetGadgetText(#bitrate)+" --pass 1 ": EndIf If passx.l=7 : encostring.s=encostring.s+"--pass 2 --bitrate %bitrate% " : EndIf If passx.l=8 : encostring.s=encostring.s+"--qp "+GetGadgetText(#bitrate)+" ": EndIf encostring.s=encostring.s+"--threads auto --thread-input " If GetGadgetText(#preset)<>"No Preset" : encostring.s=encostring.s+"--preset "+GetGadgetText(#preset)+" " : EndIf If GetGadgetText(#tuning)<>"none" : encostring.s=encostring.s+"--tune "+LCase(GetGadgetText(#tuning))+" " : EndIf If GetGadgetText(#x264mod)<>"" : encostring.s=encostring.s+" "+LCase(GetGadgetText(#x264mod))+" " : EndIf encostring.s=encostring.s+" --output "+Chr(34)+workpath.s+"MicroX264.h264"+Chr(34) If passx.l=5 : encostring.s=encostring.s+" 2>temp.txt" : EndIf If passx.l=6 : encostring.s="FOR /F "+Chr(34)+"tokens=7 delims=. "+Chr(34)+" %%A IN ('findstr encoded temp.txt') DO SET bitrate=%%A" : EndIf AddGadgetItem(#joblist,-1,encostring.s) If GetGadgetText(#audiocodec)="None" If passx.l=1 Or passx.l=3 Or passx.l=4 Or passx.l=7 Or passx.l=8 If GetExtensionPart(GetGadgetText(#outputfile))="mkv" encostring.s=Chr(34)+here.s+"application\mkvmerge.exe"+Chr(34)+" -o "+Chr(34)+GetGadgetText(#outputfile)+Chr(34)+" --default-duration 0:"+StrF(framerate.f,3)+"fps "+Chr(34)+workpath.s+"MicroX264.h264"+Chr(34)+" " AddGadgetItem(#joblist,-1,encostring.s) EndIf If GetExtensionPart(GetGadgetText(#outputfile))="mp4" encostring.s=Chr(34)+here.s+"application\mp4box.exe"+Chr(34)+" -add "+Chr(34)+workpath.s+"MicroX264.h264"+Chr(34)+" -fps "+StrF(framerate.f,3)+" " encostring.s=encostring.s+" "+Chr(34)+GetGadgetText(#outputfile)+Chr(34) AddGadgetItem(#joblist,-1,encostring.s) EndIf If GetExtensionPart(GetGadgetText(#outputfile))="h264" encostring.s="move "+Chr(34)+workpath.s+"MicroX264.h264"+Chr(34)+" "+Chr(34)+GetGadgetText(#outputfile)+Chr(34) AddGadgetItem(#joblist,-1,encostring.s) EndIf EndIf EndIf If GetGadgetText(#audiocodec)<>"None" If passx.l=1 Or passx.l=3 Or passx.l=4 Or passx.l=7 Or passx.l=8 If GetGadgetText(#audiocodec)="Aac" encostring.s=Chr(34)+here.s+"application\wavi.exe"+Chr(34)+" "+Chr(34)+workpath.s+"MicroX264.avs"+Chr(34)+" - | "+Chr(34)+here.s+"application\neroaacenc.exe"+Chr(34)+" -if - -q "+StrF((Val(GetGadgetText(#audiobitrate))/100),2)+" -ignorelength -of "+Chr(34)+workpath.s+"MicroX264.mp4"+Chr(34) AddGadgetItem(#joblist,-1,encostring.s) EndIf If GetGadgetText(#audiocodec)="Ogg Vorbis" encostring.s=Chr(34)+here.s+"application\wavi.exe"+Chr(34)+" "+Chr(34)+workpath.s+"MicroX264.avs"+Chr(34)+" - | "+Chr(34)+here.s+"application\oggenc2.exe"+Chr(34)+" - -q "+StrF((Val(GetGadgetText(#audiobitrate))/10),2)+" -o "+Chr(34)+workpath.s+"MicroX264.ogg"+Chr(34) AddGadgetItem(#joblist,-1,encostring.s) EndIf If GetExtensionPart(GetGadgetText(#outputfile))="mkv" encostring.s=Chr(34)+here.s+"application\mkvmerge.exe"+Chr(34)+" -o "+Chr(34)+GetGadgetText(#outputfile)+Chr(34)+" --default-duration 0:"+StrF(framerate.f,3)+"fps "+Chr(34)+workpath.s+"MicroX264.h264"+Chr(34)+" " If GetGadgetText(#audiocodec)="Aac" : encostring.s=encostring.s+Chr(34)+workpath.s+"MicroX264.mp4"+Chr(34) : EndIf If GetGadgetText(#audiocodec)="Ogg Vorbis" : encostring.s=encostring.s+Chr(34)+workpath.s+"MicroX264.ogg"+Chr(34) : EndIf AddGadgetItem(#joblist,-1,encostring.s) EndIf If GetExtensionPart(GetGadgetText(#outputfile))="mp4" encostring.s=Chr(34)+here.s+"application\mp4box.exe"+Chr(34)+" -add "+Chr(34)+workpath.s+"MicroX264.h264"+Chr(34)+" -fps "+StrF(framerate.f,3)+" " If GetGadgetText(#audiocodec)="Aac" : encostring.s=encostring.s+" -add "+Chr(34)+workpath.s+"MicroX264.mp4"+Chr(34) : EndIf If GetGadgetText(#audiocodec)="Ogg Vorbis" : encostring.s=encostring.s+" -add "+Chr(34)+workpath.s+"MicroX264.ogg"+Chr(34) : EndIf encostring.s=encostring.s+" "+Chr(34)+GetGadgetText(#outputfile)+Chr(34) AddGadgetItem(#joblist,-1,encostring.s) EndIf If GetExtensionPart(GetGadgetText(#outputfile))="h264" encostring.s="move "+Chr(34)+workpath.s+"MicroX264.h264"+Chr(34)+" "+Chr(34)+GetGadgetText(#outputfile)+Chr(34) If GetGadgetText(#audiocodec)="Aac" : encostring.s=encostring.s+Chr(13)+"move "+Chr(34)+workpath.s+"MicroX264.mp4"+Chr(34)+" "+Chr(34)+GetGadgetText(#outputfile)+"_audio.mp4"+Chr(34) : EndIf If GetGadgetText(#audiocodec)="Ogg Vorbis" : encostring.s=encostring.s+Chr(13)+"move "+Chr(34)+workpath.s+"MicroX264.ogg"+Chr(34)+" "+Chr(34)+GetGadgetText(#outputfile)+"_audio.ogg"+Chr(34) : EndIf AddGadgetItem(#joblist,-1,encostring.s) EndIf EndIf EndIf EndProcedure Procedure x264avs() workpath.s=GetPathPart(inputfile.s)+Mid(GetFilePart(inputfile.s),0,Len(GetFilePart(inputfile.s))-1-Len(GetExtensionPart(inputfile.s))) CreateDirectory(GetPathPart(inputfile.s)+Mid(GetFilePart(inputfile.s),0,Len(GetFilePart(inputfile.s))-1-Len(GetExtensionPart(inputfile.s)))) workpath.s=workpath.s+"\" CreateFile(987,workpath.s+"analyze.avs") If ExamineDirectory(0,here+"filters\","*.dll") Repeat type=NextDirectoryEntry(0) If type=1 ; File a$=LCase(DirectoryEntryName(0)) If FindString(a$,"soundout",0)=0 If FindString(a$,"yadif",0)=0 WriteStringN(987,"LoadPlugin("+Chr(34)+here+"filters\"+a$+Chr(34)+")") EndIf EndIf If FindString(a$,"yadif",0)<>0 WriteStringN(987,"LoadCPlugin("+Chr(34)+here+"filters\"+a$+Chr(34)+")") EndIf EndIf Until type=0 EndIf If ExamineDirectory(0,here+"filters\","*.avsi") Repeat type=NextDirectoryEntry(0) If type=1 ; File a$=DirectoryEntryName(0) WriteStringN(987,"Import("+Chr(34)+here+"filters\"+a$+Chr(34)+")") EndIf Until type=0 EndIf If dss.l=0 Select LCase(GetExtensionPart(inputfile.s)) Case "avi","mpeg","m2v","mpg","ogm","vro" WriteStringN(987,"FFVideoSource("+Chr(34)+inputfile.s+Chr(34)+")") Case "evo","m2ts","ts","mts","mkv","grf","m2t","mov","mp4","vob" WriteStringN(987,"DirectShowSource("+Chr(34)+inputfile.s+Chr(34)+",audio=false)") Case "avs" WriteStringN(987,"Import("+Chr(34)+inputfile.s+Chr(34)+")") Case "d2v" WriteStringN(987,"Mpeg2Source("+Chr(34)+inputfile.s+Chr(34)+")") Case "dgm","dgv" WriteStringN(987,"DGSource("+Chr(34)+inputfile.s+Chr(34)+")") Case "dga" WriteStringN(987,"AVCSource("+Chr(34)+inputfile.s+Chr(34)+")") EndSelect EndIf If dss.l=1 Select LCase(GetExtensionPart(inputfile.s)) Case "avi","mpeg","m2v","mpg","ogm","vro","evo","m2ts","ts","mts","mkv","grf","m2t","mov","mp4","vob" WriteStringN(987,"DirectShowSource("+Chr(34)+inputfile.s+Chr(34)+",audio=false)") Case "avs" WriteStringN(987,"Import("+Chr(34)+inputfile.s+Chr(34)+")") Case "d2v" WriteStringN(987,"Mpeg2Source("+Chr(34)+inputfile.s+Chr(34)+")") Case "dgm","dgv" WriteStringN(987,"DGSource("+Chr(34)+inputfile.s+Chr(34)+")") Case "dga" WriteStringN(987,"AVCSource("+Chr(34)+inputfile.s+Chr(34)+")") EndSelect EndIf WriteStringN(987,"last = ConvertToYV12(last)") WriteStringN(987,"sep="+Chr(34)+" "+Chr(34)) WriteStringN(987,"WriteFile("+Chr(34)+workpath.s+"info.txt"+Chr(34)+", "+Chr(34)+"Framecount"+Chr(34)+","+Chr(34)+"sep"+Chr(34)+","+Chr(34)+"Framerate"+Chr(34)+","+Chr(34)+"sep"+Chr(34)+","+Chr(34)+"WIDTH"+Chr(34)+","+Chr(34)+"sep"+Chr(34)+","+Chr(34)+"HEIGHT"+Chr(34)+")") WriteStringN(987,"trim(0,1)") CloseFile(987) If theight.l=0 And twidth.l=0 wait=RunProgram(here.s+"application\x264.exe"," --preset ultrafast --output "+Chr(34)+workpath.s+"movielenght.h264"+Chr(34)+" "+Chr(34)+workpath.s+"analyze.avs"+Chr(34),workpath.s,#PB_Program_Open) WaitProgram(wait) Delay(500) EndIf If ReadFile(gz,workpath.s+"info.txt") While Eof(gz) = #False gzs.s = ReadString(gz) framecount.l=Val(StringField(gzs.s,0," ")) framerate.f=ValF(StringField(gzs.s,2," ")) twidth.l=Val(StringField(gzs.s,3," ")) theight.l=Val(StringField(gzs.s,4," ")) tsec.l=Int(framecount.l/framerate.f)+1 Wend CloseFile(gz) EndIf leftcrop.l=0 rightcrop.l=0 topcrop.l=0 bottomcrop.l=0 height.l=0 width.l=0 If FindString(GetGadgetText(#bitrate),"M",0)<>0 If GetGadgetText(#audiocodec)="Ogg Vorbis" : abitrate.f=32+GetGadgetState(#audiobitrate)*2.8 : EndIf If GetGadgetText(#audiocodec)="Aac" : abitrate.f=32+GetGadgetState(#audiobitrate)*2.8 : EndIf If GetGadgetText(#audiocodec)="None" : abitrate.f=0 : EndIf bitrate.f=((Val(StringField(GetGadgetText(#bitrate),1,"M"))*1024*1024-framecount.l*24-abitrate.f*1000*tsec.l*0.126)/((tsec.l*0.126)/1024)/1000)/1013 EndIf If FindString(GetGadgetText(#bitrate),"M",0)=0 bitrate.f=ValF(GetGadgetText(#bitrate)) EndIf CreateFile(987,workpath.s+"MicroX264.avs") If ExamineDirectory(0,here+"filters\","*.dll") Repeat type=NextDirectoryEntry(0) If type=1 ; File a$=LCase(DirectoryEntryName(0)) If FindString(a$,"soundout",0)=0 If FindString(a$,"yadif",0)=0 WriteStringN(987,"LoadPlugin("+Chr(34)+here+"filters\"+a$+Chr(34)+")") EndIf EndIf If FindString(a$,"yadif",0)<>0 WriteStringN(987,"LoadCPlugin("+Chr(34)+here+"filters\"+a$+Chr(34)+")") EndIf EndIf Until type=0 EndIf If ExamineDirectory(0,here+"filters\","*.avsi") Repeat type=NextDirectoryEntry(0) If type=1 ; File a$=DirectoryEntryName(0) WriteStringN(987,"Import("+Chr(34)+here+"filters\"+a$+Chr(34)+")") EndIf Until type=0 EndIf If GetGadgetState(#avsmt)=1 WriteStringN(987,"") WriteStringN(987,"#Enabling MT") WriteStringN(987,"SetMemoryMax(512)") WriteStringN(987,"SetMTMode("+GetGadgetText(#avsmtvalue)+")") WriteStringN(987,"") EndIf If dss.l=0 Select LCase(GetExtensionPart(inputfile.s)) Case "avi","mpeg","m2v","mpg","ogm","vro" WriteStringN(987,"FFVideoSource("+Chr(34)+inputfile.s+Chr(34)+")") Case "evo","m2ts","ts","mts","mkv","grf","m2t","mov","mp4","vob" WriteStringN(987,"movie = DirectShowSource("+Chr(34)+inputfile.s+Chr(34)+",audio=false)") Case "avs" WriteStringN(987,"movie = Import("+Chr(34)+inputfile.s+Chr(34)+")") Case "d2v" WriteStringN(987,"movie = Mpeg2Source("+Chr(34)+inputfile.s+Chr(34)+")") Case "dgm","dgv" WriteStringN(987,"movie = DGSource("+Chr(34)+inputfile.s+Chr(34)+")") Case "dga" WriteStringN(987,"movie = AVCSource("+Chr(34)+inputfile.s+Chr(34)+")") EndSelect EndIf If dss.l=1 Select LCase(GetExtensionPart(inputfile.s)) Case "avi","mpeg","m2v","mpg","ogm","vro","evo","m2ts","ts","mts","mkv","grf","m2t","mov","mp4","vob" WriteStringN(987,"movie = DirectShowSource("+Chr(34)+inputfile.s+Chr(34)+",audio=false)") Case "avs" WriteStringN(987,"movie = Import("+Chr(34)+inputfile.s+Chr(34)+")") Case "d2v" WriteStringN(987,"movie = Mpeg2Source("+Chr(34)+inputfile.s+Chr(34)+")") Case "dgm","dgv" WriteStringN(987,"movie = DGSource("+Chr(34)+inputfile.s+Chr(34)+")") Case "dga" WriteStringN(987,"movie = AVCSource("+Chr(34)+inputfile.s+Chr(34)+")") EndSelect EndIf If GetGadgetText(#audiocodec)<>"None" Select LCase(GetExtensionPart(inputfile.s)) Case "vob","avi","mpeg","mpg","ogm","vro","evo","m2ts","ts","mts","mkv","m2t","mov","mp4","avs" WriteStringN(987,"audio = DirectShowSource("+Chr(34)+inputfile.s+Chr(34)+",video=false)") If GetGadgetState(#normalize)=1 WriteStringN(987,"audio=Normalize(audio)") EndIf WriteStringN(987,"AudioDub(movie,audio)") EndSelect EndIf If GetGadgetText(#audiocodec)="None" If GetGadgetText(#resize)="" And GetGadgetText(#leftcrop)="0" WriteStringN(987,"return movie") EndIf If GetGadgetText(#resize)="" And GetGadgetText(#leftcrop)<>"" WriteStringN(987,"last = movie") EndIf If GetGadgetText(#resize)<>"" And GetGadgetText(#leftcrop)<>"" WriteStringN(987,"last = movie") EndIf If GetGadgetText(#resize)<>"" And GetGadgetText(#leftcrop)="" WriteStringN(987,"last = movie") EndIf EndIf If GetGadgetText(#beforeresize)<>"" : WriteStringN(987,GetGadgetText(#beforeresize)) : EndIf leftcrop.l=Val(GetGadgetText(#leftcrop)) topcrop.l=Val(GetGadgetText(#topcrop)) rightcrop.l=Val(GetGadgetText(#rightcrop)) bottomcrop.l=Val(GetGadgetText(#bottomcrop)) If GetGadgetText(#resize)<>"" If CountString(GetGadgetText(#resize),",")=1 width.l=Val(StringField(GetGadgetText(#resize),1,",")) height.l=Val(StringField(GetGadgetText(#resize),2,",")) EndIf EndIf If width.l<>0 And height.l<>0 WriteStringN(987,GetGadgetText(#resizer)+"("+Str(width.l)+","+Str(height.l)+","+Str(leftcrop.l)+","+Str(topcrop.l)+",-"+Str(rightcrop.l)+",-"+Str(bottomcrop)+")") EndIf If width.l=0 And height.l=0 If leftcrop.l+topcrop.l+rightcrop.l+bottomcrop.l<>0 WriteStringN(987,"Crop(last,"+Str(leftcrop.l)+","+Str(topcrop.l)+",-"+Str(rightcrop.l)+",-"+Str(bottomcrop)+")") EndIf EndIf If GetGadgetText(#afterresize)<>"" : WriteStringN(987,GetGadgetText(#afterresize)) : EndIf CloseFile(987) If LCase(GetExtensionPart(inputfile.s))="avs" DeleteFile(workpath.s+"MicroX264.avs") CopyFile(inputfile.s,workpath.s+"MicroX264.avs") EndIf encostring.s=Chr(34)+here.s+"application\avs2yuv.exe"+Chr(34)+" "+Chr(34)+workpath.s+"MicroX264.avs"+Chr(34)+" - | " encostring.s=encostring.s+Chr(34)+here.s+"application\x264.exe"+Chr(34)+" - --stdin y4m " If passx.l=1 : encostring.s=encostring.s+"--bitrate "+StrF(bitrate.f,0)+" " : EndIf If passx.l=2 : encostring.s=encostring.s+"--pass 1 --bitrate "+StrF(bitrate.f,0)+" " : EndIf If passx.l=3 : encostring.s=encostring.s+"--pass 2 --bitrate "+StrF(bitrate.f,0)+" " : EndIf If passx.l=4 : encostring.s=encostring.s+"--crf "+StrF(bitrate.f,0)+" ": EndIf If passx.l=5 : encostring.s=encostring.s+"--crf "+StrF(bitrate.f,0)+" --pass 1 ": EndIf If passx.l=7 : encostring.s=encostring.s+"--pass 2 --bitrate %bitrate% " : EndIf If passx.l=8 : encostring.s=encostring.s+"--qp "+StrF(bitrate.f,0)+" ": EndIf encostring.s=encostring.s+"--threads auto --thread-input " If GetGadgetText(#preset)<>"No Preset" : encostring.s=encostring.s+"--preset "+GetGadgetText(#preset)+" " : EndIf If GetGadgetText(#tuning)<>"none" : encostring.s=encostring.s+"--tune "+LCase(GetGadgetText(#tuning))+" " : EndIf If GetGadgetText(#x264mod)<>"" : encostring.s=encostring.s+" "+LCase(GetGadgetText(#x264mod))+" " : EndIf encostring.s=encostring.s+" --output "+Chr(34)+workpath.s+"MicroX264.h264"+Chr(34) If passx.l=5 : encostring.s=encostring.s+" 2>temp.txt" : EndIf If passx.l=6 : encostring.s="FOR /F "+Chr(34)+"tokens=7 delims=. "+Chr(34)+" %%A IN ('findstr encoded temp.txt') DO SET bitrate=%%A" : EndIf AddGadgetItem(#joblist,-1,encostring.s) If GetGadgetText(#audiocodec)="None" If passx.l=1 Or passx.l=3 Or passx.l=4 Or passx.l=7 Or passx.l=8 If GetExtensionPart(GetGadgetText(#outputfile))="mkv" encostring.s=Chr(34)+here.s+"application\mkvmerge.exe"+Chr(34)+" -o "+Chr(34)+GetGadgetText(#outputfile)+Chr(34)+" --default-duration 0:"+StrF(framerate.f,3)+"fps "+Chr(34)+workpath.s+"MicroX264.h264"+Chr(34)+" " AddGadgetItem(#joblist,-1,encostring.s) EndIf If GetExtensionPart(GetGadgetText(#outputfile))="mp4" encostring.s=Chr(34)+here.s+"application\mp4box.exe"+Chr(34)+" -add "+Chr(34)+workpath.s+"MicroX264.h264"+Chr(34)+" -fps "+StrF(framerate.f,3)+" " encostring.s=encostring.s+" "+Chr(34)+GetGadgetText(#outputfile)+Chr(34) AddGadgetItem(#joblist,-1,encostring.s) EndIf If GetExtensionPart(GetGadgetText(#outputfile))="h264" encostring.s="move "+Chr(34)+workpath.s+"MicroX264.h264"+Chr(34)+" "+Chr(34)+GetGadgetText(#outputfile)+Chr(34) AddGadgetItem(#joblist,-1,encostring.s) EndIf EndIf EndIf If GetGadgetText(#audiocodec)<>"None" If passx.l=1 Or passx.l=3 Or passx.l=4 Or passx.l=7 Or passx.l=8 If FindString(LCase(GetGadgetText(#beforeresize)),"yadif",0) And FindString(LCase(GetGadgetText(#beforeresize)),"mode=1",0) framerate.f=framerate.f*2 EndIf If GetGadgetText(#audiocodec)="Aac" encostring.s=Chr(34)+here.s+"application\wavi.exe"+Chr(34)+" "+Chr(34)+workpath.s+"MicroX264.avs"+Chr(34)+" - | "+Chr(34)+here.s+"application\neroaacenc.exe"+Chr(34)+" -if - -q "+StrF((Val(GetGadgetText(#audiobitrate))/100),2)+" -ignorelength -of "+Chr(34)+workpath.s+"MicroX264.mp4"+Chr(34) AddGadgetItem(#joblist,-1,encostring.s) EndIf If GetGadgetText(#audiocodec)="Ogg Vorbis" encostring.s=Chr(34)+here.s+"application\wavi.exe"+Chr(34)+" "+Chr(34)+workpath.s+"MicroX264.avs"+Chr(34)+" - | "+Chr(34)+here.s+"application\oggenc2.exe"+Chr(34)+" - -q "+StrF((Val(GetGadgetText(#audiobitrate))/10),2)+" -o "+Chr(34)+workpath.s+"MicroX264.ogg"+Chr(34) AddGadgetItem(#joblist,-1,encostring.s) EndIf If GetExtensionPart(GetGadgetText(#outputfile))="mkv" encostring.s=Chr(34)+here.s+"application\mkvmerge.exe"+Chr(34)+" -o "+Chr(34)+GetGadgetText(#outputfile)+Chr(34)+" --default-duration 0:"+StrF(framerate.f,3)+"fps "+Chr(34)+workpath.s+"MicroX264.h264"+Chr(34)+" " If GetGadgetText(#audiocodec)="Aac" : encostring.s=encostring.s+Chr(34)+workpath.s+"MicroX264.mp4"+Chr(34) : EndIf If GetGadgetText(#audiocodec)="Ogg Vorbis" : encostring.s=encostring.s+Chr(34)+workpath.s+"MicroX264.ogg"+Chr(34) : EndIf AddGadgetItem(#joblist,-1,encostring.s) EndIf If GetExtensionPart(GetGadgetText(#outputfile))="mp4" encostring.s=Chr(34)+here.s+"application\mp4box.exe"+Chr(34)+" -add "+Chr(34)+workpath.s+"MicroX264.h264"+Chr(34)+" -fps "+StrF(framerate.f,3)+" " If GetGadgetText(#audiocodec)="Aac" : encostring.s=encostring.s+" -add "+Chr(34)+workpath.s+"MicroX264.mp4"+Chr(34) : EndIf If GetGadgetText(#audiocodec)="Ogg Vorbis" : encostring.s=encostring.s+" -add "+Chr(34)+workpath.s+"MicroX264.ogg"+Chr(34) : EndIf encostring.s=encostring.s+" "+Chr(34)+GetGadgetText(#outputfile)+Chr(34) AddGadgetItem(#joblist,-1,encostring.s) EndIf If GetExtensionPart(GetGadgetText(#outputfile))="h264" encostring.s="move "+Chr(34)+workpath.s+"MicroX264.h264"+Chr(34)+" "+Chr(34)+GetGadgetText(#outputfile)+Chr(34) If GetGadgetText(#audiocodec)="Aac" : encostring.s=encostring.s+Chr(13)+"move "+Chr(34)+workpath.s+"MicroX264.mp4"+Chr(34)+" "+Chr(34)+GetGadgetText(#outputfile)+"_audio.mp4"+Chr(34) : EndIf If GetGadgetText(#audiocodec)="Ogg Vorbis" : encostring.s=encostring.s+Chr(13)+"move "+Chr(34)+workpath.s+"MicroX264.ogg"+Chr(34)+" "+Chr(34)+GetGadgetText(#outputfile)+"_audio.ogg"+Chr(34) : EndIf AddGadgetItem(#joblist,-1,encostring.s) EndIf EndIf EndIf EndProcedure Procedure addtoqueue() If GetGadgetText(#x264way)="Avisynth (avs2yuv)" x264avs() EndIf If GetGadgetText(#x264way)="lavf (need X264 with lavf support)" x264lavf() EndIf If GetGadgetText(#x264way)="ffms (need X264 with ffms support)" x264lavf() EndIf If GetGadgetText(#x264way)="avs (need X264 with avs support)" x264lavf() EndIf If GetGadgetText(#x264way)="auto (need X264 with auto support)" x264lavf() EndIf EndProcedure Procedure.l RunProgramEx(filename.s,parameter.s,directory.s,showflag.l) info\wShowWindow =showflag processpriority=#IDLE_PRIORITY_CLASS If CreateProcess_(@filename,@parameter,0,0,0,processpriority,0,@directory,@info,@processinfo) CloseHandle_(processinfo\hProcess) CloseHandle_(processinfo\hThread) EndIf EndProcedure Procedure autocrop() CreateFile(987,here.s+"autocrop.avs") If ExamineDirectory(0,here+"filters\","*.dll") Repeat type=NextDirectoryEntry(0) If type=1 ; File a$=DirectoryEntryName(0) If FindString(a$,"SoundOut",0)=0 And FindString(a$,"yadif",0)=0 WriteStringN(987,"LoadPlugin("+Chr(34)+here+"filters\"+a$+Chr(34)+")") EndIf If FindString(a$,"yadif",0)<>0 WriteStringN(987,"LoadCPlugin("+Chr(34)+here+"filters\"+a$+Chr(34)+")") EndIf EndIf Until type=0 EndIf If ExamineDirectory(0,here+"filters\","*.avsi") Repeat type=NextDirectoryEntry(0) If type=1 ; File a$=DirectoryEntryName(0) If FindString(a$,"QMF",0)=0 WriteStringN(987,"Import("+Chr(34)+here+"filters\"+a$+Chr(34)+")") EndIf EndIf Until type=0 EndIf Select LCase(GetExtensionPart(inputfile.s)) Case "avi","mpeg","m2v","mpg","ogm","vro" WriteStringN(987,"FFVideoSource("+Chr(34)+inputfile.s+Chr(34)+")") Case "evo","m2ts","ts","mts","mkv","grf","m2t","mov","mp4","vob" WriteStringN(987,"DirectShowSource("+Chr(34)+inputfile.s+Chr(34)+",audio=false)") Case "avs" WriteStringN(987,"Import("+Chr(34)+inputfile.s+Chr(34)+")") Case "d2v" WriteStringN(987,"Mpeg2Source("+Chr(34)+inputfile.s+Chr(34)+")") Case "dgm","dgv" WriteStringN(987,"DGSource("+Chr(34)+inputfile.s+Chr(34)+")") Case "dga" WriteStringN(987,"AVCSource("+Chr(34)+inputfile.s+Chr(34)+")") Case "dgi" WriteStringN(987,"DGMultiSource("+Chr(34)+inputfile.s+Chr(34)+")") EndSelect WriteStringN(987,"last = ConvertToYV12(last)") WriteStringN(987,"sep="+Chr(34)+" "+Chr(34)) WriteStringN(987,"WriteFile("+Chr(34)+here.s+"info.txt"+Chr(34)+", "+Chr(34)+"Framecount"+Chr(34)+","+Chr(34)+"sep"+Chr(34)+","+Chr(34)+"Framerate"+Chr(34)+","+Chr(34)+"sep"+Chr(34)+","+Chr(34)+"WIDTH"+Chr(34)+","+Chr(34)+"sep"+Chr(34)+","+Chr(34)+"HEIGHT"+Chr(34)+")") WriteStringN(987,"autocrop(mode=2,wmultof=4,hmultof=16,samples=34,threshold=28)") WriteStringN(987,"trim(0,1)") CloseFile(987) RunProgram(here.s+"application\x264.exe"," --preset ultrafast --output "+Chr(34)+here.s+"autocrop.h264"+Chr(34)+" "+Chr(34)+here.s+"autocrop.avs"+Chr(34),here.s,#PB_Program_Wait) If ReadFile(gz,here.s+"info.txt") While Eof(gz) = #False gzs.s = ReadString(gz) framecount.l=Val(StringField(gzs.s,0," ")) framerate.f=ValF(StringField(gzs.s,2," ")) twidth.l=Val(StringField(gzs.s,3," ")) theight.l=Val(StringField(gzs.s,4," ")) tsec.l=Int(framecount.l/framerate.f)+1 Wend CloseFile(gz) EndIf If ReadFile(669,here.s+"AutoCrop.log") While Eof(669) = #False line.s = ReadString(669) ;Crop(0,72,720,432) Crop(14,140,1892,800) acleft.l=Val(Mid(StringField(line.s,1,","),6,5)) actop.l=Val(StringField(line.s,2,",")) acwidth.l=Val(StringField(line.s,3,",")) acheight.l=Val(Mid(StringField(line.s,4,","),0,Len(StringField(line.s,4,","))-1)) Wend CloseFile(669) acbottom.l=theight.l-acheight.l-actop.l acright.l=twidth.l-acwidth.l-acleft.l EndIf SetGadgetText(#leftcrop,Str(acleft)) SetGadgetText(#topcrop,Str(actop)) SetGadgetText(#rightcrop,Str(acright)) SetGadgetText(#bottomcrop,Str(acbottom)) SetGadgetText(#crop,Str(acleft.l)+","+Str(actop.l)+","+Str(acright.l)+","+Str(acbottom.l)) EndProcedure Procedure preview() CreateFile(987,here.s+"preview.avs") If ExamineDirectory(0,here+"filters\","*.dll") Repeat type=NextDirectoryEntry(0) If type=1 ; File a$=DirectoryEntryName(0) If FindString(a$,"SoundOut",0)=0 And FindString(a$,"yadif",0)=0 WriteStringN(987,"LoadPlugin("+Chr(34)+here+"filters\"+a$+Chr(34)+")") EndIf If FindString(a$,"yadif",0)<>0 WriteStringN(987,"LoadCPlugin("+Chr(34)+here+"filters\"+a$+Chr(34)+")") EndIf EndIf Until type=0 EndIf If ExamineDirectory(0,here+"filters\","*.avsi") Repeat type=NextDirectoryEntry(0) If type=1 ; File a$=DirectoryEntryName(0) If FindString(a$,"QMF",0)=0 WriteStringN(987,"Import("+Chr(34)+here+"filters\"+a$+Chr(34)+")") EndIf EndIf Until type=0 EndIf Select LCase(GetExtensionPart(inputfile.s)) Case "vob","avi","mpeg","m2v","mpg","ogm","vro" WriteStringN(987,"FFVideoSource("+Chr(34)+inputfile.s+Chr(34)+")") Case "evo","m2ts","ts","mts","mkv","grf","m2t","mov","mp4" WriteStringN(987,"DirectShowSource("+Chr(34)+inputfile.s+Chr(34)+",audio=false)") Case "avs" WriteStringN(987,"Import("+Chr(34)+inputfile.s+Chr(34)+")") Case "d2v" WriteStringN(987,"Mpeg2Source("+Chr(34)+inputfile.s+Chr(34)+")") Case "dgm","dgv" WriteStringN(987,"DGSource("+Chr(34)+inputfile.s+Chr(34)+")") Case "dga" WriteStringN(987,"AVCSource("+Chr(34)+inputfile.s+Chr(34)+")") Case "dgi" WriteStringN(987,"DGMultiSource("+Chr(34)+inputfile.s+Chr(34)+")") EndSelect WriteStringN(987,"last = ConvertToYV12(last)") If GetGadgetText(#beforeresize)<>"" : WriteStringN(987,GetGadgetText(#beforeresize)) : EndIf leftcrop.l=Val(GetGadgetText(#leftcrop)) topcrop.l=Val(GetGadgetText(#topcrop)) rightcrop.l=Val(GetGadgetText(#rightcrop)) bottomcrop.l=Val(GetGadgetText(#bottomcrop)) If GetGadgetText(#resize)<>"" If CountString(GetGadgetText(#resize),",")=1 width.l=Val(StringField(GetGadgetText(#resize),1,",")) height.l=Val(StringField(GetGadgetText(#resize),2,",")) EndIf EndIf If width.l<>0 And height.l<>0 WriteStringN(987,GetGadgetText(#resizer)+"("+Str(width.l)+","+Str(height.l)+","+Str(leftcrop.l)+","+Str(topcrop.l)+",-"+Str(rightcrop.l)+",-"+Str(bottomcrop)+")") EndIf If width.l=0 And height.l=0 If leftcrop.l+topcrop.l+rightcrop.l+bottomcrop.l<>0 WriteStringN(987,"Crop(last,"+Str(leftcrop.l)+","+Str(topcrop.l)+",-"+Str(rightcrop.l)+",-"+Str(bottomcrop)+")") EndIf EndIf If GetGadgetText(#afterresize)<>"" : WriteStringN(987,GetGadgetText(#afterresize)) : EndIf CloseFile(987) RunProgram("wmplayer",Chr(34)+here.s+"preview.avs"+Chr(34),here.s) EndProcedure Procedure defload() If ReadFile(fh,here.s+"microx264.ini") While Eof(fh)=#False line.s=ReadString(fh) If FindString(line.s,"Encoding Mode",0) : SetGadgetText(#encodingmode,StringField(line.s,2,"=")) : EndIf If FindString(line.s,"Preset",0) : SetGadgetText(#preset,StringField(line.s,2,"=")) : EndIf If FindString(line.s,"Tuning",0) : SetGadgetText(#tuning,StringField(line.s,2,"=")): EndIf If FindString(line.s,"Bitrate",0) : SetGadgetText(#bitrate,StringField(line.s,2,"=")) : EndIf If FindString(line.s,"Audio Codec",0) : SetGadgetText(#audiocodec,StringField(line.s,2,"=")) : EndIf If FindString(line.s,"Audio Quality",0) : SetGadgetState(#audiobitrate,Val(StringField(line.s,2,"="))) : EndIf If FindString(line.s,"Normalize",0) : SetGadgetState(#normalize,Val(StringField(line.s,2,"="))) : EndIf If FindString(line.s,"Custom x264",0) : SetGadgetText(#x264mod,StringField(line.s,2,"=")) : EndIf If FindString(line.s,"MT Mode=1",0) : SetGadgetState(#avsmt,1) : EndIf If FindString(line.s,"MT Value",0) : SetGadgetText(#avsmtvalue,StringField(line.s,2,"=")) : EndIf If FindString(line.s,"Resizer",0) : SetGadgetText(#resizer,StringField(line.s,2,"=")) : EndIf If FindString(line.s,"Before Resize",0) : SetGadgetText(#beforeresize,StringField(line.s,2,"#")) : EndIf If FindString(line.s,"After Resize",0) : SetGadgetText(#afterresize,StringField(line.s,2,"#")) : EndIf If FindString(line.s,"Force DSS=1",0) : dss.l=1 : EndIf Wend CloseFile(fh) EndIf EndProcedure Procedure start() CreateFile(666,workpath.s+"queue.bat") WriteStringN(666,GetGadgetText(#joblist)) CloseFile(666) RunProgramEx(workpath.s+"queue.bat","",workpath.s,#SW_MINIMIZE) EndProcedure dss.l=0 OpenWindow_Window_0() If FileSize(here.s+"microx264.ini")<>-1 : defload() : EndIf If FileSize(here.s+"HDConvertToX_profile.txt")<>-1 ReadFile(fh,here.s+"HDConvertToX_profile.txt") While Eof(fh)=#False line.s=ReadString(fh) If FindString(line.s,"X264;",0) : AddGadgetItem(#x264mod,-1,StringField(line.s,4,";")) : EndIf Wend CloseFile(fh) EndIf Repeat Event = WaitWindowEvent() Select Event Case #PB_Event_Gadget EventGadget = EventGadget() EventType = EventType() If EventGadget = #encodingmode If GetGadgetText(#encodingmode)="CRF Mode" SetGadgetText(#Text_14,"CRF value:") ElseIf GetGadgetText(#encodingmode)="QP Mode" SetGadgetText(#Text_14,"QP value:") Else SetGadgetText(#Text_14,"Bitrate value:") EndIf ElseIf EventGadget = #preview : preview() ElseIf EventGadget = #autocrop : autocrop() ElseIf EventGadget = #deletejob ClearGadgetItems(#joblist) DisableGadget(#start,1) ElseIf EventGadget = #inputbutton If GetPathPart(GetGadgetText(#input))<>"" : last.s=GetPathPart(GetGadgetText(#input)) : EndIf inputfile.s=OpenFileRequester("Open File to Encode", last.s, "Supported Movie File|*VOB;*.EVO;*.M2TS;*.TS;*.MTS;*.MKV;.GRF;*.m2t;*.mpeg;*.m2v;*.mpg;*.avs;*.d2v;*.dga;*.dgi;*.vro;*.avi;*.grf;*.264;*.h264;*.mp4;*.mov;*.dgm;*.dgv;*.ogm|Encode Audio file|All files|*.*",0) If inputfile.s<>"" twidth.l=0 theight.l=0 SetGadgetText(#input,inputfile.s) outputfile.s=SaveFileRequester("Save output file",GetPathPart(inputfile.s)+Mid(GetFilePart(inputfile.s),0,Len(GetFilePart(inputfile.s))-1-Len(GetExtensionPart(inputfile.s)))+"_MX","*.mkv|*.mkv|*.mp4|*.mp4|*.h264|*.h264",0) index=SelectedFilePattern() If outputfile.s<>"" If index=0 : outputfile.s=outputfile.s+".mkv" : EndIf If index=1 : outputfile.s=outputfile.s+".mp4" : EndIf If index=2 : outputfile.s=outputfile.s+".h264" : EndIf SetGadgetText(#outputfile,outputfile.s) EndIf EndIf ElseIf EventGadget = #start start() ElseIf EventGadget = #addjob DisableGadget(#start,0) If GetGadgetText(#encodingmode)="1 pass" : passx.l=1 : addtoqueue() : EndIf If GetGadgetText(#encodingmode)="2 pass" passx.l=2 : addtoqueue() passx.l=3 : addtoqueue() EndIf If GetGadgetText(#encodingmode)="1 pass + CRF Mode" passx.l=5 : addtoqueue() passx.l=6 : addtoqueue() passx.l=7 : addtoqueue() EndIf If GetGadgetText(#encodingmode)="CRF Mode" : passx.l=4 : addtoqueue() : EndIf If GetGadgetText(#encodingmode)="QP Mode" : passx.l=8 : addtoqueue() : EndIf EndIf ; //////////////////////// Case #PB_Event_CloseWindow EventWindow = EventWindow() If EventWindow = #Window_0 CloseWindow(#Window_0) Break EndIf EndSelect ForEver ; IDE Options = PureBasic 4.40 (Windows - x86) ; CursorPosition = 703 ; FirstLine = 698 ; Folding = --- ; EnableXP ; EnableUser ; EnableOnError ; UseIcon = ___logo.ico ; Executable = MicroX264.exe ; DisableDebugger ; CompileSourceDirectory ; EnableCompileCount = 290 ; EnableBuildCount = 23 ; EnableExeConstant