function OnInit(initData) { initData.name = "Video Frame Columns"; initData.version = "2.0"; initData.copyright = ""; initData.url = ""; initData.desc = "Brings Explorer's Length, Frame Width, Frame Height, Frame Rate, and TotalBitrate columns into Opus."; initData.default_enable = true; initData.min_version = "12.7.3"; var col; var props; props = DOpus.FSUtil.GetShellPropertyList("System.Video.TotalBitrate", "r"); if (props.count == 1) { var prop = props(0); col = initData.AddColumn(); col.name = "TotalBitrate"; col.multicol = true; col.method = "OnCol"; col.label = "T.kbps"; // col.label = prop.display_name; col.justify = "right"; col.type = 'text'; col.autogroup = true; col.autorefresh = 1; col.userdata = prop.pkey; } props = DOpus.FSUtil.GetShellPropertyList("System.Media.Duration", "r"); if (props.count == 1) { var prop = props(0); col = initData.AddColumn(); col.name = "Length"; col.multicol = true; col.method = "OnCol"; col.label = "Len"; // col.label = prop.display_name; col.justify = "right"; col.autogroup = true; col.autorefresh = 1; col.userdata = prop.pkey; } propsSampleRate = DOpus.FSUtil.GetShellPropertyList("System.Audio.SampleRate", "r"); if (propsSampleRate.count == 1) { var prop = propsSampleRate(0); col = initData.AddColumn(); col.name = "SampleRate"; col.multicol = true; col.method = "OnCol"; col.label = "Samples"; // col.label = prop.display_name; col.justify = "right"; col.autogroup = true; col.autorefresh = 1; col.userdata = prop.pkey; col.type = "double"; } propsHeight = DOpus.FSUtil.GetShellPropertyList("System.Video.FrameHeight", "r"); if (propsHeight.count == 1) { var prop = propsHeight(0); col = initData.AddColumn(); col.name = "FrameHeight"; col.multicol = true; col.method = "OnCol"; col.label = "frameH"; // col.label = prop.display_name; col.justify = "right"; col.autogroup = true; col.autorefresh = 1; col.userdata = prop.pkey; col.type = "number"; } propsWidth = DOpus.FSUtil.GetShellPropertyList("System.Video.FrameWidth", "r"); if (propsWidth.count == 1) { var prop = propsWidth(0); col = initData.AddColumn(); col.name = "FrameWidth"; col.multicol = true; col.method = "OnCol"; col.label = "frameW"; // col.label = prop.display_name; col.justify = "right"; col.autogroup = true; col.autorefresh = 1; col.userdata = prop.pkey; col.type = "number"; } if (propsHeight.count == 1 && propsWidth.count == 1) { col = initData.AddColumn(); col.name = "Dimensions"; col.multicol = true; col.method = "OnCol"; col.label = "frameSize"; col.justify = "right"; col.autogroup = false; col.userdata = DOpus.Create.Vector(propsHeight(0).pkey+"", propsWidth(0).pkey+""); } props = DOpus.FSUtil.GetShellPropertyList("System.Video.FrameRate", "r"); if (props.count == 1) { var prop = props(0); col = initData.AddColumn(); col.name = "FrameRate"; col.multicol = true; col.method = "OnCol"; col.label = "Fps"; // col.label = prop.display_name; col.justify = "right"; col.autogroup = true; col.autorefresh = 1; col.userdata = prop.pkey; col.type = "double"; } } function OnCol(scriptColData) { try { var fileItem = scriptColData.item; var width; var height; var triedWidth = false; var triedHeight = false; for (var e = new Enumerator(scriptColData.columns); !e.atEnd(); e.moveNext()) { var colName = e.item(); var colData = scriptColData.columns(colName); if (colName == "Dimensions") { if (!triedHeight) { height = fileItem.shellprop(colData.userdata(0)); triedHeight = true; } if (!triedWidth) { width = fileItem.shellprop(colData.userdata(1)); triedWidth = true; } if (typeof(height) == "number" && typeof(width) == "number") { colData.value = width + "x" + height; colData.sort = DOpus.Create.Vector(width, height); } else { colData.value = ""; // Ensure we set a value so we don't get asked again for this column. } } else { if (colName == "FrameHeight") { if (!triedHeight) { height = fileItem.shellprop(colData.userdata); triedHeight = true; } colData.value = height; } else if (colName == "FrameWidth") { if (!triedWidth) { width = fileItem.shellprop(colData.userdata) triedWidth = true; } colData.value = width; } else { colData.value = fileItem.shellprop(colData.userdata); } // ================================================ if (typeof(colData.value) == "number") { if (colName == "TotalBitrate") { if (colData.value > 0) { var kbps = colData.value / 1000; colData.value = Math.floor(kbps); } else { colData.value = ""; } } else if (colName == "SampleRate") { colData.value = (colData.value /= 1000).toFixed(1) + " kHz"; } else if (colName == "FrameRate") { colData.value = (colData.value /= 1000).toFixed(2); } else if (colName == "Length") { var seconds = colData.value / 10000000; colData.sort = seconds; var hours = Math.floor(seconds / 3600); seconds %= 3600; var minutes = Math.floor(seconds / 60); seconds = Math.floor(seconds%60); colData.value = hours + ":" + ZeroPad(minutes,2) + ":" + ZeroPad(seconds,2); } } else { colData.value = ""; // Ensure we set a value so we don't get asked again for this column. } } } } catch (e) { scriptColData.value = ""; return; } } function ZeroPad(n, digits) { var s = n + ""; while (s.length < digits) { s = "0" + s; } return s; }