]> git.sesse.net Git - nageru-docs/blob - futatabi.rst
Bump version to 1.8.2.
[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.
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 Basic UI operations
80 '''''''''''''''''''
81
82 Nageru can be operated using either the keyboard and mouse, or using a MIDI
83 controller with some help of the mouse. In this section, we will be discussing
84 the keyboard and mouse only; see :ref:`midi` for details on using MIDI
85 controllers.
86
87 A clip in the clip list consists simply of an in and an out point; it represents
88 an interval of physical time (although timed to the video clock). A clip in the
89 playlist contains the same information plus some playback parameters, in particular
90 which camera (stream) to play back.
91
92 Clicking the ”Cue in” button, or pressing the A key, will start a new clip in
93 the clip list that begins at the current time. Similarly, clicking the ”Cue
94 out” button, or pressing the S key, will set the end point for said clip.
95 (If you click a button twice, it will overwrite the previous result.)
96 Now it is in a state where you can queue it to the play list (mark the camera
97 you want to use and click the “Queue” button, or Q on the keyboard) for
98 playing, or you can preview them using the “Preview” button (W on the
99 keyboard). Previewing can be done either from the clip list the clip list or
100 the playlist; they will not be interpolated or faded, but will be played back
101 in the right
102
103 You can edit cue points, both in the clip and the playlist, in two ways:
104 Either use the scroll wheel on the mouse, or hold down the left mouse button
105 and scrub left or right. (You can hold down Shift to change ten times as fast,
106 or Alt to change at one-tenth the speed.) You'll see the new cue points as you
107 change them in the preview window. You can also give clips names; these don't
108 mean anything, but can be good references to locate a specific kind of clip
109 for later use. Once you're happy with a playlist, and your producer is ready
110 to cut to your channel, click on the first clip you want to play back and
111 click the “Play” button (space on the keyboard); the result will both be
112 visible in the top screen and go out live over the network to Nageru.
113
114 On top of these basics, there are many possible workflows; we'll discuss only
115 two. Try out a few and see which ones fit your style and type of event.
116
117 Repeated cue-in
118 '''''''''''''''
119
120 In many sports, you don't necessarily know when a replay-worthy event has happened
121 before it's already happened. However, you may reasonably know when something is
122 *not* happening, and it would be a good time to start a clip if something is happening
123 immediately afterwards. At these points, you can make repeated cue-ins, ie., start
124 a clip without finishing it. As long as you keep making cue-ins, the previous one
125 will be discarded. Once you see that something *is* happening, you can wait until
126 it's done, and then do a cue-out, which gives you a good clip immediately.
127
128 For instance, in a basketball game, you could be seeing a series of uninteresting
129 passes, clicking cue-in on each of them. However, once it looks like there's an
130 opportunity for a score, you can hold and see what happens; if the shot happens,
131 you can click cue-out, and if not, you can go back.
132
133 Before playing the clip, you can make adjustments to the in and out points
134 as detailed above. This will help you trim away any uninteresting lead-ups,
135 or add more margins for fades. If you consistently find that you have too
136 little margin, you can use the *cue point padding* feature (either from the
137 command line using *--cue-point-padding*, or set from the menu). If you set
138 cue point padding to e.g. two seconds, the cue-in point will automatically be set
139 two seconds ago when you cue-in, and the cue-out point will be set two seconds
140 into the future when you cue-out.
141
142
143 Instant clips
144 '''''''''''''
145
146 Like the previous section explained how you generally would know the *start*
147 of an interesting event (at least if discarding most of the candidates),
148 you would be even more sure about the *end* of one. Thus, you can simply wait
149 until something interesting has happened, and then click cue-in immediately
150 followed by cue-out. This will give you a clip of near zero length, ending
151 at the right point. Then, edit this clip to set the starting point as needed,
152 and it's ready to play.
153
154 Again, you can use the cue point padding feature to your advantage; if so,
155 your clips will not be of zero length, but rather of some predefined length
156 given by your chosen cue point padding.
157
158
159 .. _sampledata:
160
161 Sample multicamera data
162 '''''''''''''''''''''''
163
164 Good multicamera sample video is hard to come by, so it can be hard to
165 test or train before an actual event. To alleviate this, I've uploaded some
166 real-world video from the very first event where an early version of Futatabi
167 was tested. (There are some issues with the JPEG quality, but it should
168 largely be unproblematic.) You are free to use these for training or
169 demonstration purposes. Do note that they will not be displayed entirely
170 correctly in most video players (see :ref:`futatabiformat`), although
171 they will certainly be watchable.
172
173 There are two files:
174
175  * `Trøndisk 2018, finals only (MJPEG, 77 GB) <https://storage.sesse.net/trondisk2018-finals-multicam-mjpeg.mkv>`_:
176    The final match, in MJPEG format (about 30 minutes). This can be downloaded
177    and then fed directly to Nageru as if it were a real camera stream
178    (remember the --slow-down-input option).
179  * `Trøndisk 2018, entire tournament (H.264, 74 GB) <https://storage.sesse.net/trondisk2018-multicam-h264.mp4>`_: The entire tournament,
180    with no cuts (about 12 hours). However, due to space and bandwidth
181    constraints, it has been transcoded to H.264 (with some associated
182    quality loss), and needs to be transcoded to MJPEG before Nageru can use it.
183
184 Both files are mixed-resolution, with some cameras at 1080p59.94 and some
185 at 720p59.94 (one even switches between matches, as the camera was replaced).
186 They contain four different camera angles (overview camera on crane, detail camera
187 in tripod, two fixed endzone overhead cameras) with differing quality depending
188 on the camera operators. In short, they should be realistic input material
189 to practice with.
190
191
192 Transferring data to and from Nageru
193 ------------------------------------
194
195 .. _futatabiformat:
196
197 Video format specification
198 ''''''''''''''''''''''''''
199
200 Futatabi expects to get data in MJPEG format only; though MJPEG is old,
201 it yields fairly good quality per bit for an intraframe format, supports
202 4:2:2 without too many issues, and has hardware support through VA-API
203 for both decode (since Ivy Bridge) and encode (since Skylake). The latter
204 is especially important for Futatabi, since there are so many high-resolution
205 streams; software encode/decode of several 1080p60 streams at the same time
206 is fairly taxing on the CPU if done in software. This means we can easily
207 send 4:2:2 camera streams back and forth between Nageru and Futatabi without having
208 to scale or do other lossy processing (except of course the compression itself).
209
210 However, JPEG as such does not have any way of specifying things like color
211 spaces and chroma placement. JFIF, the *de facto* JPEG standard container,
212 specifies conventions that are widely followed, but they do not match what
213 comes out of a capture card. Nageru's multicam export _does_ set the appropriate
214 fields in the output Matroska mux (which is pretty much the only mux that can
215 hold such information), but there are few if any programs that read them and give
216 them priority over JFIF's defaults. Thus, if you want to use the multicam stream
217 for something other than Futatabi, or feed Futatabi with data not from Nageru,
218 there are a few subtle issues to keep in mind.
219
220 In particular:
221
222   * Capture cards typically send limited-range Y'CbCr (luma between 16..235
223     and chroma between 16..240); JFIF is traditionally full-range (0..255
224     for both). (See also :ref:`synthetictests`.) Note that there is a special
225     private JPEG comment added to signal this, which FFmpeg understands.
226   * JFIF, like MPEG, assumes center chroma placement; capture cards and most
227     modern video standards assume left.
228   * JFIF assumes Rec. 601 Y'CbCr coefficients, while all modern HD processing
229     uses Rec. 709 Y'CbCr coefficients. (Futatabi does not care much about
230     the actual RGB color space; Nageru assumes it is Rec. 709, like for capture
231     cards, but the differences between 601 and 709 here are small. sRGB gamma
232     is assumed throughout, like in JFIF.)
233
234 Many players may also be confused by the fact that the resolution can change
235 from frame to frame; this is because for original (uninterpolated) frames,
236 Futatabi will simply output the received JPEG frame directly to the output
237 stream, which can be a different resolution from the interpolated frames.
238
239 Finally, the subtitle track with status information (see :ref:`talkback`) is
240 not marked as metadata due to FFmpeg limitations, and as such will show up
241 raw in subtitle-enabled players.
242
243
244 .. _midi:
245
246 Using MIDI controllers
247 ----------------------
248
249
250 Monitoring
251 ----------
252
253 .. _talkback:
254
255 Tally and status talkback
256 '''''''''''''''''''''''''
257
258 Prometheus metrics
259 ''''''''''''''''''