]> git.sesse.net Git - nageru-docs/blob - hdmisdi.rst
Wrote a bit more about the sources of latency.
[nageru-docs] / hdmisdi.rst
1 HDMI/SDI output
2 ===============
3
4 Sometimes, what you want from a video mixer isn't a stream, just another
5 output that goes to e.g. a projector—or you might want the live stream,
6 but also a monitor output on a separate display. You could of course play
7 the stream on another PC, but for many uses, the end-to-end latency is
8 too high, and you might not want to involve a full extra PC just for this
9 anyway.
10
11 Thus, since 1.5.0, Nageru supports using a spare output card for HDMI/SDI
12 output, turning it into a simple, reasonably low-latency audio/video switcher.
13
14
15 Setting up HDMI/SDI output
16 --------------------------
17
18 Turning on HDMI/SDI output is simple; just right-click on the live view and
19 select the output card. (Equivalently, you can access the same functionality
20 from the _Video_ menu in the regular menu bar.) Currently, this is supported
21 for DeckLink cards only (PCI/Thunderbolt), as the precise output protocol for
22 the Intensity Shuttle cards is still unknown. The stream and recording will
23 keep running just as before.
24
25 A video mode will automatically be picked for you, favoring 59.94 fps if possible,
26 but you can change the mode on-the-fly to something else if you'd like,
27 as long as the resolution matches with what you've set up at program start.
28 Note that whenever HDMI/SDI output is active, the output card will be the
29 master clock; you cannot change it to any of the input cards. This also means
30 that the frame rate you choose here will determine the frame rate for the
31 stream.
32
33
34 A note on latency
35 -----------------
36
37 For a regular stream, a few seconds of latency is usually acceptable
38 (clients will typically buffer at least a few seconds), and thus,
39 working hard to shave off single frames' worth of latency is not worth it.
40 However, for a live output, every millisecond of latency counts;
41 if you have a stage with a projector behind it, 500 ms latency on
42 the projector looks distinctly out of sync with what's happening
43 on stage. Thus, HDMI/SDI output typically has much stricter
44 latency demands than usual streaming.
45
46 Nageru is capable of low latency operation, but not extremely low latency;
47 for instance, it waits for an entire frame to arrive before processing
48 it. (This is a complexity and flexibility tradeoff; anything else would make
49 e.g. scaling nearly impossible.) Well-designed hardware switcher setups can do
50 **cut-through switching** to get latency down to as little as one frame [#]_ or
51 less, ie. 16.7 ms at 60 fps; Nageru can get down to 2–3 frames (50 ms)
52 given the right hardware, and in general, 100 ms isn't hard. 
53
54 .. [#] Since almost all latency in a realtime video setup is caused by processing of various
55        forms and not by length of the cable, most forms of latency will be
56        proportional to the length of a frame. Thus, one will often see latency
57        calculated in terms of number of frames, not milliseconds, and video at
58        higher frame rates will often see less delay. Networking (and by extension
59        streaming) is different; there, jitter and delay is more often caused
60        by propagation and administrative delays, and latency is more often
61        independent of the frame rate.
62
63
64 Typical sources of latency
65 ..........................
66
67 This section aims to illuminate some of the sources of latency and how to deal
68 with them. Note that often, latency is at odds with throughput, and so,
69 tradeoffs must be made. The most important sources of latency are:
70
71  - **Frame transmission latency:** Unlike computer networks, HDMI and SDI
72    transmit their frames pretty much in real time, ie., sending one frame
73    takes one frame of time. For cut-through switching (which includes
74    HDMI → SDI conversion and the other way around), this doesn't really
75    matter, but Nageru has to receive the entire frame before it can start
76    processing it (and by extension, send the result frame out). Thus, you will
77    typically get one frame of latency just by having Nageru, or really any
78    switcher/mixer with digital effects, in the chain at all.
79
80  - **Jitter and queuing latency:** Unless you are lucky enough to have an
81    all-SDI setup where everything runs off of a shared reference clock,
82    frames on different devices, as well as on the output, will be at random
83    offsets from each other (and also drifting slowly, even if they are at
84    the same frame rate). Thus, some sort of *input queue* is needed for each
85    input card, and the time a frame spends in the queue before being picked
86    out for processing is by definition extra latency. (Note that this means
87    that latency is not a single number for the chain as a whole, but can
88    vary by input.)
89
90  - **Processing latency:** By definition, processing of each frame has to take
91    less than one frame's worth of time, or else the system can't keep up.
92    But if you have a fast GPU and/or do little processing, you can spend
93    significantly less. Thus, if you're after the lowest possible latency,
94    a faster GPU might help you shave off a fraction of a frame here.
95
96  - **Output latency:** Finally, cards have their own output queue,
97    and some will expect there to be multiple frames in it before outputting anything.
98    This is outside Nageru's control, unfortunately, but can easily add 2–3
99    frames of latency. If you want to avoid this, look for Blackmagic's “4K” series of
100    cards, which are of a newer, lower-latency design than the previous cards.
101    The 4K series in this context include everything that have “4K” in their
102    names, plus the Mini Recorder, Duo 2 and Quad 2 devices.
103
104 TODO: Write about queuing options. And latency measurements. And audio.
105
106 TODO: Write something about time codes here.
107