local neutral_colors = {
{0.5, 0.5, 0.5}, -- Input 0.
{0.5, 0.5, 0.5}, -- Input 1.
- {0.5, 0.5, 0.5} -- Input 2.
+ {0.5, 0.5, 0.5}, -- Input 2.
+ {0.5, 0.5, 0.5}, -- Input 3.
+ {0.5, 0.5, 0.5} -- Input 4.
}
local overlay_transition_start = -2.0
local live_signal_num = 0
local preview_signal_num = 1
+local NUM_CAMERAS = 5 -- Remember to update neutral_colors, too.
-- Valid values for live_signal_num and preview_signal_num.
local INPUT0_SIGNAL_NUM = 0
local INPUT1_SIGNAL_NUM = 1
local INPUT2_SIGNAL_NUM = 2
-local STATIC_SIGNAL_NUM = 3
+local INPUT3_SIGNAL_NUM = 3
+local INPUT4_SIGNAL_NUM = 4
+local STATIC_SIGNAL_NUM = NUM_CAMERAS
-- Preview-only signal showing the current signal with the overlay.
-- Not valid for live_signal_num!
-local OVERLAY_SIGNAL_NUM = 4
+local OVERLAY_SIGNAL_NUM = NUM_CAMERAS + 1
-- Valid values for transition_type. (Cuts are done directly, so they need no entry.)
local NO_TRANSITION = 0
-- frame and not per field, since we deinterlace.
local last_resolution = {}
-local caspar_input = VideoInput.new("unix:///tmp/caspar.sock")
+local caspar_input = VideoInput.new("unix:///tmp/caspar.sock", Nageru.VIDEO_FORMAT_BGRA)
caspar_input:change_rate(2.0)
-- Utility function to help creating many similar chains that can differ
local input0 = make_fade_input(chain, INPUT0_SIGNAL_NUM, input0_live, input0_deint, input0_scale)
local input1 = make_fade_input(chain, INPUT1_SIGNAL_NUM, input1_live, input1_deint, input1_scale)
+ -- If fading between two live inputs, the overlay is put on top.
+ -- If fading between the static picture and a live input,
+ -- the overlay is put on the live input.
+ local overlay = nil
+ if input0_live and not input1_live then
+ overlay = possibly_make_overlay(has_overlay, chain, input0.last)
+ if overlay then
+ input0.last = overlay.overlay_effect
+ end
+ elseif input1_live and not input0_live then
+ overlay = possibly_make_overlay(has_overlay, chain, input1.last)
+ if overlay then
+ input1.last = overlay.overlay_effect
+ end
+ end
+
local mix_effect = chain:add_effect(MixEffect.new(), input0.last, input1.last)
- local overlay = possibly_make_overlay(has_overlay, chain, mix_effect)
+ if input0_live and input1_live then
+ overlay = possibly_make_overlay(has_overlay, chain, mix_effect)
+ end
chain:finalize(hq)
return make_simple_chain(input_deint, input_scale, has_overlay, hq)
end)
--- A chain to show a single static picture on screen.
+-- A chain to show a single static picture on screen. Never with CasparCG overlay.
local static_chains = make_cartesian_product({
- {true, false}, -- has_overlay
{true, false} -- hq
-}, function(has_overlay, hq)
+}, function(hq)
local chain = EffectChain.new(16, 9)
local chain_input = chain:add_effect(ImageInput.new("tfk_pause.png"))
- local overlay = possibly_make_overlay(has_overlay, chain, chain_input)
chain:finalize(hq)
return {
- chain = chain,
- overlay = overlay
+ chain = chain
}
end)
-- Returns the number of outputs in addition to the live (0) and preview (1).
-- Called only once, at the start of the program.
function num_channels()
- return 5
+ return NUM_CAMERAS + 2 -- static picture and overlay
end
function is_plain_signal(num)
- return num >= INPUT0_SIGNAL_NUM and num <= INPUT2_SIGNAL_NUM
+ return num >= INPUT0_SIGNAL_NUM and num <= INPUT4_SIGNAL_NUM
end
-- Helper function to write e.g. “720p60”. The difference between this
-- channels in case they change resolution.
function channel_name(channel)
local signal_num = channel - 2
- if is_plain_signal(signal_num) then
- return "Input " .. (signal_num + 1) .. " (" .. get_channel_resolution(signal_num) .. ")"
+ if signal_num == INPUT0_SIGNAL_NUM then
+ return "Main (" .. get_channel_resolution(signal_num) .. ")"
+ elseif signal_num == INPUT1_SIGNAL_NUM then
+ return "Secondary (" .. get_channel_resolution(signal_num) .. ")"
+ elseif signal_num == INPUT2_SIGNAL_NUM then
+ return "Goal L (" .. get_channel_resolution(signal_num) .. ")"
+ elseif signal_num == INPUT3_SIGNAL_NUM then
+ return "Goal R (" .. get_channel_resolution(signal_num) .. ")"
+ elseif signal_num == INPUT4_SIGNAL_NUM then
+ return "Ambience (" .. get_channel_resolution(signal_num) .. ")"
elseif signal_num == STATIC_SIGNAL_NUM then
return "Static picture"
elseif signal_num == OVERLAY_SIGNAL_NUM then
-- Called once for each channel, at the start of the program.
-- Will never be called for live (0) or preview (1).
function channel_signal(channel)
- if channel == 2 then
- return 0
- elseif channel == 3 then
- return 1
+ if is_plain_signal(channel) then
+ return channel - 2
else
return -1
end
return channel == (signal_num + 2)
end
if signal_num == STATIC_SIGNAL_NUM then
- return (channel == 5)
+ return (channel == NUM_CAMERAS)
end
return false
end
-- if and only if num==0.
function get_chain(num, t, width, height, signals)
local input_resolution = {}
- for signal_num=0,2 do
+ for signal_num=0,(NUM_CAMERAS-1) do
local res = {
width = signals:get_width(signal_num),
height = signals:get_height(signal_num),
end
return chain.chain, prepare
elseif live_signal_num == STATIC_SIGNAL_NUM then -- Static picture.
- local chain = static_chains[overlay_enabled][true]
+ local chain = static_chains[true]
prepare = function()
prepare_overlay_live(chain, t)
end
return chain.chain, prepare
end
if num == STATIC_SIGNAL_NUM + 2 then
- local chain = static_chains[show_overlay][false]
+ local chain = static_chains[false]
prepare = function()
prepare_overlay_static(chain, t)
end