-- plugin info variableslocal name = "x264 info"local desc = "Prints status/info from modded x264 build."local version = "0.1"-- register pluginfunction xchat_register() return name, desc, versionend-- initialize pluginfunction xchat_init() local help = "x264: Prints status/info from modded x264 build." xchat.hook_command("x264", "cmd_x264info", xchat.PRI_NORM, help) xchat.print("x264 info " .. version .. " loaded.")end-- for use with while loopslocal i-- round to nearest decimal (idp)function round(num,idp) local mult = 10^(idp or 0) return math.floor(num * mult + 0.5) / multend-- port of php's explode functionfunction explode(div,str) if (div=='') then return false end local pos,arr = 0,{} for st,sp in function() return string.find(str,div,pos,true) end do table.insert(arr,string.sub(str,pos,st-1)) pos = sp +1 end table.insert(arr,string.sub(str,pos)) return arrend-- return size of file in bytesfunction size(file) file = assert(io.open(file)) local size = file:seek("end") file:close() return sizeend-- returns filesize or projected filesizefunction fsize(ostring,cstring,perc) local file,fsize,unit,temp if (string.find(ostring,"^%a:\\")) then file = ostring elseif (string.find(ostring,"^\\")) then local temp1 = explode("\\",cstring) file = (temp1[1] .. "" .. ostring) else file = (cstring .. "\\" .. ostring) end if (ostring == "NUL") then fsize = 0 else fsize = size(file) end if (perc) then fsize = (fsize/perc)*100 end i = 1024 while(i <= 1024^3) do if (fsize >= 1024) then fsize = fsize/1024 if (i == 1024) then unit = "KB" elseif (i == 1024^2) then unit = "MB" elseif (i == 1024^3) then unit = "GB" end end i = i * 1024 end i = 0 temp = round(fsize,2) if (temp == 0) then return "N/A" else return (temp .. " " .. unit) endend-- returns filename from windows pathfunction filename(instring) local slash = explode('\\',instring) return slash[table.getn(slash)]end-- returns progress bar textfunction bar(perc) local bar,num num = round(tonumber(perc)*.1,0)*10 bar = "" i = 10 while (i <= 100) do if (tonumber(num) >= i) then bar = (bar .. "05|") else bar = (bar .. "15-") end i = i + 10 end i = 0 return barend-- parses info file and prints resultsfunction cmd_x264info() local handle = assert(io.open("C:/x264.output","r")) local contents = handle:read("*all") handle:close() local array = explode(":::",contents) local f_info = {} if (tonumber(array[2]) == 0) then f_info[1] = "N/A"; f_info[2] = "15----------" else f_info[1] = (round((array[1]/array[2])*100,1) .. "%") f_info[2] = bar(round((array[1]/array[2])*100,1)) end f_info[3] = filename(array[7]) f_info[4] = fsize(array[9],array[8]) f_info[5] = fsize(array[9],array[8],(array[1]/array[2])*100) xchat.command("SAY 05[15x26405] [15File: " .. f_info[3] .. "05] [15" .. f_info[1] .. "05] [" .. f_info[2] .. "05] [15" .. array[1].. "/" ..array[2] .." frames encoded at " .. array[3].. " fps05] [15ETA: " .. array[4] .. ":" .. array[5] .. ":" .. array[6].. "05] [15Filesize: " .. f_info[4] .. "05] [15Proj. Filesize: " .. f_info[5].. "05]") return xchat.EAT_XCHATend