-
Notifications
You must be signed in to change notification settings - Fork 16
Local Overrides Sample: Rescale Single Camera
bp2008 edited this page Feb 16, 2021
·
9 revisions
This sample demonstrates how to change the video resolution in a camera's metadata, causing it to be rendered at a different aspect ratio. The example code adjusts clips and cameras with resolution 960x1080
to make them render at 1920x1080
. The example code also shows how to override the resolution based on a camera's short name.
This sample requires the Digital Zoom setting "At 1x zoom, match resolution of:" to be set to "Camera", which is the default value.
This sample works best with UI3-141 or newer.
Caveats:
- Does not affect all UI elements that display imagery, only the main video player.
To learn more about ui3-local-overrides, see: Local Overrides Scripts and Styles
// This sample demonstrates how to change the video resolution in a camera's metadata, causing it to be rendered at a different aspect ratio.
// The example code adjusts clips and cameras with resolution 960x1080 to make them render at 1920x1080.
// The example code also shows how to override the resolution based on a camera's short name.
// This sample requires the Digital Zoom setting "At 1x zoom, match resolution of:" to be set to "Camera", which is the default value.
// This sample works best with UI3-141 or newer.
BI_CustomEvent.AddListener("ExecJSON_Success", function (eventArgs)
{
if (eventArgs.args.cmd === "camlist")
EditCameraList(eventArgs.data);
else if (eventArgs.args.cmd === "cliplist" || eventArgs.args.cmd === "alertlist")
EditClipList(eventArgs.data);
});
function EditCameraList(lastResponse)
{
var allCams = lastResponse.data;
for (var i = 0; i < allCams.length; i++)
{
var cam = allCams[i];
if (cam.width === 960 && cam.height === 1080)
{
cam.width = 1920;
if (cam.rects)
{
for (var n = 0; n < cam.rects.length; n++)
{
cam.rects[n][0] *= 2;
cam.rects[n][2] *= 2;
}
}
}
if (cam.optionValue === "porcha")
{
cam.width = 640;
cam.height = 480;
}
}
}
function EditClipList(lastResponse)
{
var allClips = lastResponse.data;
for (var i = 0; i < allClips.length; i++)
{
var clip = allClips[i];
var res = new ClipRes(clip.res);
if (res.valid && res.width === 960 && res.height === 1080)
{
clip.res = "1920x1080";
}
if (clip.camera === "porcha")
{
clip.res = "640x480";
}
}
};