Credit Andrea with major explanations to clarify Sar, Dar, Par, anamorphic, and W...
[goodguy/cin-manual-latex.git] / parts / Attributes.tex
1 \chapter{Project and Media Attributes}%
2 \label{cha:project_and_media_attributes}
3 \index{project attributes}
4 \index{format}
5 \index{settings}
6
7 When you play media files in \CGG{}, the media files have a certain
8 number of tracks, frame size, sample size, and so on.  No matter
9 what attributes the media file has, it is played back according to
10 the project attributes.  So, if an audio file's sample rate is
11 different than the project attributes, it is resampled.  Similarly,
12 if a video file's frame size is different than the project
13 attributes, the video is composited on a black frame, either cropped
14 or bordered with black.
15
16 The project attributes are adjusted in \texttt{Settings $\rightarrow$
17 Format} (figure~\ref{fig:set-format}) or can be created in
18 \texttt{File $\rightarrow$ New}.  When you adjust project settings
19 in \texttt{File $\rightarrow$ New}, a new empty timeline is created.
20 Every timeline created from this point on uses the same settings.
21 When you adjust settings in \texttt{Settings $\rightarrow$ Format},
22 media on the timeline is left unchanged.  But every timeline created
23 from this point uses the same settings.
24
25 \begin{figure}[htpb]\centering
26 \includegraphics[width=0.6\linewidth]{set-format.png}
27   \caption{Set Format window - note the Audio Channel positions}
28   \label{fig:set-format}
29 \end{figure}
30
31 In addition to the standard settings for sample rate, frame rate,
32 and frame size (canvas size), \CGG{} uses some less traditional settings like
33 channel positions, color model, and aspect ratio.  The aspect ratio
34 refers to the display aspect ratio (DAR).
35
36 Edit decision lists , the EDL \index{EDL} stored in XML, save the project
37 settings.  Formats which contain media but no edit decisions just
38 add data to the tracks.  Keep in mind details such as if your
39 project sample rate is 48\,kHz and you load a sound file with
40 96\,kHz, you will still be playing it at 48\,kHz.  Or if you load an
41 EDL file at 96\,kHz and the current project sample rate is 48\,kHz,
42 you will change it to 96\,kHz.
43
44 The New Project window has some options that are different than the
45 Set Format window as you can see by comparing
46 figure~\ref{fig:set-format} above with this
47 figure~\ref{fig:new-project}.  Mostly notably is the field for a
48 directory path and a Project Name.
49
50 \begin{figure}[htpb] \centering
51 \includegraphics[width=0.7\linewidth]{new-project.png}
52   \caption{New Project dialog window}
53   \label{fig:new-project}
54 \end{figure}
55
56 Explanation of the various fields is described next.
57
58 \section{Audio attributes}%
59 \label{sec:audio_attributes}
60 \index{audio!attributes}
61
62
63 \begin{description}
64 \item[Presets:] select an option from this menu to have all the
65 project settings set to one of the known standards.  Some of the
66 options are 1080P/24, 1080I, 720P/60, PAL, NTSC, YouTube, and CD
67 audio.
68
69 \item[Tracks:] (in New Project menu only) sets the number of audio
70 tracks for the new project. Tracks can be added or deleted later,
71 but this option is on the New Project menu for convenience.
72
73 \item[Samplerate:] \index{sample rate} sets the samplerate of the audio. The project
74 samplerate does not have to be the same as the media sample rate
75 that you load. Media is resampled to match the project sample rate.
76
77 \item[Channels:] \index{audio!channels} sets the number of audio channels for the new
78 project. The number of audio channels does not have to be the same
79 as the number of tracks.
80
81 \item[Channel positions:] the currently enabled audio channels and
82 their positions in the audio panning boxes in the track patchbay are
83 displayed in the channel position widget in the Set Format window.
84 You can see this display on the left side in
85 figure~\ref{fig:set-format} above.  Channel positions are not in New
86 Project window.
87
88   The channels are numbered.  When rendered, the output from channel
89 1 is rendered to the first output track in the file or the first
90 sound card channel of the sound card.  Later channels are rendered
91 to output tracks numbered consecutively.  The audio channel
92 positions correspond to where in the panning widgets each of the
93 audio outputs is located.  The closer the panning position is to one
94 of the audio outputs, the more signal that speaker gets.  Click on a
95 speaker icon and drag to change the audio channel location.  The
96 speakers can be in any orientation.  A different speaker arrangement
97 is stored for every number of audio channels since normally you do
98 not want the same speaker arrangement for different numbers of
99 channels.
100
101   Channel positions is the only setting that does not affect the
102 output necessarily.  It is merely a convenience, so that when more
103 than two channels are used, the pan controls on the timeline can
104 distinguish between them.  It has nothing to do with the actual
105 arrangement of speakers.  Different channels can be positioned very
106 close together to make them have the same output.
107 \end{description}
108
109
110 \section{Video attributes}%
111 \label{sec:video_attributes}
112 \index{video!attributes}
113
114 \begin{description}
115 \item[Tracks:] (in New Project menu only) sets the number of video
116 tracks the new project is assigned.  Tracks can be added or deleted
117 later, but options are provided here for convenience.
118
119 \item[Framerate:] \index{framerate} sets the framerate of the video.  The project
120 framerate does not have to be the same as an individual media file
121 frame rate that you load.  Media is reframed to match the project
122 framerate.
123
124 \item[Canvas size:] \index{canvas size} sets the size of the video output \index{output size}. In addition,
125 each track also has its own frame size.  Initially, the New Project dialog creates video tracks whose size matches the video output.  The video track sizes can be changed later without changing the video output. We have: Project size = $Width \times Height$, pixels = canvas size = output size .
126
127 \item[W/H Ratio] Sets the ratio of the new canvas size (Width, Height) from the old (previous) canvas size (Width, Height).
128
129 \qquad W Ratio = $\frac{W_f}{W_i}$ \qquad H Ratio = $\frac{H_f}{H_i}$
130
131 with $W_f$/$H_f$: final Width and Height; $W_i$/$H_i$: initial Width and Height.
132
133 The new canvas size is recalculated based upon a certain factor in the \texttt{W Ratio}, \texttt{H Ratio} fields. A practical use-case: the current resolution is $640 \times 480$, and for some reason you want Width to be 1.33 times bigger. You don't have to calculate what $640 \times1.33$ is; you type 1.33 into the \texttt{Width} input instead, and \CGG{} calculates it for you. W/H Ratio works as a local calculator. Warning: if you vary W/H Ratio without adjusting Display aspect ratio, we may get non-square pixels resulting in anamorphic frame distortion.
134
135 \item[Display aspect ratio:] \index{aspect ratio} sets the aspect ratio; this aspect ratio refers to the display aspect ratio (DAR).  The aspect ratio is applied to the video output (canvas). It can be convenient to vary the size of the canvas in percentage terms, instead of having to calculate the number of Width x Height pixels. The aspect ratio can be different than the ratio that results from the formula: $\dfrac{h}{v}$ (the number of horizontal pixels divided into the number of vertical pixels).  If the aspect ratio differs from the results of the formula above, your output will be in non-square pixels.
136
137 \item[Auto aspect ratio:] if this option is checked, the \texttt{Set Format}
138 dialog always recalculates the Aspect ratio setting based upon the
139 given Canvas size. This ensures pixels are always square.
140
141 \item[Color model:] \index{color!model} the internal color space of \CGG{} is X11 sRGB
142 without color profile. \CGG{} always switches to sRGB when applying
143 filters or using the compositing engine. Different case for
144 decoding/playback or encoding/output; the project will be stored in
145 the color model video that is selected in the dropdown.  Color model
146 is important for video playback because video has the disadvantage
147 of being slow compared to audio.  Video is stored on disk in one
148 colormodel, usually a YUV derivative.  When played back, \CGG{}
149 decompresses it from the file format directly into the format of the
150 output device.  If effects are processed, the program decompresses
151 the video into an intermediate colormodel first and then converts it
152 to the format of the output device.  The selection of an
153 intermediate colormodel determines how fast and accurate the effects
154 are.  A list of the current colormodel choices follows.
155
156   \begin{description}
157   \item[RGB-8 bit] Allocates 8\,bits for the R, G, and B channels
158 and no alpha. This is normally used for uncompressed media with low
159 dynamic range.
160   \item[RGBA-8 bit] Allocates an alpha channel to the 8\,bit RGB
161 colormodel. It can be used for overlaying multiple tracks.
162   \item[RGB-Float] Allocates a 32\,bit float for the R, G, and B
163 channels and no alpha. This is used for high dynamic range
164 processing with no transparency.
165   \item[RGBA-Float] This adds a 32\,bit float for alpha to
166 RGB-Float. It is used for high dynamic range processing with
167 transparency. Or when we don't want to lose data during workflow,
168 for example in color correction, key extraction and motion
169 tracking. Note: even if \CGG{} outputs fp32, exr/tiff values there are normalized to 0-1.0f.
170   \item[YUV-8 bit] Allocates 8\,bits for Y, U, and V. This is used
171 for low dynamic range operations in which the media is compressed in
172 the YUV color space. Most compressed media is in YUV and this
173 derivative allows video to be processed fast with the least color
174 degradation.
175   \item[YUVA-8 bit] Allocates an alpha channel to the 8\,bit YUV
176 colormodel for transparency.
177   \end{description}
178
179 In order to do effects which involve alpha
180 channels \index{alpha channel}, a colormodel with an alpha channel must be selected.
181 These are RGBA-8 bit, YUVA-8 bit, and RGBA-Float.  The 4 channel
182 colormodels are slower than 3\,channel colormodels, with the slowest
183 being RGBA-Float.  Some effects, like fade, work around the need for
184 alpha channels while other effects, like chromakey, require an alpha
185 channel in order to be functional.  So in order to get faster
186 results, it is always a good idea to try the effect without alpha
187 channels to see if it works before settling on an alpha channel and
188 slowing it down.
189
190   When using compressed footage, YUV colormodels \index{yuv} are usually faster
191 than RGB colormodels \index{RGB}.  They also destroy fewer colors than RGB
192 colormodels.  If footage stored as JPEG or MPEG is processed many
193 times in RGB, the colors will fade whereas they will not fade if
194 processed in YUV\@.  Years of working with high dynamic range footage
195 has shown floating point RGB to be the best format for high dynamic
196 range.  16 bit integers were used in the past and were too lossy and
197 slow for the amount of improvement.  RGB float does not destroy
198 information when used with YUV source footage and also supports
199 brightness above 100\,\%.  Be aware that some effects, like
200 Histogram, still clip above 100\,\% when in floating point. See also \ref{sec:color_space_range_playback}, \ref{sec:conform_the_project} and \ref{sec:overview_color_management}.
201
202 \item[Interlace mode:] \index{interlacing} this is mostly obsolete in the modern digital
203 age, but may be needed for older media such as that from broadcast
204 TV\@.  Interlacing uses two fields to create a frame. One field
205 contains all odd-numbered lines in the image; the other contains all
206 even-numbered lines.  Interlaced fields are stored in alternating
207 lines of interlaced source footage. The alternating lines missing on
208 each output frame are interpolated.
209 \end{description}
210
211 \section{Best practice in pre-editing}%
212 \label{sec:best_practice_pre_editing}
213
214 \CGG{} supports the simultaneous presence in the Timeline of sources with different frame sizes and frame rates. However, audio/video synchronization problems may occur due to their different timing.\protect\footnote{credit to sge and Andrew Randrianasulu}
215 Plugins that rely on the timing of each frame, for example \textit{Motion} and \textit{Interpolate} plugins, may have problems when used at the same time with engines which increase frame rate. Frame rate per definition cannot be increased without either duplicating some frames or generating them in some intelligent way. But to work reliably, the \textit{Motion} plugin requires access to all actual frames. These kinds of plugins (and also the rare cases of audio/video desync) explicitly require the \textit{Play every frame} option.
216
217 There is no problem as long as the source fps, project fps, and destination fps are identical. In most cases, high frame rates such as 120 or 144 or any fps, will be just fine for \textit{Motion} provided that source footage all has the same frame rate.
218
219 But when \textit{project} and \textit{source} frame rates are different (or \textit{project} and
220 \textit{rendered} fps), then the \CGG{} engine has to either duplicate (interpolate) some frames or throw some away. Because of this, the audio tracks and the timeline get out of sync with such accelerated (or slowed down) video. And to make \textit{Motion} plugins reliably calculate interframe changes, you have to ensure the consistent frame numbers and frame properties.
221
222 Generally, best practice is to perform the following sequence of preparations for video editing.
223
224 \begin{enumerate}
225         \item Motion stabilization, and maybe some other preparations, to improve the quality of the source video is best done under the properties identical to the properties of the original video; it may be different codec, but same frame size and same frame rate. For stabilization you can use ffmpeg command line plugins called \textit{vidstabdetect} and \textit{vidstabtransform}.
226         \item To have a workflow at the highest quality it may be convenient to convert the sources into image sequences (e.g. OpenEXR). Especially if we want to exchange files with other Color or Compositimg programs that preferably use image sequences.
227         \item Uniform the color models. It is convenient to unify the color models of the sources because they would give different and inconsistent results with each other once displayed in the Compositor window.
228         \item If we intend to do some color correction or compositing with VFX, it is convenient to do some de-noising on the sources to make their pixels more homogeneous and suitable for post processing. De-noising is a heavy operation for the system so it may be convenient to do it in pre-editing.
229         \item If you need to alter the frame rate, for example because different source clips have different frame rates, then recode all the necessary clips to the same future project frame rate. Here frame sizes can still have different sizes, but frame rates should be all the same.   If you need to change frame rate of some restricted part, particularly when smooth acceleration/deceleration is needed, it can be done in timeline. But if frame rate has to be changed only due to different source fps, it is better to do it during the preparation stage.
230 \end{enumerate}
231
232 \CGG{} does not have color management \index{color management}, but we can still give some general advice on how to set color spaces:
233
234 \begin{enumerate}
235         \item Profiling and setting the monitor: \\
236         source: \textit{sRGB} $\rightarrow$ monitor: \textit{sRGB}  (we get a correct color reproduction) \\
237         source: \textit{sRGB} $\rightarrow$ monitor: \textit{rec709} (we get slightly dark colors) \\
238         source: \textit{sRGB} $\rightarrow$ monitor: \textit{DCI-P3} (we get over-saturated colors) \\
239         
240         source: \textit{rec709} $\rightarrow$ monitor: \textit{rec709} (we get a correct color reproduction) \\
241         source: \textit{rec709} $\rightarrow$ monitor: \textit{sRGB} (we get slightly faded colors) \\
242         source: \textit{rec709} $\rightarrow$ monitor: \textit{DCI-P3} (we get over-saturated colors)
243         \item It would be better to set the project as RGB(A)-FLOAT, allowing system performance, because it collects all available data and does not make rounding errors. If we can't afford it, starting from YUV type media it is better to set the project as YUV(A)8, so as not to have a darker rendering in the timeline. On the contrary, if we start from RGB signals, it is better to use RGB(A)8. If we don't display correctly on the timeline, we'll make adjustments from the wrong base (metamerism) and get false results.
244         \item Having correct color representation in the Compositor can be complicated. You can convert the imput \textit{YUV color range} to a new YUV color range that provides more correct results (i.e. MPEG to JPEG). The \texttt{Colorspace} plugin can be used for this conversion.
245         \item Among the rendering options always set the values \\      
246         \texttt{color\_trc=...} (gamma correction) \\
247         \texttt{color\_primaries=...} (gamut) \\
248         \texttt{colorspace=...} (color spaces conversion, more depth-color); \\
249         or \\
250         \texttt{colormatrix=...} (color spaces conversion, faster).
251         
252         These are only metadata that do not affect rendering but when the file is read by a player later they are used to reproduce the colors without errors.
253 \end{enumerate}
254
255 For more tips on how \CGG{} processes colors on the timeline see  \nameref{sec:color_space_range_playback}, \nameref{sec:conform_the_project} and \nameref{sec:overview_color_management}.
256
257 %%% Local Variables:
258 %%% mode: latex
259 %%% TeX-master: "../CinelerraGG_Manual"
260 %%% End: