]> git.sesse.net Git - nageru-docs/blob - futatabi.rst
Add a section on producer cooperation.
[nageru-docs] / futatabi.rst
1 Futatabi: Real-time instant replay with slow motion
2 ===================================================
3
4 Futatabi (after the Japanese word *futatabi*, 再び, meaning “again” or
5 “for the second time”) is a system for instant replay. Even though Futatabi
6 is meant to be used with Nageru, shares some code with it and is built from
7 the same source distribution, it is a separate
8 application. Futatabi is meant for slow motion for e.g. sports broadcasts, but
9 can also be used as a more generic multitrack recorder for later editing.
10
11 Futatabi supports *interpolated* slow motion, meaning you do not need to buy
12 a high-speed 120 fps camera to get smooth 60 fps output after slowdown—Futatabi
13 will automatically synthesize in-between frames for you during playback.
14 Good interpolation, especially in realtime, is a difficult problem, and not all
15 content will do equally well. Most content should do quite acceptably, especially
16 considering that half of the frames will actually be originals, but you
17 will need to see in practice what actually works for you. Interpolation can
18 also be used for frame rate conversion (e.g. 50 to 59.94 fps).
19
20 Futatabi currently uses a GPU reimplementation of
21 `Fast Optical Flow using Dense Inverse Search (DIS) <https://github.com/tikroeger/OF_DIS>`_
22 by Kroeger et al, together with about half of the algorithm from
23 `Occlusion Reasoning for Temporal Interpolation Using Optical Flow <https://www.microsoft.com/en-us/research/publication/occlusion-reasoning-for-temporal-interpolation-using-optical-flow/>`_
24 (to do the actual interpolation based on the estimated
25 optical flow), although this may change in the future.
26
27 Since Futatabi is part of the Nageru source distribution, its version number
28 mirrors Nageru. Thus, the first version of Futatabi is version 1.8.0,
29 which is the Nageru version when it was first introduced.
30
31
32 System requirements
33 -------------------
34
35 It is strongly recommended to run Futatabi on a separate machine from Nageru,
36 not the least because you probably want a different person to operate the replay
37 while the producer is operating Nageru. (See :ref:`coop`.)
38
39 Like Nageru, Futatabi uses your GPU for nearly all image processing.
40 However, unlike Nageru, Futatabi requires a powerful GPU for interpolation;
41 a GTX 1080 or similar is recommended for interpolated 720p60. (Futatabi
42 was initially developed on a GTX 950, which is passable, but has little
43 performance margin.) If you have a slower GPU and are happy with worse
44 quality, or just wish to test, you can use a faster preset, or turn off
45 interpolation entirely. Futatabi requires OpenGL 4.5 or newer.
46
47 For other required libraries, see :ref:`compile`; when you build Nageru,
48 you also build Futatabi.
49
50
51 Getting started
52 ---------------
53
54 Futatabi always pulls data from Nageru over the network; it doesn't support SDI
55 input or output. Assuming you have a recent version of Nageru (typically one
56 that comes with Futatabi), it is capable of sending all of its cameras as one
57 video stream (see :ref:`futatabiformat`), so you can start Futatabi with
58
59   ./futatabi http://path.to.nageru.host/multicam.mp4
60
61 If you do not have a running Nageru installation, see :ref:`sampledata`.
62
63 Once you are up and connected, Futatabi will start recording all of the frames
64 to disk. This process happens continuously for as long as you have disk space,
65 even if you are playing something back or editing clips, and the streams are
66 displayed in real time in mini-display as they come in. You make replays in
67 the form of *clips* (the top list is the clip list), which are then queued into
68 the *playlist* (the bottom list). Your end result is a live HTTP stream that
69 can be fed back into Nageru as a video input; by default, Futatabi listens
70 on port 9096.
71
72 Futatabi has the concept of a *workspace*, which defaults to your current
73 directory (you can change it with the -d option). This holds all of the
74 recorded frames, all metadata about clips, and preferences set from the menus
75 (interpolation quality and cue point padding).  If you quit Futatabi and
76 restart it (or you go down as the result of a power failure or the likes),
77 it will remember all the state and frames for you.
78
79 .. _basicui:
80
81 Basic UI operations
82 '''''''''''''''''''
83
84 Nageru can be operated using either the keyboard and mouse, or using a MIDI
85 controller with some help of the mouse. In this section, we will be discussing
86 the keyboard and mouse only; see :ref:`midi` for details on using MIDI
87 controllers.
88
89 A clip in the clip list consists simply of an in and an out point; it represents
90 an interval of physical time (although timed to the video clock). A clip in the
91 playlist contains the same information plus some playback parameters, in particular
92 which camera (stream) to play back.
93
94 Clicking the ”Cue in” button, or pressing the A key, will start a new clip in
95 the clip list that begins at the current time. Similarly, clicking the ”Cue
96 out” button, or pressing the S key, will set the end point for said clip.
97 (If you click a button twice, it will overwrite the previous result.)
98 Now it is in a state where you can queue it to the play list (mark the camera
99 you want to use and click the “Queue” button, or Q on the keyboard) for
100 playing, or you can preview them using the “Preview” button (W on the
101 keyboard). Previewing can be done either from the clip list the clip list or
102 the playlist; they will not be interpolated or faded, but will be played back
103 in the right
104
105 You can edit cue points, both in the clip and the playlist, in two ways:
106 Either use the scroll wheel on the mouse, or hold down the left mouse button
107 and scrub left or right. (You can hold down Shift to change ten times as fast,
108 or Alt to change at one-tenth the speed.) You'll see the new cue points as you
109 change them in the preview window. You can also give clips names; these don't
110 mean anything, but can be good references to locate a specific kind of clip
111 for later use. Once you're happy with a playlist, and your producer is ready
112 to cut to your channel, click on the first clip you want to play back and
113 click the “Play” button (space on the keyboard); the result will both be
114 visible in the top screen and go out live over the network to Nageru.
115
116 .. _coop:
117
118 Working with your producer
119 ''''''''''''''''''''''''''
120
121 Generally, we recommend that the producer (Nageru operator) and slow motion
122 operator (Futatabi operator) sit closely together and can communicate verbally.
123 Good cooperation between the two is essential to get a good final product;
124 especially the switches to and from the replays can be a critical point.
125
126 The general rule for working together is fairly obvious: The producer should
127 switch to a replay when there's something to show, and switch away when there's
128 nothing more to show (or, less ideally, when something live takes priority).
129 Generally, when you have a playlist ready, inform your producer; they will
130 count you in (three, two, one, go). At one, start playing so that you have some
131 margin. If the Nageru theme is set up correctly (see :ref:`talkback`), they will
132 know how much is queued up so that they can switch back before the replay runs
133 out, but it doesn't hurt to give a warning up-front. The producer might also
134 be able to request replays of specific events, or ask you to save something
135 for later if they can't show it right now (e.g. a foul situation that wasn't called).
136
137 Replay workflows
138 ----------------
139
140 On top of the basics outlined in :ref:`basicui`, there are many possible
141 workflows; we'll discuss only two. Try out a few and see which ones fit your
142 style and type of event.
143
144 Repeated cue-in
145 '''''''''''''''
146
147 In many sports, you don't necessarily know when a replay-worthy event has happened
148 before it's already happened. However, you may reasonably know when something is
149 *not* happening, and it would be a good time to start a clip if something is happening
150 immediately afterwards. At these points, you can make repeated cue-ins, ie., start
151 a clip without finishing it. As long as you keep making cue-ins, the previous one
152 will be discarded. Once you see that something *is* happening, you can wait until
153 it's done, and then do a cue-out, which gives you a good clip immediately.
154
155 For instance, in a basketball game, you could be seeing a series of uninteresting
156 passes, clicking cue-in on each of them. However, once it looks like there's an
157 opportunity for a score, you can hold and see what happens; if the shot happens,
158 you can click cue-out, and if not, you can go back.
159
160 Before playing the clip, you can make adjustments to the in and out points
161 as detailed above. This will help you trim away any uninteresting lead-ups,
162 or add more margins for fades. If you consistently find that you have too
163 little margin, you can use the *cue point padding* feature (either from the
164 command line using *--cue-point-padding*, or set from the menu). If you set
165 cue point padding to e.g. two seconds, the cue-in point will automatically be set
166 two seconds ago when you cue-in, and the cue-out point will be set two seconds
167 into the future when you cue-out.
168
169
170 Instant clips
171 '''''''''''''
172
173 Like the previous section explained how you generally would know the *start*
174 of an interesting event (at least if discarding most of the candidates),
175 you would be even more sure about the *end* of one. Thus, you can simply wait
176 until something interesting has happened, and then click cue-in immediately
177 followed by cue-out. This will give you a clip of near zero length, ending
178 at the right point. Then, edit this clip to set the starting point as needed,
179 and it's ready to play.
180
181 Again, you can use the cue point padding feature to your advantage; if so,
182 your clips will not be of zero length, but rather of some predefined length
183 given by your chosen cue point padding.
184
185
186 .. _sampledata:
187
188 Sample multicamera data
189 '''''''''''''''''''''''
190
191 Good multicamera sample video is hard to come by, so it can be hard to
192 test or train before an actual event. To alleviate this, I've uploaded some
193 real-world video from the very first event where an early version of Futatabi
194 was tested. (There are some issues with the JPEG quality, but it should
195 largely be unproblematic.) You are free to use these for training or
196 demonstration purposes. Do note that they will not be displayed entirely
197 correctly in most video players (see :ref:`futatabiformat`), although
198 they will certainly be watchable.
199
200 There are two files:
201
202  * `Trøndisk 2018, finals only (MJPEG, 77 GB) <https://storage.sesse.net/trondisk2018-finals-multicam-mjpeg.mkv>`_:
203    The final match, in MJPEG format (about 30 minutes). This can be downloaded
204    and then fed directly to Nageru as if it were a real camera stream
205    (remember the --slow-down-input option).
206  * `Trøndisk 2018, entire tournament (H.264, 74 GB) <https://storage.sesse.net/trondisk2018-multicam-h264.mp4>`_: The entire tournament,
207    with no cuts (about 12 hours). However, due to space and bandwidth
208    constraints, it has been transcoded to H.264 (with some associated
209    quality loss), and needs to be transcoded to MJPEG before Nageru can use it.
210
211 Both files are mixed-resolution, with some cameras at 1080p59.94 and some
212 at 720p59.94 (one even switches between matches, as the camera was replaced).
213 They contain four different camera angles (overview camera on crane, detail camera
214 in tripod, two fixed endzone overhead cameras) with differing quality depending
215 on the camera operators. In short, they should be realistic input material
216 to practice with.
217
218
219 Transferring data to and from Nageru
220 ------------------------------------
221
222 .. _futatabiformat:
223
224 Video format specification
225 ''''''''''''''''''''''''''
226
227 Futatabi expects to get data in MJPEG format only; though MJPEG is old,
228 it yields fairly good quality per bit for an intraframe format, supports
229 4:2:2 without too many issues, and has hardware support through VA-API
230 for both decode (since Ivy Bridge) and encode (since Skylake). The latter
231 is especially important for Futatabi, since there are so many high-resolution
232 streams; software encode/decode of several 1080p60 streams at the same time
233 is fairly taxing on the CPU if done in software. This means we can easily
234 send 4:2:2 camera streams back and forth between Nageru and Futatabi without having
235 to scale or do other lossy processing (except of course the compression itself).
236
237 However, JPEG as such does not have any way of specifying things like color
238 spaces and chroma placement. JFIF, the *de facto* JPEG standard container,
239 specifies conventions that are widely followed, but they do not match what
240 comes out of a capture card. Nageru's multicam export _does_ set the appropriate
241 fields in the output Matroska mux (which is pretty much the only mux that can
242 hold such information), but there are few if any programs that read them and give
243 them priority over JFIF's defaults. Thus, if you want to use the multicam stream
244 for something other than Futatabi, or feed Futatabi with data not from Nageru,
245 there are a few subtle issues to keep in mind.
246
247 In particular:
248
249   * Capture cards typically send limited-range Y'CbCr (luma between 16..235
250     and chroma between 16..240); JFIF is traditionally full-range (0..255
251     for both). (See also :ref:`synthetictests`.) Note that there is a special
252     private JPEG comment added to signal this, which FFmpeg understands.
253   * JFIF, like MPEG, assumes center chroma placement; capture cards and most
254     modern video standards assume left.
255   * JFIF assumes Rec. 601 Y'CbCr coefficients, while all modern HD processing
256     uses Rec. 709 Y'CbCr coefficients. (Futatabi does not care much about
257     the actual RGB color space; Nageru assumes it is Rec. 709, like for capture
258     cards, but the differences between 601 and 709 here are small. sRGB gamma
259     is assumed throughout, like in JFIF.)
260
261 Many players may also be confused by the fact that the resolution can change
262 from frame to frame; this is because for original (uninterpolated) frames,
263 Futatabi will simply output the received JPEG frame directly to the output
264 stream, which can be a different resolution from the interpolated frames.
265
266 Finally, the subtitle track with status information (see :ref:`talkback`) is
267 not marked as metadata due to FFmpeg limitations, and as such will show up
268 raw in subtitle-enabled players.
269
270
271 .. _midi:
272
273 Using MIDI controllers
274 ----------------------
275
276
277 Monitoring
278 ----------
279
280 .. _talkback:
281
282 Tally and status talkback
283 '''''''''''''''''''''''''
284
285 Prometheus metrics
286 ''''''''''''''''''