add 19
[goodguy/cin-manual-latex.git] / parts / Rendering.tex
index 1cb18a7821e5561d1a4cbdf51ee4bc489ce034ad..1287f88d95491982c1c0bce0de25447d3ce63ef1 100644 (file)
@@ -33,7 +33,9 @@ Use the File pulldown and select Render to start the render dialog (figure~\ref{
 \begin{description}
     \item[Wrench:] select the \textit{wrench} next to each toggle to set compression parameters.  If the file format can not store audio or video the compression parameters will be blank.  If \textit{Render audio tracks} or \textit{Render video tracks} is selected and the file format does not support it, trying to render will result in an error message.
     \item[Create new file at each label] the option causes a new file to be created when every label in the timeline is encountered – a separate file for each.  This is useful for dividing long audio recordings into individual tracks.  When using the Render Farm (described later), \textit{Create new file at each label} causes one render farm job to be created at every label instead of using the internal load balancing algorithm to space jobs.   If the filename given in the render dialog has a 2 digit number in it, the 2 digit number is overwritten with a different incremental number for every output file. If no 2 digit number is given, Cinelerra automatically concatenates a number to the end of the given filename for every output file.
 \begin{description}
     \item[Wrench:] select the \textit{wrench} next to each toggle to set compression parameters.  If the file format can not store audio or video the compression parameters will be blank.  If \textit{Render audio tracks} or \textit{Render video tracks} is selected and the file format does not support it, trying to render will result in an error message.
     \item[Create new file at each label] the option causes a new file to be created when every label in the timeline is encountered – a separate file for each.  This is useful for dividing long audio recordings into individual tracks.  When using the Render Farm (described later), \textit{Create new file at each label} causes one render farm job to be created at every label instead of using the internal load balancing algorithm to space jobs.   If the filename given in the render dialog has a 2 digit number in it, the 2 digit number is overwritten with a different incremental number for every output file. If no 2 digit number is given, Cinelerra automatically concatenates a number to the end of the given filename for every output file.
-    For example, in the filename \texttt{/movies/track01.wav} the $01$ would be overwritten for every output file. The filename \texttt{/movies/track.wav}; however, would become \texttt{/movies/track.wav001} and so on.  Filename regeneration is only used when either render farm mode is active or creating new files for every label is active.
+    For example, in the filename \texttt{/movies/track01.wav} the $01$ would be overwritten for every output file. 
+    The filename \texttt{/movies/track.wav}; however, eventually would become \texttt{/movies/track.wav001} and so on.  
+    Filename regeneration is only used when either render farm mode is active or creating new files for every label is active.
     \item[Render range:] choices are \textit{Project}, \textit{Selection}, \textit{In/Out points}, and \textit{One Frame} for single images like Tiff.  For these images, Render range will have \textit{One Frame} automatically checked and all of the others ghosted since nothing else makes sense (figure~\ref{fig:render02}).  This makes it easy to set the insertion point where you want the 1 frame to be rendered rather than having to precisely zoom in to set the in/out pointers.  Note that whichever Render range is checked, remains checked so that if \textit{One Frame} gets automatically checked, the next time you render it will still be checked and you will have to select a different one if desired.  That is why you should always check the settings.
 \end{description}
 
     \item[Render range:] choices are \textit{Project}, \textit{Selection}, \textit{In/Out points}, and \textit{One Frame} for single images like Tiff.  For these images, Render range will have \textit{One Frame} automatically checked and all of the others ghosted since nothing else makes sense (figure~\ref{fig:render02}).  This makes it easy to set the insertion point where you want the 1 frame to be rendered rather than having to precisely zoom in to set the in/out pointers.  Note that whichever Render range is checked, remains checked so that if \textit{One Frame} gets automatically checked, the next time you render it will still be checked and you will have to select a different one if desired.  That is why you should always check the settings.
 \end{description}
 
@@ -71,7 +73,7 @@ If you want to render many projects to media files without having to constantly
 
 The first thing to do when preparing to do batch rendering is to create one or more Cinelerra projects to be rendered and save them as a normal project, such as \texttt{ProjectA.xml}.  The batch renderer requires a separate project file for every batch to be rendered.  You can use the same Cinelerra project file if you are rendering to different output files, as in an example where you might be creating the same output video in different file formats.
 
 
 The first thing to do when preparing to do batch rendering is to create one or more Cinelerra projects to be rendered and save them as a normal project, such as \texttt{ProjectA.xml}.  The batch renderer requires a separate project file for every batch to be rendered.  You can use the same Cinelerra project file if you are rendering to different output files, as in an example where you might be creating the same output video in different file formats.
 
-To create a project file which can be used in batch render, set up your project and define the region to be rendered either by highlighting it, setting in/out points around it, or positioning the insertion point before it. Then save the project as usual to your project.xml file. Define as many projects as needed this way.  The batch renderer takes the active region from the EDL file for rendering.
+To create a project file which can be used in batch render, set up your project and define the region to be rendered either by highlighting it, setting in/out points around it, or positioning the insertion point before it. Then save the project as usual to your project.xml file. Define as many projects as needed this way.  The batch renderer takes the active region from the EDL file for rendering. If we have not set active regions, it is better to bring the insertion point to the beginning of the timeline to avoid possible problems with the rendering.
 
 With all the Cinelerra xml project files prepared with active regions, go to \texttt{File $\rightarrow$ Batch Render}. This brings up the batch render dialog. The interface for batch rendering is more complex than for single file rendering.  A list of batches must be defined before starting a batch rendering operation.  The table of batches appears on the bottom of the batch render dialog and is called \textit{Batches to render}.  Above this are the configuration parameters for a single batch; a batch is simply a pairing of a project file with a choice of output file and render settings.
 
 
 With all the Cinelerra xml project files prepared with active regions, go to \texttt{File $\rightarrow$ Batch Render}. This brings up the batch render dialog. The interface for batch rendering is more complex than for single file rendering.  A list of batches must be defined before starting a batch rendering operation.  The table of batches appears on the bottom of the batch render dialog and is called \textit{Batches to render}.  Above this are the configuration parameters for a single batch; a batch is simply a pairing of a project file with a choice of output file and render settings.
 
@@ -196,11 +198,12 @@ Cinelerra can distribute the rendering tasks over the network to the other compu
 The following steps are just a guideline to start your render farm.  It is assumed that you already have the master and client nodes communication, shared filesystem, permissions and usernames synched.
 
 \begin{enumerate}
 The following steps are just a guideline to start your render farm.  It is assumed that you already have the master and client nodes communication, shared filesystem, permissions and usernames synched.
 
 \begin{enumerate}
-    \item On the master computer, use \texttt{Settings $\rightarrow$ Preferences $\rightarrow$ Performance tab} to set up a Render Farm:
+    \item On the master computer, use \texttt{Settings} $\rightarrow$ \texttt{Preferences} $\rightarrow$ \texttt{Performance} \texttt{tab} to set up a Render Farm:
     \begin{itemize}
         \item check the \texttt{Use render farm} box;
     \begin{itemize}
         \item check the \texttt{Use render farm} box;
-        \item in the Hostname box, keyin your hostname or ip address such as $192.168.1.12$ or \texttt{localhost};
-        \item enter in a port number such as $401-405$ (only a root user can use privileged ports) or $1025$  and click on \texttt{Add Nodes};
+        \item in the \texttt{Hostname} box, keyin your hostname or ip address such as \\
+            192.168.1.12 or \texttt{localhost};
+        \item enter in a port number such as 401--405 (only a root user can use privileged ports) or $1025$  and click on \texttt{Add Nodes};
         \item you will see something like the following in the Nodes listbox to the right:
             \begin{tabular}{lllc}
                 On & Hostname     & Port & Framerate \\\midrule
         \item you will see something like the following in the Nodes listbox to the right:
             \begin{tabular}{lllc}
                 On & Hostname     & Port & Framerate \\\midrule
@@ -267,7 +270,7 @@ Below we describe the Performance tab for configuring a render farm (figure~\ref
     \item[Reset rates] sets the framerate for all the nodes to $0$.  Frame rates are used to scale job sizes based on CPU speed of the node.  Frame rates are calculated only when render farm is enabled.
 \end{description}
 
     \item[Reset rates] sets the framerate for all the nodes to $0$.  Frame rates are used to scale job sizes based on CPU speed of the node.  Frame rates are calculated only when render farm is enabled.
 \end{description}
 
-Framerates can really affect how the Render Farm works.  The first time you use the render farm all of the rates are displayed as $0$ in the \texttt{Settings $\rightarrow$ Preferences}, Performance tab in the Nodes box.  As rendering occurs, all of the nodes send back framerate values to the master node and the preferences page is updated with these values.  A rate accumulates based on speed.  Once all nodes have a rate of non-zero, the program gives out less work to lower rated nodes in an effort to make the total time for the render to be almost constant.
+Framerates can really affect how the Render Farm works.  The first time you use the render farm all of the rates are displayed as $0$ in the \texttt{Settings $\rightarrow$ Prefe\-rences}, Performance tab in the Nodes box.  As rendering occurs, all of the nodes send back framerate values to the master node and the preferences page is updated with these values.  A rate accumulates based on speed.  Once all nodes have a rate of non-zero, the program gives out less work to lower rated nodes in an effort to make the total time for the render to be almost constant.
 Initially, when the framerate scaling values are zero, the program just uses package length --- render size 
 divided by the number of packages to portion out the work (if not labels).  If something goes wrong or the rates become suspect, then all of the rest of the work will be dumped into the last job.  When this happens, you really should \texttt{reset rates} for the next render farm session to restart with a good balance.
 
 Initially, when the framerate scaling values are zero, the program just uses package length --- render size 
 divided by the number of packages to portion out the work (if not labels).  If something goes wrong or the rates become suspect, then all of the rest of the work will be dumped into the last job.  When this happens, you really should \texttt{reset rates} for the next render farm session to restart with a good balance.
 
@@ -421,15 +424,13 @@ These steps are for quickly setting up render farm with the least amount of addi
 
 Because index files speed up displaying the video you may want to share these files with the clients on a shared filesystem.  There is a configuration option available in \texttt{Settings $\rightarrow$ Preferences}, the Interface tab, that sets up in your preferences the location of the index files which you can put on a shared disk.
 Screencast below shows part of the Preferences menu where you can change the index files setup (figure~\ref{fig:index}).
 
 Because index files speed up displaying the video you may want to share these files with the clients on a shared filesystem.  There is a configuration option available in \texttt{Settings $\rightarrow$ Preferences}, the Interface tab, that sets up in your preferences the location of the index files which you can put on a shared disk.
 Screencast below shows part of the Preferences menu where you can change the index files setup (figure~\ref{fig:index}).
-
 \begin{figure}[htpb]
     \centering
     \includegraphics[width=0.8\linewidth]{images/index.png}
     \caption{Index file setup for your preferred configuration for Render Farm sharing or anything}
     \label{fig:index}
 \end{figure}
 \begin{figure}[htpb]
     \centering
     \includegraphics[width=0.8\linewidth]{images/index.png}
     \caption{Index file setup for your preferred configuration for Render Farm sharing or anything}
     \label{fig:index}
 \end{figure}
-
-\noindent Or, one of the convenient features of cin5 is the redirection of the path via \texttt{CIN\_CONFIG} as in:
+ Or, one of the convenient features of cin5 is the redirection of the path via \texttt{CIN\_CONFIG} as in:
 \begin{lstlisting}[language=bash]
 CIN_CONFIG=/<shared_file_pathname>/<filename_such_as_.bcast5> /<cinelerra_pathname>/cin
 \end{lstlisting}
 \begin{lstlisting}[language=bash]
 CIN_CONFIG=/<shared_file_pathname>/<filename_such_as_.bcast5> /<cinelerra_pathname>/cin
 \end{lstlisting}
@@ -603,25 +604,104 @@ flags +pass2
 
 If you need to re-render this, the Batch Render will still be set up but you have to click on the \texttt{Enabled} column in the listbox to re-enable the jobs to run which puts an X there.  Click Start again. You can reuse batch job using the \texttt{save jobs} and \texttt{load jobs} buttons in the batch render dialog.
 
 
 If you need to re-render this, the Batch Render will still be set up but you have to click on the \texttt{Enabled} column in the listbox to re-enable the jobs to run which puts an X there.  Click Start again. You can reuse batch job using the \texttt{save jobs} and \texttt{load jobs} buttons in the batch render dialog.
 
-\paragraph{Render shortcuts for webm, h264, h265} are available by using the option files that are already set up for this purpose.  Use the render menu as usual, with ffmpeg/mp4, choose h264 or h265 \texttt{pass1of2\_h26x} for the video and \texttt{passes1and2\_h26x} for the audio; with ffmpeg/webm, choose \texttt{pass1of2\_vp9}.  When that is finished, you will have to use the render menu again and this time for video, choose \texttt{pass2of2\_h26x} or \texttt{pass2of2\_vp9}.  The logfile is hard coded in the options file so will write over any currently existing logfile if you do not change it before you start the render.
+\paragraph{Render shortcuts for webm, h264, h265} are available by using the option files that are already set up for this purpose.  Use the render menu as usual, with ffmpeg/mp4, choose h264 or h265 \texttt{pass1of2\_h26x} for the video and \texttt{passes1and\-2\_h26x} for the audio; 
+with ffmpeg/webm, choose \texttt{pass1of2\_vp9}.  When that is finished, you will have to use the render menu again and this time for video, choose \texttt{pass2of2\_h26x} or \texttt{pass2of2\_vp9}.  The logfile is hard coded in the options file so will write over any currently existing logfile if you do not change it before you start the render.
 
 
-\paragraph{Requirements for some other libraries} (used instead of \texttt{flags +pass1} \& \texttt{passlogfile}):
+\paragraph{Requirements for some other libraries} ~\\ (used instead of \texttt{flags +pass1} \& \texttt{passlogfile}):
 
 \begin{description}
     \item[x265:] add this line:
     \begin{lstlisting}[language=bash]
 x265-params=pass=1:stats=/tmp/{temporary log file name}.log
     \end{lstlisting}      
 
 \begin{description}
     \item[x265:] add this line:
     \begin{lstlisting}[language=bash]
 x265-params=pass=1:stats=/tmp/{temporary log file name}.log
     \end{lstlisting}      
-    at the time this document was written, you should see in the output:  \texttt{stats-read=2}
+    at the time this document was written, you should see in the output: \\  \texttt{stats-read=2}
     
     
-    \item[libvpx-vp9, xvid, and huffyuv:]
+    \item[libvpx-vp9, xvid, and huffyuv:]~
+
     \begin{lstlisting}[language=bash]
     \begin{lstlisting}[language=bash]
-cin_stats_filename /tmp/{temporary log file name}.log
-flags +pass1 (or flags +pass2 for the second pass)
-    \end{lstlisting} 
-    \noindent \textit{NOTE:} for vp9, the best Pixels is \texttt{gbrp}   
+    cin_stats_filename /tmp/{temporary log file name}.log
+    flags +pass1 (or flags +pass2 for the second pass)
+    \end{lstlisting}    
 \end{description}
 
 \end{description}
 
+\noindent \textit{NOTE:} for vp9, the best Pixels is \texttt{gbrp}
+
+\subsection{Use case: High Efficiency Video Coding (HEVC)}%
+\label{sub:use_case_hevc}
+
+An example of video profile based on CRF, a quality-controlled
+variable bitrate, instead of fixed quality scale (ABR).
+HEVC (H.265) was developed as a successor to AVC (H.264) to more
+efficiently compress the future large amounts of data from 2/4/8k
+videos.
+In comparison to AVC, an average saving of around 30 percent can be
+assumed for the same quality.
+Because HEVC is not bound to any size format, it is suitable for
+virtually any image size.
+
+The following example is HD and FullHD oriented and produces a
+picture quality similar to the Blu-ray with some limitations.
+As container Matroska (.mkv) is used, but also mp4 and others are
+possible.
+
+\vspace{2ex} \begin{lstlisting}[language=Bash]
+matroska libx265
+
+# CRF 16 creates a balanced compromise
+# between quality and file size. 
+crf=16
+
+# Preset changes encoding speed and generally
+# degrades the overall result. Medium (default)
+# always fits.
+preset=medium
+
+# Additional parameters that are passed on to the codec.
+# me=star improves the search for very fast
+# movements, but slows down the encoding.
+#x265-params=me=star
+
+# Keyint does FFmpeg automatically, otherwise
+# the setting must match the frame rate.
+#keyint\_min=25
+
+# Profile does FFmpeg automatically.
+#profile=high
+
+# Source sRBG and retention of color space.
+# 720/1080=bt709 if no profile set. Useful
+# for formats smaller than 720 if no lossy
+# conversion is desired.
+colorspace=bt709
+color_trc=bt709
+color_primaries=bt709
+
+# Output in 10 bit, prevents 8-bit step formation
+pixel_format=yuv420p
+\end{lstlisting}
+
+\noindent \textit{NOTE:}
+
+A CRF of 16 delivers satisfactory results in most cases. However, if
+the video material is really \emph{grainy}, a CRF~16 can lead to unwanted large files.  In this case, a trial export of perhaps one minute should be performed. The resulting bit rate can be used to correct the CRF to 17,\,18,\,19\ldots --- remember, a CRF of 0 means lossless, the higher the number the stronger the lossy compression. The approximate calculation of the final file size can be extrapolated from the sample export.
+
+The color space information must be used explicitly so that it can
+be included in the video. Cinelerra\,GG or FFmpeg does not write it
+by itself. Without this information the players (e.\,g.\ \href{https://mpv.io/}{mpv}) stick to the dimensions of the video and take the assumed color model from a table. With videos in the dimensions from 720 to 1080 this is bt709. For smaller dimensions, e.\,g.\ DVD, bt601 is assumed and for 4k and above it is bt2020. Normally this is not a problem, but if you want to export a FullHD without color loss to a smaller size like 576 for example, you have to inform the encoder as well as the decoder of the player. This also applies if the videos are to be loaded on video platforms, where they are then converted into videos of different sizes. It is a security measure to prevent false colors, such as the color profiles in digital photos and the copies made from them.
+
+The HEVC tuning has not been considered here, because it is is
+rarely used and requires background knowledge.
+
+Further links:
+\begin{itemize}
+    \item \href{http://x265.readthedocs.org/en/default/}{x265
+        Documentation}
+    \item \href{http://x265.readthedocs.org/en/latest/cli.html}{x265
+        Command Line Options}
+    \item \href{http://x265.readthedocs.org/en/latest/presets.html}{x265
+        Presets/Tuning}
+\end{itemize}
+
 \subsection{Piping Video to a Command Line}%
 \label{sub:piping_video_command_line}
 
 \subsection{Piping Video to a Command Line}%
 \label{sub:piping_video_command_line}