From: Andrea-Paz <50440321+Andrea-Paz@users.noreply.github.com> Date: Tue, 8 Oct 2019 07:35:26 +0000 (+0200) Subject: add chapter 12 - 13 X-Git-Tag: 2021-05~173 X-Git-Url: https://git.cinelerra-gg.org/git/?a=commitdiff_plain;h=b77b9c2740bd81b2bea54f70142b47ed9f3477d4;p=goodguy%2Fcin-manual-latex.git add chapter 12 - 13 --- diff --git a/parts/DVD.tex b/parts/DVD.tex new file mode 100644 index 0000000..8179966 --- /dev/null +++ b/parts/DVD.tex @@ -0,0 +1,740 @@ +\chapter{DVD and Bluray Creation}% +\label{cha:dvd_bluray_creation} + +This section describes how to create a blu-ray DVD, or \textcolor{red}{BD} referring to a \textcolor{red}{B}lu-ray \textcolor{red}{D}VD, and a regular DVD, or \textcolor{red}{SD} referring to a \textcolor{red}{S}tandard \textcolor{red}{D}VD. The DVDs (plural usage of DVD means either BD or SD) created are unencrypted, unlike commercially available movie DVDs. This Cinelerra version conceivably can create different variations of DVD/Blu-ray media but for the casual user the most standard usages are readily usable and will be described here. + +Some preliminary information follows. For NTSC, SD media is almost always $720\times480$ interlaced (the format in the United States, US). For PAL, SD media is almost always $720\times576$ interlaced (Europe, EU, and most of the world). An SD can conceivably be created with a lower resolution – for example $352\times240$ MPEG-1 -- but it is not useful. Aspect ratio for either NTSC or PAL can be $4:3$ or $16:9$. + +Frames per seconds is usually $29.97$ for NTSC and $25$ fps for PAL. The standard SD dvd generally uses the MPEG-2 program stream with a filename extension of \texttt{m2v}. BD blu-ray media is not normally interlaced, but you can leave it interlaced. Blu-ray uses the MPEG transport stream which contains 1 or more program streams with a default filename extension of \texttt{m2ts}. + +Requirements for creating DVDs is the hardware device to write the media on and, obviously, the blank media for either BD or SD. When generating SD media, you will have to install \textit{dvdauthor} and for BD media, install \textit{udftools} if they are not on your system. Also, keep in mind that to mount filesystems for creating files and to burn DVDs, you will have to be root since you have to have privileges, unless special permissions have been provided for a non-root user. It is also highly recommended to +run the cinelerra startup from a terminal window, instead of the icon, in order to see informative messages of how to actually write the output (at prompt: keyin \texttt{bd\_(or dvd\_)} + \item Load your media, format if needed, note device name to substitute for \texttt{} or \texttt{} + \begin{itemize} + \item If rewritable blu-ray, use \\ + \texttt{dd if=./bd.udfs of=/dev/ bs=2048000} + \item If write-once blu-ray, use \\ + \texttt{growisofs -dvd-compat -Z /dev/=./bd.udfs} + \item If any DVD media, use \\ + \texttt{growisofs -dvd-compat -Z /dev/ -dvd-video ./iso} + \end{itemize} +\end{enumerate} + +Any problems encountered will require that you read more information in this section to include specific details, helpful hints, and problem resolution. + +\paragraph{Details and specific explanations} to create blu-ray or regular DVD are provided here. It is very advantageous to startup cinelerra from the command line prompt instead of the icon. Also, please be root or your hard work will be lost when the automount is issued and fails for bluray udfs mounting. + +The general design of the DVD/blu-ray generation operations is to first render media using batch rendering and then terminate Cinelerra to start a script which creates the target device filesystem data. These scripts are the \texttt{dvd.sh} and \texttt{bd.sh} scripts written into the target directory. For DVD, the general plan is to write a directory \texttt{/iso} with the dvd filesystem via \textit{dvdauthor} and then generate an iso9660 filesystem and write it to a dvd via \textit{growisofs}. + +For blu-ray, the filesystem generation is slightly harder. First, it creates an empty filesystem image \texttt{/bd.udfs} using \textit{mkudffs} which makes a big hole for the filesystem data. The hole is made just a little bigger than the data written by \textit{bdwrite} so that you don't have to write an entire $25GB$ or $50GB$ disc even if no data exists. This empty filesystem is loopback mounted to make it writable, and the linux kernel manages the filesystem image. The bdwrite program applies the blu-ray structure to the UDF filesystem by creating the needed BDMV blu-ray filesystem, which the kernel stores onto the image file \texttt{bd.udfs}. When udfs is unmounted, the kernel finalizes the disk image on bd.udfs. The bd.udfs image can be written directly to a blu-ray disk via \textit{dd} or \textit{growisofs}. + +NOTE of IMPORTANCE: there is a serious situation with the interaction between the Operating System (OS) and bdwrite when creating blu-ray, that requires automount to be turned off. The blu-ray automatic script unmounts the blu-ray/UDF filesystem but the system has not finalized the directories so the OS creates a new loop file device and the data is loaded and cached for use by the new loop but it is stale. Consequences is that not all of the data is written where it should be. The solution is for the OS not to mount this second mount so we have to make sure it doesn't. There are 2 methods to fix this. The first and easiest is by using the following command to disable automount: + +\begin{lstlisting}[language=bash] +gsettings set org.gnome.desktop.media-handling automount false +\end{lstlisting} + +This can be reversed when you have completed the blu-ray generation via: + +\begin{lstlisting}[language=bash] +gsettings set org.gnome.desktop.media-handling automount true +\end{lstlisting} + +A different and more complicated method you can use to turn off automount is to download and install the \textit{dconf-editor}. Automount is a system parameter and only needs to be done once unless you do not want automounts to always be disabled. + +\begin{enumerate} + \item run: \texttt{dconf-editor} + \item select: org $\rightarrow$ gnome $\rightarrow$ desktop $\rightarrow$ applications $\rightarrow$ media-handling + \item uncheck: automount + \item close dconf-editor window +\end{enumerate} + +Immediately below are the detailed steps with explanations for creating SD or BD media. + +\textit{Step 1}: Construct a session with the desired presentation: + +\begin{itemize} + \item Format frame rates choices are $29.97$ or $25$ for SD, based on the user's timezone, with NTSC 29.97/US or PAL 25 /EU. For BD, the media input will be analyzed to automatically pick the default format or if unknown, the user's timezone will be used to default to $1920/29.97i$ for US or $1920/25i$ for EU. Be sure to set the rendering parameters in the \texttt{settings $\rightarrow$ format} menu. + \item Choose audio stereo or 5.1, again depending on your media. + \item Target Geometry will be $720\times480$ (US) or $720\time576$ (EU) for SD. +\end{itemize} + +\textit{Step 2}: From the main window, select \texttt{file $\rightarrow$ BD Render} or select \texttt{file $\rightarrow$ DVD Render} (figure~\ref{fig:bluray_dvd}). Then: + +\begin{figure}[htpb] + \centering + \begin{minipage}[h]{0.49\linewidth} + \center{\includegraphics[width=0.99\linewidth]{images/bluray01.png}} \\ BluRay (scale pulldown) + \end{minipage} + \begin{minipage}[h]{0.49\linewidth} + \center{\includegraphics[width=0.99\linewidth]{images/dvd01.png}} \\ DVD (format pulldown) + \end{minipage} + \caption{BD Render and DVD Render} + \label{fig:bluray_dvd} +\end{figure} + +(Note: both the BD and the DVD windows above, show insufficient space, \textit{disk space:} in red) + +\begin{itemize} + \item Select desired features, check/un-check as appropriate. + \item Click \texttt{OK} check button. It is very important to realize that when you check OK, the EDL will be saved and that will be used for batch job rendering. If you bring up the Batch Render and then change some parameters, they will not take effect UNLESS you remember to either check \texttt{Save to EDL Path} or \texttt{Use Current EDL} in the Batch Render window. You will get a reminder automatically if \texttt{warn if jobs/session mismatched} is checked. +\end{itemize} + +Explanation of the choice boxes as seen in figure~\ref{fig:bluray_dvd} for both SD and BD menus is given below. Many of them are plugins which allow you to further manipulate the settings for best results. They are just suggestions set by the program automatically based on your input media, and can be reset to suit your needs. These are listed in the next 4 points. + +\begin{enumerate} + \item If the media does not match the DVD target geometry, and the scale plugin is not already in use, then the \textit{scale} plugin is applied with scaling set to fit the media dimensions to the DVD format target geometry. + \item If the video height is at least twice the DVD height and the input media is interlaced, then the \textit{deinterlace} plugin is applied with odd line sampling. + \item \textit{Audio 5.1} will automatically be set to the wide-audio if you have 6 tracks of audio. + \item To allow video data to be accessible and overlay properly, the track buffers are \textit{resized} to the largest track frame size in use (\texttt{Resize Tracks}). The theory behind this is to make sure to have enough memory to cover the entire presentation for transcoding. +\end{enumerate} + +\noindent All of the current choice boxes are further defined immediately following. + +\begin{description} + \item[Deinterlace] remove the interlace. Interlacing is a video scanning system in which alternating lines are transmitted so that half a picture is displayed each time the scanning beam moves down the screen. You lose a lot and the quality is bad when you view interlacing on a progressive TV. You might not really want to use deinterlace, because if you deinterlace non-interlaced media, it will look awful. + \item[Scale] alter the spatial mapping of an image to increase or reduce the size; modifies the picture. When some programs scale from $4:3$ to $16:9$ they will automatically cut off the appropriate section of the image for you. It is necessary to keep in mind, that \textit{square pixels} is the true end goal of scaling, not the aspect ratio which could result in squished or stretched output. More information about scaling will be provided on a subsequent page with usage of the \textit{Scale Ratio} plugin. + \item[Histogram] remaps the color space. The color space ranges from $0-255$ for 8-bit color values. You can use this tool to remap the color space to use the entire space or for stretching the contrast. Also, it lets you perform global color-correction on the image. You can use this to correct for color screens that are \textit{too blue}, or for color Televisions that produce \textit{brownish} output, or whatever. In addition to color-correction, you can use the RGB modification tool to add color to images that didn't have color to begin with. For instance, you can \textit{pseudo-color} greyscale media. + \item[Inverse Telecine] the reverse of $3:2$ pulldown where frames, which were duplicated to create 60-fields/second video from 24-frames/second film, are removed. MPEG-2 video encoders usually apply an inverse Telecine process to convert 60-fields/second video into 24-frames/second encoded video. The encoder adds information enabling the decoder to recreate the 60-fields/second display rate. \textit{Telecine}, i.e. $3:2$ pulldown, is used to transfer film to video. That's where the $3:2$ ratio comes in. To ensure that there will consistently be 60 frames per second, the first frame is displayed on the TV screen 3 times and the second frame is displayed 2 times. The following frame is repeated 3 times, the next one 2 times, etc. throughout the film. For inverse telecine, you show 2 of the film frames for 3 of output frames. Only check \textit{Inverse Telecine} if you have film or something that is $24fps$ and want to project to $30fps$ (most likely this will never be necessary). + \item[Audio 5.1] 6 channel surround sound. For most home systems, uses five full bandwidth channels and one low-frequency effects channel. Could automatically get set as explained previously. + \item[Aspect Ratio] aspect ratio may be automatically set to $4:3$ or $16:9$. Aspect ratio would better be defined as the size of the display, monitor, or TV which will be used to view the output. If you measure your old TV, which supposedly is $4:3$ and your latest digital TV, which is supposedly $16:9$, you will see that those ratios aren't always correct anyway. Then measure your laptop monitor, your desktop monitor, and your neighbor's, and lo and behold, the ratios don't fit either of the purported \textit{standard} aspect ratio. Maintaining square pixels via scaling is more important in the long run. + \item[Use FFMPEG] this is user's choice; it is recommended and faster but more difficult to modify due to numerous options. For blu-ray, ffmpeg must be used and is not an available option. + \item[Resize Tracks] change track width and height as explained previously. The size is adjusted to the largest frame size needed. + \item[Chapters at Labels] without this checked, chapters markers are automatically inserted every 5 minutes. The chapter labels can then be \textit{skipped to} when playing the DVD. If instead, you want to put labels in at opportune times, you will have to run dvdauthor outside of Cinelerra and mark the chapter labels yourself by hand. In that case, you should checkbox \texttt{Chapters at Labels} so that the automatic 10-minute labels are not created. This checkbox is not currently available for blu-ray. +\end{description} + +\begin{figure}[htpb] + \centering + \includegraphics[width=0.9\linewidth]{images/dvd02.png} + \caption{check Deinterlace; Histogram and Resize Tracks} + \label{fig:dvd02} +\end{figure} + +Figure~\ref{fig:dvd02} shows on the upper right side the \textit{Create DVD} window with Deinterlace, Histogram and Resize Tracks checked. Also Scale is set to Scaled. Once the green checkmark is clicked, the \textit{Batch Render} window comes up and in the main window you will see the 3 plugins below the video track on the main window. By clicking on the magnifying glass that appears on the rightmost side, the controls for each will popup and you can make any necessary adjustments. Note the numerous choices for Deinterlace; the Value, Red, Green, and Blue for color adjustments in the Histogram window; and Scale Ratio popup menu for numerical settings control. + +The \texttt{Scale} parameter gives you a lot of flexibility. A default based on your input media is provided for you but possible choices are None, Scaled, Cropped, Filled, Horiz Edge, and Vert Edge. You will have the opportunity to manipulate the desired results in the \textit{Scale Ratio} window. Values for W (width), H (height), and X/Y coordinates are the number of pixels. For example, if video is $720\times432$, that is obviously 720 pixels by 432 pixels and this would be the values for Dst W and for Dst H. So if you have some media that is off center you can crop by changing the SRC Y value AND then change DST X/Y to non-zero. It will become the output origin. To see what it does, change them from $0.0$ to $400.0$ and you will see big changes in the compositor window. + +For example, if you have the Cropped choice for the Scale, you will want to manipulate the \textit{ScaleRatio} plugin (the magnifying glass on the main window video track) which brings up the Scale window. For cropped top instead of crop both top and bottom, modify the \texttt{Src Y}. As you change the Y scale, you will see the cropping take place in the Compositor. + +Scaling options are provided in order to preserve image aspect ratio. To determine which scaling option to use, it is important to correctly identify your source/destination video aspect ratios. Next is a short explanation of possible options. + +\begin{description} + \item[None] do not do any scaling. The destination output matches the source input. There is no resizing. + \item[Scaled] do not use uniform scaling on X and Y. Just make it fit and you will might end up with squishing/stretching in one direction or the other in order to do that. This happens when the input aspect ratio is different than that displayed on the output. + \item[Cropped] removes outer edges of a source image in order to fit the image on the output display. This is done in order to maintain uniform geometry scale on the destination display without being affected by the particular factor of original media aspect ratio. Since cropping omits image area, and the areas which you wish to view may not be viewed when the image is centered, you can pan the image source using the Src X/Y to modify which area is in view. You can also think of this as \textit{scaled up}. + \item[Filled] the entire output display will be filled with image content but in order to do so, some of the image may have had to be cut. Any mismatch between the two will be filled with black. Centering of the image can be modified by using the Dest X/Y variables in the Scale Ratio controls. You can also think of this as \textit{scaled down}. + \item[Horiz Edge] this indicates preserving of the Horizontal edge. + \item[Vert Edge] this option preserves the Vertical edge. +\end{description} + +Horizontal and Vertical are duplicates or restatement of same functionality as Cropped or Filled but are provided as options to accommodate different ways of thinking. In any case, you can choose which outer edges of the image to crop by using the \texttt{Show Controls} of the Scale Ratio plugin. For example, you can ensure that no \textit{action} is lost by displaying the center of the screen only or making sure that any textual information on the bottom is not lost by cutting only the top off. + +\textit{Step 3}: Batch render menu appears with \texttt{m2ts} format selected for blu-ray or \texttt{dvd} format selected for regular/standard DVD when File Format selected is ffmpeg in the previous \textit{Create DVD} menu. It will work just fine without selecting ffmpeg for DVD and may be advantageous not to. Using the audio/video wrench tools (you will have to have the video batch job highlighted to manipulate the video or audio batch job for audio). + +\begin{itemize} + \item Setup the audio bitrate ($192000$ recommended). Data rate is $192K$ default. + \item Setup the video bitrate ($6000000 - 12000000$ recommended). $10Mb/sec$ is the current default. + \item Click \texttt{OK} check button. +\end{itemize} + +The default bitrate is the largest value possible. The actual \textit{target} bitrate is calculated based on a formula from the blu-ray/DVD code. It divides the media size (in bits) by the video time (in seconds) to find the bitrate that will \textit{just fit} on the target media. This could create a weird bitrate if the media is large, and the video time is small, so the default/target bitrate is limited to $10Mb/s$.Batch jobs are then built and appended to the job list. Once these batch jobs are built, if you make any changes, you have to start over. You will see listed the batch jobs that are created to perform the rendering/tasks -- 2 jobs for blu-ray, one for audio/video processing and one for the scripts. There will be 3 batch jobs created for DVD when not using ffmpeg to include one each for audio and video and then one more for the scripts. When you click on \texttt{start}, it fires off those jobs and you will see the rendering main window progress bar in the bottom corner reflecting the fact that it is currently processing. Be aware that the Cinelerra program will be totally shutdown AFTER the batch jobs finish.Screenshot below shows BD blu-ray creation with 2 batch jobs queued up and ready to go. + +Figure~\ref{fig:dvd-batch01} for DVD and Figure~\ref{fig:dvd-batch02} for BD shows a creation render ready to be started. Note that because it is not ffmpeg, the processing of video is done separately from audio. If you need to modify the video tracks, which you can see is ghosted out, you need to highlight the first batch job listed. Be sure to highlight the first batch job before pressing Start so it runs all of the jobs and be sure the X for job enabled is set. + +\begin{figure}[htpb] + \centering + \includegraphics[width=0.8\linewidth]{images/dvd-batch01.png} + \caption{Batch render for DVD creation} + \label{fig:dvd-batch01} +\end{figure} + +\vspace{-4ex} +\begin{figure}[htpb] + \centering + \includegraphics[width=0.8\linewidth]{images/dvd-batch02.png} + \caption{Batch render for BD creation} + \label{fig:dvd-batch02} +\end{figure} + +When you click on \texttt{start}, it fires off those jobs and you will see the rendering main window progress bar in the bottom corner reflecting the fact that it is currently processing. Be aware that the Cinelerra program will be \textbf{totally shutdown after the batch jobs finish} and you will be at the command line prompt. + +This will produce a new directory in your target path which contains a filesystem image file. +For example: \\ +\texttt{/TargetDirectory/bd\_20150820-093747} \\ +Directory and file names should not be changed at this time because the scripts and programs rely on the given names in order to proceed. You can change them later for your own purposes. + +If bluray to test the filesystem you just created, use the command line interface; loopback mount the filesystem image which was generated in the target directory. For example if blu-ray: + +\begin{lstlisting}[language=bash] +cd /TargetDirectory/bd_20150820-093747/ +mount -o loop,ro ./bd.udfs ./udfs +#check the media using a compatible media rendering tool like ffplay +umount ./udfs... +\end{lstlisting} + +To burn blu-ray media you will need to run from the command line interface. In the examples below, \texttt{/dev/bd} represents your blu-ray writer device (for example: \texttt{/dev/sr1}) and \texttt{/dev/dvd} represents your dvd writer device (for example: \texttt{/dev/sr0}). + +\subsubsection*{Blu-ray Media} +\label{ssub:bluray_media} + +For rewritable blu-ray (recommended) (BD-RE): + +Note: unwritten (virgin) media must be formatted first using: + +\begin{lstlisting}[language=bash] +dvd+rw-format /dev/bd #only done once and does not take very long +\end{lstlisting} + +To write or rewrite rewritable blu-ray media: + +\begin{lstlisting}[language=bash] +cd /TargetDirectory/bd_20150820-093747/ +dd if=./bd.udfs of=/dev/bd bs=2048000 #the growisofs command below also works +\end{lstlisting} + +To write blu-ray write-once media: (BD-R) (no pre-formatting needed): + +\begin{lstlisting}[language=bash] +cd /TargetDirectory/bd_20150820-093747/ +growisofs -dvd-compat -Z /dev/bd=./bd.udfs +\end{lstlisting} + +\subsubsection*{DVD Media} +\label{ssub:dvd_media} + +For rewritable DVD (DVD+RW): + +Note: unwritten (virgin) media must be formatted first using: + +\begin{lstlisting}[language=bash] +dvd+rw-format /dev/dvd #only done once and does not take very long +\end{lstlisting} + +To write a DVD, load blank media and run the following from the command line (requires dvdauthor): + +\begin{lstlisting}[language=bash] +cd /TargetDirector/dvd_20160404-175416 +growisofs -dvd-compat -Z /dev/dvd -dvd-video ./iso +\end{lstlisting} + +Figure~\ref{fig:dvd-batch03} shows the availability of 4:2 :2 for a Batch Render seen by clicking on wrench icon. + +\begin{figure}[htpb] + \centering + \includegraphics[width=0.7\linewidth]{images/dvd-batch03.png} + \caption{Video options for bluray yuv422p} + \label{fig:dvd-batch03} +\end{figure} + +Figure~\ref{fig:dvd-batch04} shows the availability of 10-bit high quality 4:2 :2 for a Batch Render seen by clicking on wrench icon. You need specially compiled cinelerra in order to use the x265 10-bit as opposed to 8-bit. + +\begin{figure}[htpb] + \centering + \includegraphics[width=0.7\linewidth]{images/dvd-batch04.png} + \caption{Video options for bluray yuv422p10} + \label{fig:dvd-batch04} +\end{figure} + +\section{Output Terminal Messages from Creating DVDs}% +\label{sec:output_terminal_messages_dvd} + +Below are examples of what the batch jobs generate and you will see on the terminal screen if you started the cinelerra program in the recommended manner from a terminal window. It is just informational but will let you know if errors. In looking at any of the output, you can safely ignore the errors that read \texttt{Unsupported codec with id 100357 for input stream 0} -- this comes from \textit{nav-data} (navigation data). The first 2 examples are seen from running the batch jobs; the last 2 are from the single line execution which records the media output to the DVD hardware. + +\subsubsection*{SD Example: Partial Output during Cinelerra run} +\label{ssub:sd_example_partial_output} + +\begin{lstlisting}[language=bash] +... +FFMPEG::open_decoder: some stream times estimated +Render::render_single: Session finished. +FFMPEG::open_decoder: some stream times estimated +Render::render_single: Session finished. +running /tmp/dvd_20160407-113530/dvd.sh 1 /tmp/dvd_20160407-113530 +INFO: [mplex] mplex version 2.1.0 (2.2.7 $Date: 2012/11/17 01:55:16 $) +INFO: [mplex] File /tmp/dvd_20160407-113530/dvd.m2v looks like an MPEG Video stream. +. . . +INFO: [mplex] MUX STATUS: no under-runs detected. +DVDAuthor::dvdauthor, version 0.7.1. +Build options: gnugetopt graphicsmagick iconv freetype fribidi fontconfig +Send bug reports to + +INFO: default video format is NTSC +INFO: dvdauthor creating VTS +STAT: Picking VTS 01 + +STAT: Processing /tmp/dvd_20160407-113530/dvd.mpg... +STAT: VOBU 32 at 15MB, 1 PGCs +INFO: Video pts = 0.133 .. 22.789 +INFO: Audio[0] pts = 0.133 .. 22.789 +STAT: VOBU 46 at 21MB, 1 PGCs +CHAPTERS: VTS[1/1] 0.000 +INFO: Generating VTS with the following video attributes: +INFO: MPEG version: mpeg2 +INFO: TV standard: ntsc +INFO: Aspect ratio: 16:9 +INFO: Resolution: 720x480 +INFO: Audio ch 0 format: ac3/6ch, 48khz drc, 'en' + +STAT: fixed 46 VOBUs +INFO: dvdauthor creating table of contents +INFO: Scanning /tmp/dvd_20160407-113530/iso/VIDEO_TS/VTS_01_0.IFO +To burn dvd, load blank media and run: +growisofs -dvd-compat -Z /dev/dvd -dvd-video /tmp/dvd_20160407-113530/iso +\end{lstlisting} + +\subsubsection*{BD Example: Partial Output during Cinelerra run} +\label{ssub:bd_example_partial_output} + +\begin{lstlisting}[language=bash] +... +FFMPEG::open_decoder: some stream times estimated +Render::render_single: Session finished. ++ PATH=/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/mnt0/build5/cinelerra-5.1/bin ++ mkdir -p /tmp/bd_20161224-162059/udfs +++ du -sb /tmp/bd_20161224-162059/bd.m2ts +++ sed -e 's/[ ].*//' ++ sz=19811904 ++ blks=13769 ++ mkudffs /tmp/bd_20161224-162059/bd.udfs 13769 +start=0, blocks=16, type=RESERVED +start=16, blocks=3, type=VRS +start=19, blocks=237, type=USPACE +start=256, blocks=1, type=ANCHOR +start=257, blocks=16, type=PVDS +start=273, blocks=1, type=LVID +start=274, blocks=13238, type=PSPACE +start=13512, blocks=1, type=ANCHOR +start=13513, blocks=239, type=USPACE +start=13752, blocks=16, type=RVDS +start=13768, blocks=1, type=ANCHOR ++ mount -o loop /tmp/bd_20161224-162059/bd.udfs /tmp/bd_20161224-162059/udfs ++ bdwrite /tmp/bd_20161224-162059/udfs /tmp/bd_20161224-162059/bd.m2ts ++ umount /tmp/bd_20161224-162059/udfs ++ echo To burn bluray, load writable media and run: +To burn bluray, load writable media and run: ++ echo for WORM: growisofs -dvd-compat -Z /dev/bd=/tmp/bd_20161224-162059/bd.udfs +for WORM: growisofs -dvd-compat -Z /dev/bd=/tmp/bd_20161224-162059/bd.udfs ++ echo for RW: dd if=/tmp/bd_20161224-162059/bd.udfs of=/dev/bd bs=2048000 +for RW: dd if=/tmp/bd_20161224-162059/bd.udfs of=/dev/bd bs=2048000 +\end{lstlisting} + +\subsubsection*{SD Example – Partial Output during writing disc media} +\label{ssub:sd_example_partial_output_writing} + +\begin{lstlisting}[language=bash] +growisofs -dvd-compat -Z /dev/sr0 -dvd-video /tmp/dvd_20161224-160756/iso +WARNING: /dev/sr0 already carries isofs! +About to execute 'mkisofs -dvd-video /tmp/dvd_20161224-160756/iso | builtin_dd of=/dev/sr0 obs=32k seek=0' +I: -input-charset not specified, using utf-8 (detected in locale settings) +75.62% done, estimate finish Sat Dec 24 16:09:51 2016 +Total translation table size: 0 +Total rockridge attributes bytes: 0 +Total directory bytes: 4096 +Path table size(bytes): 42 +Max brk space used 1a000 +6624 extents written (12 MB) +/dev/sr0: "Current Write Speed" is 4.1x1352KBps. +builtin_dd: 6624*2KB out @ average 0.7x1352KBps +/dev/sr0: flushing cache +# +\end{lstlisting} + +\subsubsection*{BD Example – Partial Output during writing disc media} +\label{ssub:bd_example_partial_output_writing} + +\begin{lstlisting}[language=bash] +growisofs -dvd-compat -Z /dev/sr0=/tmp/bd_20161224-155658/bd.udfs +Executing 'builtin_dd if=/tmp/bd_20161224-155658/bd.udfs of=/dev/sr0 obs=32k seek=0' +/dev/sr0: "Current Write Speed" is 2.0x4390KBps. +1605632/24524800 ( 6.5%) @0.0x, remaining 1:39 RBU 100.0% UBU 0.0% +1605632/24524800 ( 6.5%) @0.0x, remaining 2:22 RBU 100.0% UBU 100.0% +1605632/24524800 ( 6.5%) @0.0x, remaining 3:05 RBU 100.0% UBU 100.0% +5865472/24524800 (23.9%) @0.3x, remaining 0:54 RBU 100.0% UBU 33.3% +11829248/24524800 (48.2%) @0.4x, remaining 0:21 RBU 75.8% UBU 37.5% +17858560/24524800 (72.8%) @0.4x, remaining 0:08 RBU 39.8% UBU 79.2% +23789568/24524800 (97.0%) @0.4x, remaining 0:00 RBU 4.5% UBU 4.2% +builtin_dd: 11984*2KB out @ average 0.2x4390KBps +/dev/sr0: flushing cache +\end{lstlisting} + +\section{Debugging DVDs Creation}% +\label{sec:debugging_dvd_creation} + +This section contains helpful hints, how to initially check the results, and some information on determining what might have gone wrong and how to address it. + +\begin{enumerate} + \item For first time users, taking the defaults seem to work very well when running as root. + \item You may want to use rewritable media to see how it goes before using permanent media. + \item Until you are familiar with the procedure, start with shorter input in order not to waste time. + \item Test the generated output with a compatible media rendering tool before burning DVDs. + \item Check the list of files and file sizes after the batch jobs are complete before burning DVDs. +\end{enumerate} + +For blu-ray creation, \texttt{cd /workpath/bd\_date-time} directory and look for similar files: + +\texttt{bd.jobs \qquad bd.m2ts \qquad bd.sh \qquad bd.udfs \qquad bd.xml} + +\texttt{udfs} directory which is used as a loopback mount point + +Note that the size of \textit{bd.udfs} should be larger than \texttt{bd.m2ts} because this is the final file which is actually going to be written to the disc media. It contains contents of \texttt{bd.m2ts} and all of the required disc structure. + +For DVD creation, \texttt{cd /workpath/dvd\_date-time} directory and look for similar files: + +\texttt{dvd.ac3 \qquad dvd.jobs \qquad dvd.m2v \qquad dvd.mpg \qquad dvd.sh \qquad dvd.xml} +\texttt{iso} directory with VIDEO\_TS and AUDIO\_TS subdirectories of non-zero size. + +Note that there will be no files in the actual AUDIO\_TS directory. + +\begin{enumerate}[start=6] + \item The \texttt{bd.sh} and \texttt{dvd.sh} files are script files that you can carefully run manually from some start point to determine where the failure occurred. You must BE CAREFUL and know what you are doing and what directory you are in because dvd.sh contains an \texttt{rm} command and will delete files. The script takes a command line parameter of the directory where the file was rendered to and which is usually the directory where dvd.sh or bd.sh was created. + \item There is also a file in the same directory, called bd.jobs. It was the information that was used in creating the batch jobs and may be helpful in determining what parameters were actually used if there are any resulting problems. With enough background knowledge, you can make changes and rerun. + \item For blu-ray check to make sure you do not have any spurious loopback disks mounted that may interfere with the correct generation. Use the df command to check this and then the umount command to unmount these. Also, check to make sure you have used the gsettings command to disable automount. + \item For blu-ray loopback mount the \texttt{/bd.udfs} image, and see if it has the BDMV filesystem written to it, and in particular a subdirectory named STREAM. Look at the results in \texttt{./udfs} and check for the stream file which should exist in \texttt{./udfs/BDMV/STREAM/00000.m2ts} and should have the same size as \texttt{./bd.m2ts}. + \begin{lstlisting}[language=bash] + mount -o loop /bd.udfs /udfs + ls -lR /udfs + du -sc /udfs + umount /udfs + \end{lstlisting} +\end{enumerate} + +\subsubsection*{Checklist for Troubleshooting} +\label{ssub:checklist_troubleshooting} + +\begin{itemize} + \item Are you logged in as root? This is required in order to loopback mount files for bluray and to write media on \texttt{/dev/hardware}. See section 8.3.5 \todo{What are you referring to?} for a workaround for normal user mode. + \item Did you startup cinelerra from a terminal window so you can see informative messages? + \item Is udftools installed for BD and dvdauthor installed for SD? + \item Do you have loopback not enabled for bluray? At least temporarily, disable automount via: + \begin{lstlisting}[language=bash] + gsettings set org.gnome.desktop.media-handling automount false + \end{lstlisting} + \item Did you have sufficient disk space for working/writing files? In the \textit{Create} window, the \textit{disk space} will be displayed in green if sufficient, but in red if less than what fits on the disc media. + \item Did you use \texttt{/tmp} as the work device, then rebooted the computer, which deleted files on \texttt{/tmp}? + \item If the input media is interlaced, did you check the Deinterlace option to eliminate interlacing? + \item Did you change the output name in the \textit{Batch Render} window after the batch jobs were already created? These filenames have already been written to disk. If you want to change either the Title or the \texttt{Work\_path}, you have to start over. + \item Have you selected a Title in the Create window that is a directory that already exists? The program attempts to create that directory and will give you an error message if it exists. + \item Did you replace the \texttt{/dev/bd} or \texttt{/dev/dvd} on the command line with your hardware device name? + \item If a warning was issued in the Create BD/SD window of \textit{* non-standard format} and your bluray reader could not play the disc, did you change to a standard format instead? + \item Did you correctly interpret the frame rate if using interlaced format to be $\frac{1}{2}$ due to interlacing? +\end{itemize} + +\section{Subtitles}% +\label{sec:subtitles} + +DVD (not blu-ray... yet) subtitles are added by using the main window pulldown \texttt{File $\rightarrow$ Subtitle} which brings up a window allowing you to type the filename of a previously generated text file containing the desired words/lines, the script. After entering the filename, click \texttt{Load} to read in your script. By creating a script file ahead of time, it lets you easily add dialog that was already written out and carefully edited for spelling and proper grammar. + +The format of the script/text input file has specific requirements as listed below: + +\begin{itemize} + \item Lines can be any length but they will be broken up to fit according to some criteria below. + \begin{itemize} + \item Running text used as script lines will be broken into multiple lines. + \item The target line length is 60 characters. + \item Punctuation may be flagged to create an early break. + \item Single carriage return ends an individual script line. + \item Double carriage return indicates the end of a entry and helps to keep track of where you are. + \end{itemize} + \item The "\textit{=}" sign in column 1 indicates a comment seen in the script text to assist you in location. + \item An “\textit{*}” at the beginning of the line is a comment and not a script line. + \item \textit{Whitespace} at either the beginning of a script line or the end will be removed. +\end{itemize} + +Figure~\ref{fig:subtitle01} shows the Subtitle window you will see. + +\begin{figure}[htpb] + \centering + \includegraphics[width=0.8\linewidth]{images/subtitle01.png} + \caption{Subtitle window} + \label{fig:subtitle01} +\end{figure} + +To put the subtitles onto your media, first add a subtitle track via the pulldown \texttt{Track $\rightarrow$ Add Subttl}. In the Subtitle window, note that there are 2 major textboxes. There is the \textit{Script Text} textbox showing the current entry of text from your input file and there is the \textit{Line Text} textbox showing the currently active text. In your subtitle track, select a timeline region (in/out or drag select with hairline cursor/highlight) to indicate the region where you want the active Line Text to be pasted. Then click the \texttt{Paste} button in the Subtitle window to paste the line onto the subtitle track. Silence will be added to the subtitle track in the places in the media where there are gaps. + +Editing in the Line Text box can be used to change the active script line. By double clicking the timeline over the subtitle track, you can reselect the active script line. The subtitle text will be reloaded into the Line Text box and can be edited and re-pasted as the new active subtitle text. You can also highlight multiple lines in the Script Text box and paste them (using the usual window paste methodology) into the Line Text box. After pasting to the timeline, the Line Text box will be updated with the next script line. In addition, if you triple click a line in the \textit{Script Text} box, it will automatically become the current line in the \textit{Line Text} box. + +When you are finished, before clicking \texttt{Save}, you must supply a legitimate filename in the \textit{Path} box; your current directory will be used if only a filename but no directory path is supplied. The filename used will automatically have a “-” after it followed by the \textit{track label} and then \textit{udvd} extension added; any extension in the filename will be removed.. If you click \texttt{OK} before saving, the subtitle script position is saved with the session. This is convenient for continuing where you left off. + +\noindent To reposition the script, use the slider or tumbler buttons: + +\textit{Slider} bar to move through the text entries quickly. + +\textit{Prev} or \textit{Next} buttons to go to the previous or next script line. + +\noindent Figure~\ref{fig:subtitle02} shows what the pasted subtitle script looks like in a portion of the main window. + +\begin{figure}[htpb] + \centering + \includegraphics[width=0.9\linewidth]{images/subtitle02.png} + \caption{Subtitles on timeline} + \label{fig:subtitle02} +\end{figure} + +\section{Dvd Interlaced Chroma}% +\label{sec:dvd_interlaced_chroma} + +Cinelerra uses $4:4:4$ colorspace to edit, so it is necessary to convert interlaced $4:2:0$ video to $4:4:4$. +But you can run into problems, referred to as the \textit{chroma bug}, which you see in DVD media displayed on higher resolution monitors -- streaks or spiky horizontal lines are visible in the chroma channel, especially on diagonal edges. The Chroma Bug is specific to MPEG and 4:2:0 encoding. + +Now you can use the \textit{YUV420P DVD Interlace Mode} when rendering DV directly to mpeg2 through a yuv4mpeg stream and when using video effects on HDV video. + +With this option enabled, improved chroma results will be obtained from your DV or HDV source. +Editing DV or HDV and rendering it back to the same format does not require any special handling. +In order to perform colorspace conversions correctly in Cinelerra and avoid Chroma errors for interlaced $4:2:0$ video, check the box as follows: + +\texttt{Settings $\rightarrow$ Performance $\rightarrow$ YUV420P DVD Interlace Mode} + +This option maintains the interlacing in Chroma sample addressing, which ordinarily would be deleted +because the upsampling of interlaced chroma fields is normally done using a progressive algorithm. +With this mode enabled, the MPEG decoder uses a different algorithm for interlaced frames so that the +$4:2:0$ format chroma interlacing is preserved. + +\section{MPEG utility programs}% +\label{sec:mpeg_utility_programs} + +There are 2 utility programs that come in handy when dealing with DVD media for creating or reading previously written DVDs. + +\paragraph{zmpeg3cc2txt} convert closed captioning data to subtitle data. + +This program can be used to scan captured broadcast data streams and convert the closed captioning text data into subtitle track data. The result can be used to add subtitles to DVDs created from the captured media using the text collected from the closed captioning. + +usage: + +\begin{lstlisting}[language=bash] +./zmpeg3cc2txt [-c cc_service ] [-s start:length, ...] [ -t track ] [-v verbose ] [-w wdw mask ] [-x file.xml ] [-o file.udvd ] file.ts +\end{lstlisting} + +\begin{tabular}{lcl} + cc\_service&=&closed caption service id\\ + + start:length&=&start:length frames (comma separated list)\\ + + track&=&video track number\\ + + verbose&=&verbose level\\ + + wdw mask&=&bit mask for windows (-1 = all)\\ + + file.xml&=&filename for edl xml format subtitle data\\ + + file.udvd&=&filename for udvd format subtitle data\\ + + file.ts&=&filename for transport stream\\ +\end{tabular} + +To use this program, the input file must be a transport stream (broadcast video) which contains closed captioning services. The service id defaults to one, and the default video track is zero. Either \texttt{-o} or \texttt{-x} must be specified to indicate the output file format desired. If the output file name is a '-' then stdout is selected as the output file. +For example: + +\begin{lstlisting}[language=bash] +zmpeg3cc2txt -o - /dvb_data/channel5.ts +\end{lstlisting} + +\paragraph{zmpeg3ifochk} check DVD \texttt{ifo} file for usable features. + +For some time, DVD manufacturers have been employing a variety of measures to make reading a DVD difficult on a computer. One technique which is widely deployed is to add a bunch of extra program data, so that correct playback is only likely if you can read the DVD virtual machine data and decode a maze of program data to find the undamaged stream definitions. Only a few streams are created which are machine usable, and dozens are created as decoy streams. The decoy streams fail or introduce errors. This program scans the IFO (info file) playlists and verifies the contents of the stream that does not contain obvious damage. The result is a list of program ids which can be entered into the playback preferences to select a program which qualifies. + +\section{HDV on a Blu-ray Disc Without Re-encoding}% +\label{sec:hdv_bd_without_reencoding} + +An MTS file is a video file saved in the high-definition (HD) MPEG Transport Stream video format, commonly called \textit{AVCHD}. It contains HD video compatible with Blu-ray disc format and is based on the MPEG-2 transport stream. MTS files are often used by Sony, Panasonic, Canon and other HD camcorders. Legal input for Video --- MPEG1VIDEO, MPEG2VIDEO, H264; Audio --- MP1, MP2, AC3, AC3PLUS, DTS, TRUHD. + +For creating a blu-ray disc, if you have HDV MPEG-2 media that is in blu-ray format, you can save the original quality of your work, rather than rendering it to another format. Follow the steps below directly instead of going through cinelerra. It has been tested on 10 different MTS files. + +\begin{lstlisting}[language=bash] +du -sb /yourHDVfile.MTS # Determine the size of your file in bytes. +blocks=((size-in-bytes/2048 + 4096)) # Convert bytes into blocks + a little more. +mkudffs /tmp/newfilename.udfs blocks # Create a file with that \# of blocks + some extra. +mount -o loop /tmp/newfilename.udfs /mntX # Use a mount point like mntX that is not in use. +//bin/bdwrite /mntX /tmp/yourHDVfile.MTS # Substitute cinelerra path. +umount /mntX # You must unmount the udfs filesystem +growisofs -Z /dev/bd=/tmp/newfilename.udfs # Replace /dev/bd with your bluray hardware device. +OR dd if=/tmp/newfilename.udfs of=/dev/bd bs=2048000 # if using rewritable blu-ray; replace bd. +\end{lstlisting} + +\section{Blu-ray Workaround for Mount/Umount}% +\label{sec:bluray_workaround_mount_umount} + +Creating BD images to be written to media requires usage of \textit{mount} and \textit{umount} which typically can only be done by the root user due to security. If you want to avoid running cinelerra as root, you can implement a workaround by adding a line in \texttt{/etc/fstab} (must be root to edit the file initially) and by creating a directory in your home area, called \texttt{bluray}. You only have to do this once unless you upgrade the Operating System and it wipes out the line in \texttt{/etc/fsta}b. Now the cinelerra program will automatically do the mount and umount for you each time you execute BD Render and you can run as an ordinary user. + +The line to add to \texttt{/etc/fstab} will look something like the following, assuming your username is \textit{name} and your groupid may be \textit{users} or \textit{name}. If you do an \texttt{ls -l} in your home directory, the $3^{rd}$ and $4^{th}$ fields shown will be your uid or name and gid or groupid which you must substitute in the line below. + +\begin{lstlisting}[language=bash] +/home/name/image /home/name/bluray udf noauto,loop,rw,user,uid=name,gid=groupid 0 0 +\end{lstlisting} + +Also, be sure to do a \texttt{mkdir bluray} in your \texttt{/home/name} directory as this is a requirement (owned by you; uid=gid=name). When the actual image to be written to disc media is created, it will first d any current \texttt{/home/name/image} file. Warning – make sure you do not already have a file called \textit{image} that you want to save as it will be automatically deleted every time you initiate a BD Render. So you will want to burn a bluray disc after cinelerra creates the \textit{image} since it will written over on the next rendition. The actual writing to your bluray burner (something like \texttt{/dev/sr0}) is done outside of cinelerra at a terminal prompt and requires root privilege usually. You can either use \textit{sudo} for 1 line or create user wheel group to get around this. + +\section{Blu-ray from Multiple Cinelerra Output}% +\label{sec:bluray_multiple_cinelerra_output} + +Writing prepared multiple cinelerra output files, \texttt{bd.m2ts}, to a single bluray disc is relatively easy to do but is not done automatically. You can render all of the desired files via the Create BD menu, save each individual \texttt{bd.m2ts} file with a unique name, construct a Menu Title that reflects the contents of each of these files, then manually use a few commands to create a udfs file to be written to BD. + +Usage of the final preparation taken from the bdwrite program comments: + +\begin{lstlisting}[language=bash] +./bdwrite ... + + == - | -- | --- + may be empty string, or a numeric pgm_pid for current title clip + defaults to first pgm probed + == ... +\end{lstlisting} + +One title is built for each playlist; playlist-0 is used as first-play item. The separators (\texttt{} represented by the dash character) have unique roles. The double “$--$” means stop after playing, and the triple “$---$” means pause. + +For example: + +\begin{lstlisting}[language=bash] +./bdwrite /tmp/dir /path/menu_titles.m2ts --- /path/clip0.m2ts -- /path/clip1.m2ts -- /path/clip2.m2ts +\end{lstlisting} + +The basic idea is to use playlist-0 as a menu or directions to use the bluray player remote control to select the desired Title and start the play, avoiding the need for a menu system. Planning in advance to get the desired results is necessary. The following steps provide an outline to get started. + +\begin{enumerate} + \item Create all of the \texttt{bd.m2ts} files that you want to put on the Bluray. + \item Using cinelerra, design your Title page using a few seconds of video and the \textit{Title} plugin. + \item Use BD Create to render your short Title video. + \item Next is the most complicated part which is to run \texttt{mkudffs} with a sufficient amount of disk space to hold all of the \texttt{bd.m2ts} files \textit{plus a little more!} To calculate this, you can record the sizes from having run BD Create mkudffs. This number is displayed on the terminal screen when using the command line interface each time and add them together. Or recalculate the size of each bd.m2ts using the formula below and adding them all together. This is the number of blocks used to make a bluray image space for bdwrite to use. For many files, this could require a huge amount of space, so check first. + \begin{lstlisting}[language=bash] + Total size = File0 size in bytes / 2048 + 4094 “+” File1 size in bytes / 2048 + 4094 “+” ... + \end{lstlisting} + Now create the image file via: \texttt{mkudffs image } where image or udfs is the image name. + \item Loop mount the disk image (refer to Sections 8.3.4 and 8.3.5 \todo{idem as above}). + \item Then actually write your multiple bd.m2ts type files onto the \textit{image} where \texttt{} is the location of the cinelerra binary \textit{bdwrite} file and \texttt{} is your directory path. Below is a single line that wrapped around with 4 Titles. + \begin{lstlisting}[language=bash] + /bin/bdwrite image /menu_titles.m2ts --- //bd1.m2ts -- //bd2.m2ts -- //bd3.m2ts -- /bd4.m2ts + \end{lstlisting} + Note that the 3 dashes after the \texttt{menu\_titles.m2ts} lets the bluray player know to \textit{pause} after playing the few seconds video which contains the index to the rest of the files. The 2 dashes after each of the bd.m2ts signify \textit{stop}. That is when you will have to use your remote to \textit{Search Titles} in order to play the next one you want to see. In addition, if for some reason you just want to \textit{play all}, you will have to add another line to the Title menu as a choice and list all of the 4 files in a row at the end of your bdwrite line without any dashes in between. + \item Umount the loopback disk. + \item Use your favorite \textit{dd} or \textit{growisofs} tool to write to a formatted bluray disc. +\end{enumerate} + +Figure~\ref{fig:dvd-title} demonstrates an example of setting up a Title menu on a 5 second video. There is a list of 4 menu title options that can be searched via remote control using the Title search option for your player. + +\begin{figure}[htpb] + \centering + \includegraphics[width=0.8\linewidth]{images/dvd-title.png} + \caption{Title menu for DVD/BD} + \label{fig:dvd-title} +\end{figure} + +\section{Use Case: DVD}% +\label{sec:use_case_dvd} + +Example of Video Source with 4:3 Aspect Ratio, Being Transcribed to 16:9 and Creating a DVD to be Displayed on a Digital TV. Illustrated steps to take source input with 4:3 aspect ratio and convert to 16:9, with the bottom of the image being cropped in order to preserve top of video so nobody's head gets cut off are provided here. + +\begin{enumerate} + \item In order to write to a DVD writer hardware device, you must be \textit{root}!! + \item Start Cinelerra-GG to bring up the 4 usual screens with main track canvas in the lower left corner. + \item Load media via the pulldown \texttt{File $\rightarrow$ Load files}\dots by choosing the directory path with the desired file. + \item Bring up the \textit{Create DVD} window using \texttt{File $\rightarrow$ DVD Render}. + \item Choose Format: PAL or NTSC with 16x9 aspect ratio for today's digital TV as in below screenshot. figure~\ref{fig:dvd-000}. +\end{enumerate} + +\begin{figure}[htpb] + \centering + \includegraphics[width=0.7\linewidth]{images/dvd01.png} + \caption{Choose NTSC or PAL for DVD creation} + \label{fig:dvd-000} +\end{figure} + +\begin{enumerate}[start=6] + \item Modify the \textit{Work path:} parameter to a disk that has sufficient disk space and you will see the + amount of disk space in green letters (\texttt{/tmp} is default, but is often deleted so may be a bad choice). + \item Note that in the following screenshot, Scale of \textit{Cropped} has been chosen (figure~\ref{fig:dvd03}). +\end{enumerate} + +\begin{figure}[htpb] + \centering + \includegraphics[width=0.9\linewidth]{images/dvd03.png} + \caption{Set Scale Ratio to Cropped} + \label{fig:dvd03} +\end{figure} + +\begin{enumerate}[start=8] + \item Click the green checkmark on the bottom left side of the window to close it and proceed. + \item Now the \textit{Batch Render} window will appear along with the Scale Ratio brown-colored line below the video in the main track canvas as seen in the screenshot below. Note that in this screenshot the top right most corner of the shot displays the bottom portion of the Compositor window. + \item Next, right mouse click the gold-colored magnifying glass, which is on the right hand side of the brown-colored line. This will bring up the Scale Ratio window that you can see below. Note in the Compositor window, the blue legs are only showing up to the knees. +\end{enumerate} + +With the \textit{Scale Ratio} plugin you can manipulate your video so that it will look the way you want it on a different output Display device. In this case we are going to create a DVD for playing on a Digital TV screen. + +In figure~\ref{fig:scaleratio}, the left side shows the Input Ratio, Width, and Height of input. The top right half shows desired output values. In this particular case, the input was a YouTube video which was not quite $4:3$ aspect ratio. + +\begin{figure}[htpb] + \centering + \includegraphics[width=0.7\linewidth]{images/scaleratio.png} + \caption{Scale Ratio plugin} + \label{fig:scaleratio} +\end{figure} + +Left and right sides of the bottom portion show the Source and the Destination X, Y, W, H values. As you change the values on the left side, you can see how this will affect the output as you observe the results in the compositor window. For example, as you change the values for SrcY in a \textit{cropped} Scale scenario, you see up/down movement. + +Keep in mind that the monitor you are using is NOT the intended output display device --- your digital TV is, which most likely will have different looking aspect/pixels, etc. + +\begin{enumerate}[start=11] + \item In order to \textit{crop} the bottom of the video in order to preserve all of the image on the top, modify the Src Y value on the bottom of the left hand side in the Scale Ratio plugin. Src Y which was $21$ has now been changed to $-18$. You will see in the Compositor window how the bottom dark colored border is now gone so that none of the top portion which contains a person's head will be chopped off. Compare figure~\ref{fig:dvd04} to figure~\ref{fig:dvd03} and note the blue legs can be now seen to the waist. +\end{enumerate} + +\begin{figure}[htpb] + \centering + \includegraphics[width=0.9\linewidth]{images/dvd04.png} + \caption{Better scale on compositor} + \label{fig:dvd04} +\end{figure} + +\begin{enumerate}[start=12] + \item Click the \texttt{Apply} box in the Scale Ratio window. + \item Click the \texttt{Save to EDL Path} in the \textit{Batch Render} window for creating a DVD. If you do NOT do this, you will get a Warning box as seen in figure~\ref{fig:dvd-batch05}, to remind you to Save because you have changed the EDL by modifying the scaling parameters in the Scale Ratio window. +\end{enumerate} + +\begin{figure}[htpb] + \centering + \includegraphics[width=0.8\linewidth]{images/dvd-batch05.png} + \caption{Error in Batch Render} + \label{fig:dvd-batch05} +\end{figure} + +\begin{enumerate}[start=13] + \item Next, make sure you have the Timeline set in the Main window at the beginning of where you want to start rendering. Also, make sure the first line in the \textit{Batches to render} section is highlighted as you can see above by the blue highlighting. Click on the \texttt{Start} box in the Batch Render window and you will see the video playing in the Compositor window. + \item Cinelerra program will be stopped when done rendering; you will be at the terminal prompt where you will see it has printed out some informational messages (or errors if problems), the last 2 are: + \begin{lstlisting}[language=bash] + To burn dvd, load blank media and run: + growisofs -dvd-compat -Z /dev/dvd -dvd-video /mnt0/dvd_20161027-131723/iso + \end{lstlisting} + \item Load a blank or rewritable DVD into your DVD writer device, which will be similar to \texttt{/dev/dvd} as in the \textit{growisofs} line above --- something like \texttt{/dev/sr0} on your computer. + \item Keyin the \textit{growisofs} line, substituting your actual writer device name. Again, you must be root. + \item When back at the terminal prompt, and if there are no errors, keyin \texttt{eject /dev/dvd} substituting. + \item Play it on your DVD player connected up to your Digital TV screen. +\end{enumerate} + + + diff --git a/parts/Recording.tex b/parts/Recording.tex new file mode 100644 index 0000000..73d2325 --- /dev/null +++ b/parts/Recording.tex @@ -0,0 +1,663 @@ +\chapter{Capturing and Recording Media}% +\label{cha:capturing_recording_media} + +This section covers the areas of capturing media from the web or television by the use of recording. + +Access the Record function via \texttt{File} $\rightarrow$ \texttt{Record}\dots The recording application really only does one thing, capture media from some external source, and write it onto a file in a specified way. + +\vspace{2ex} +\begin{tabular}{lll} + Path: & output media file path & \\ + + Start time: & weekday/time of day & to begin capture\\ + + Duration: & hrs:mins:secs & until end of capture\\ + + Source: & channel/device input & selection of input subsource\\ + + \multirow{2}*{Mode:} & timed & use start time/duration \\ + + & untimed & use transport controls\\ +\end{tabular} + +\vspace{2ex} +The media file will be written using the format and codec specified in the \texttt{Settings $\rightarrow$ Preferences $\rightarrow$ Recording tab}, which you will need to set up first. See the Settings/Preferences \todo{reference to section} section for parameters. Only ffmpeg can record both audio and video simultaneously, and some ffmpeg formats require too much cpu to do a realtime compression. A setting which is more likely to be usable (requires less cpu/memory for realtime encoding) is \texttt{ffmpeg /qt/mp4.qt} with bitrates like $audio/256000$ \& $video/6000000$. + +\section{Record Web Media in real-time}% +\label{sec:record_web_media_rt} + +Below describes the necessary steps for recording freely available media from the internet for your own personal use. You have to be on a system using pulseaudio, such as ubuntu, fedora, centos. + +\begin{enumerate} + \item Start cinelerra and select \texttt{Settings $\rightarrow$ Preferences $\rightarrow$ Recording} From a terminal (with a wide text window) run: \texttt{pactl list}. You will see all of the audio sources and sinks on your system. Identify the source associated with the normal output your system uses. Example: \texttt{Source $\#1$}. Locate the source which monitors your normal audio output. For example: \texttt{front stereo}. + \item Choose a \textit{File Format} and \textit{File Type} (for example: \texttt{FFMPEG \& qt}). + \begin{itemize} + \item Check \texttt{Record audio tracks}. + Click \texttt{Audio wrench} tool: + \begin{itemize} + \item Select \texttt{mp4}, for example. + \item Set \texttt{Bitrate} ($256000$ is a reasonable number). + \end{itemize} + \item Check \texttt{Record video tracks}. + \item Click \texttt{Video wrench} tool: + \begin{itemize} + \item Select \texttt{mp4} video, for example. + \item Set \texttt{Bitrate} $1000000 - 4000000$ (bigger=better, but more cpu) + \end{itemize} + \item Select \texttt{Audio In $\rightarrow$ Record Driver: ALSA} (or whatever you have instead) + \begin{itemize} + \item Set the \texttt{Bits}: \texttt{16 Bit Linear} (probably, because reasonable and fast) + \item Select \texttt{Device}: the source from above \texttt{pactl} list search, for example Source $\#1$ + \item Samples read from device: aprox dev buffer size ($2k-16k$ probably) + \item Samples to write to disk: $131072$ (a good size) + \item Sample rate for recording: $44100$ (will automatically change) + \item Channels to record $2$ (probably) + \item Uncheck Map $5.1 \rightarrow 2$ + \item Gain $1.0$ + \end{itemize} + \item Select \texttt{Video In $\rightarrow$ Record Driver}: \texttt{Screencapture} + \begin{itemize} + \item Set the \texttt{Display}: leave blank (probably) or use "$:0.0$" (default screen/display) + \item Frames to record to disk at a time: $30$ (a good number) + \item Frames to buffer in device: $(2-6)$ (probably) + \item Positioning: \texttt{Software Timing} (important) + \item Uncheck: \texttt{Sync drives automatically} + \item Size of captured frame: $720x480$ (this is your choice, actual capture size; $600x320$ youtube) + \begin{itemize} + \item This defines a \textit{screen capture} rectangular area on the display. + \item Try to make it the size you need to cover the screen playback area. + \end{itemize} + \end{itemize} + \item Frame rate for recording $23.97 fps$ (a good choice, not all choices work) + \item OK + \end{itemize} + +\end{enumerate} + +When recording from the screen, a large green-colored boundary box appears to allow you to easily frame the screen area to be recorded when you move it around to where you want to position it. In addition there are \textit{record cursor} and \textit{big cursor} check boxes which allow for also recording the cursor and for making the cursor bigger. + +Screenshot to illustrate some appropriate settings which are described above/below the image (figure~\ref{fig:recording01}). + +\begin{figure}[htpb] + \centering + \includegraphics[width=0.9\linewidth]{images/recording01.png} + \caption{Recording window with tipical settings} + \label{fig:recording01} +\end{figure} + +\begin{enumerate}[start=3] + \item Make sure the Compositor window is up since you will want to see the captured media later. From the main window press (lower case \texttt{r}) (move windows and resize if needed) Using the mouse pointer, mouse over the \textit{Video In} Recording monitor display. Press and hold the left mouse button and drag the display until the desired target screen capture area is properly positioned inside the record monitor \textit{Video In} display. At first this may seem confusing, but keep in mind that what you are actually doing is positioning the portion of your monitor display you want to capture over the \textit{Video In} window. + \item From the \textit{Recording window} select a Path file name for the recording. + \item Select mode untimed. + \item Make sure the \textit{monitor audio} is unchecked else audio becomes looped and is very loud. + \item Press Transport \texttt{start recording} (red circle button). + \item Operate the playback of the media source, i.e. start playing the web video. + \item When the media ends, stop on the playback application. + \item Press Transport \texttt{stop recording} button (white square button). + \item Before clicking \texttt{chk-Ok}, be sure to set the \textit{Insertion Strategy}. + \item Press \texttt{chk-Ok} to review the capture, or \texttt{X} to cancel/dismiss application. +\end{enumerate} + +Two things are happening during recording, the data is being written, and it is being rendered. When recording, if video and audio are not in sync, it will usually be video behind audio as opposed to the other way around because video is more difficult to decode. During recording, video frame and audio sample positions are checked and efforts to maintain synchronization are used. Below is an explanation for some of the less obvious settings for recording as shown in the previous screenshot. +\paragraph{Frames dropped} more input than cpu(s) can process. This is the number of frames dropped when the system is too slow to keep up with the video. This value serves as a warning that it is behind and is dropping frames to keep up. You might want to consider stopping to make some parameter adjustments and start over to reduce drops. +\paragraph{Frames behind} active input buffers. This is the number of frames that the video is behind and it will drop frames to get caught up. \textit{Frames behind} depends on the synchronization source, for example, time as the synchronization. This means that frames are not being written as fast as they are being captured and can occur when the system is too slow to keep up. This situation can happen with older systems or cpus where there is more input then can be processed in a timely manner. So that when there are “Frames behind”, frames will be dropped. + +The algorithm for determining how many frames to drop is as follows: + +\begin{itemize} + \item If the number of frames behind $> 3$, only $3$ frames will be dropped before it will then do $1$ frame; + \item if the number of frames behind is $2$, only drop $1$ frame; + \item if only $1$ frame behind, no frames will be dropped. +\end{itemize} +\paragraph{Drop overrun frames} checkbox when enabled, frames will be dropped. Drops occur when you capture a frame and there is no storage space available to save it, usually because buffer space is exhausted. This situation can occur when there are too many frames coming in too fast and the I/O system is not keeping up in emptying the buffers. +\paragraph{Fill underrun frames} checkbox if enabled, duplicate last frame when no input frame ready for output. As the tooltip states \textit{write extra frames when behind}. This is desirable in order to keep audio and video synched with regards to sample and frame rates. Use underrun padding to fill frames when the input capture rate is lower than the output frame rate. Since demand is constant, you have to output something, so the last frame is duplicated as many times as needed to keep up. You should stop and adjust the frame/sample rates to match the input if not filling underruns, then start over. This situation can occur if the input stops for some reason like lightning interrupts the signal or the internet connection is too slow. +\paragraph{Transport controls} these control buttons mimic the functions of tape recorders from the old days. + +\begin{itemize} + \item \textit{Reverse button/left arrow} --remnant from the past; does the same as the Start button really. + \item \textit{Red round button} --this is the Start button to start recording. + \item \textit{White square} --this is the Stop button to stop recording. + \item \textit{Red round button with white line} --start recording in single frame mode. The way this works is to just \textit{take a picture now, take a picture now\dots} The reason to use this mode is to get a still shot like you would with a camera. Sometimes input is continuous, for example looking at stars with a telescope -- surveillance goes on for hours, but you just want to take a picture now when something of significance interest comes up +\end{itemize} +\paragraph{Cron} The batch recording watcher, cron, is either Idle or Active. When you start or stop batch recording at specific times, there is a cron thread watching timers to perform the timed action. Idle/Active indicates whether the timers are running. +\paragraph{Position} this is a timebase which tracks frames/samples when obeying frame/sample rate. When a recording starts, it resets to 0. Timing is against audio (when available). Audio time and video time are based on position. +You can select synchronization time source \textit{Positioning} in: + +\texttt{Settings $\rightarrow$ Preferences} under the \texttt{Recording} tab. + +\noindent Possible choices for time base are: + +\begin{itemize} + \item \textit{Presentation Timestamps} --use time code which is in both the audio and video media input stream. Uses these timestamps to sync the 2 streams. + \item \textit{Device Position} --this is the device hardware position of where you are. It is usually only on the audio side. + \item \textit{Sample Position} --Sample $\#$ or frame $\#$ divided by frame rate tells you where you are. + \item \textit{Software Timing} --usually used for things like YouTube; it just will \textit{take a picture now} \dots \textit{take a picture now} \dots over and over again until you tell it to stop. +\end{itemize} + +Positioning \& Timing needs more detailed explanation for complete understanding and application. The overall goal is to maintain media stream timeline synchronization. The reason for providing different \textit{Positioning} options is that different input media may have different timebase standards. Additionally, the input may be damaged. Damaged data can skew the timeline during presentation. The timebase standards make it possible to correctly resynchronize the media presentation to the original time position. For example, the transport layer may have timestamps provided in it. These timestamps record \textit{audio time} and \textit{video time} and are called \textit{presentation timestamps}. + +The kind of positioning used depends on the input device and the media format. In the transport stream example, the media has already been coded at least once as a stream and contains position information. In other situations, sample position or device position can provide timeline position. If the input device provides data at a variable or asynchronous rate, then software timers can provide timeline position. Sample position is position from the perspective of software, and device position is position from the perspective of hardware. The difference is buffer time. Device position is usually more accurate, but may not be available, or may contain errors. + +Examples of media which usually has a particular type of positioning is: + +\begin{enumerate} + \item mpeg has timestamps therefore Presentation Timestamps is a good recording choice; + \item raw media streams/screen capture have no timestamps, so tell it time via Software; + \item a web cam may supply data at variable rates, so again you would use \textit{Software timing}; + \item an example of Device Position is audio (timestamps can come off the device); + \item if Software Positioning working for you, try Sample Position for really bad audio. +\end{enumerate} + +Other \textit{Recording} settings are more pertinent to capturing and editing broadcast television with all of its many commercials. Their usage will be explained in more detail in a later section. +\paragraph{Label} create a label. During capture, put a time marker at the designated spot. When the recording +gets pulled in later for review, you will see a green arrow marking the spot that was clicked. +\paragraph{ClrLbls} clears all of the previously set labels. +\paragraph{Check for ads} check for commercials. In real time, labels are added when a commercial that matches +a previous ad is already in the database (the TDB, Traveling Data Base). + +One other noted new feature is a new choice for recording - \texttt{V4L2 MPEG}. Some digital tuners now stream mpeg data for broadcast data streams. V4l2 has been upgraded to be able to process data from these device streams. Figure~\ref{fig:recording02} shows the available options to include v4l2 mpeg. + +\begin{figure}[htpb] + \centering + \includegraphics[width=0.9\linewidth]{images/recording02.png} + \caption{new feature v4l2 mpeg} + \label{fig:recording02} +\end{figure} + +\section{Digital Video Broadcasting (DVB)}% +\label{sec:digital_video_broadcasting} + +You can do real-time capture of a full transport stream of Broadcast TV. Record television programs using Cinelerra by setting up ahead of time to start recording later at the specified time. Then you can use Cinelerra to watch later and easily fast forward through the commercials or edit the program, deleting the commercials, to watch uninterrupted. Some details may be slightly different than what it is in the United States. There are 3 requirements you must have to take advantage of this capability. + +\begin{enumerate} + \item You need to have a suitable DVB Adapter such as the Hauppauge WinTV-HVR 950Q usb adapter. Make sure it is the linux version, not the new version. + \item Your DVB adapter on your PC should connect to a broadcast antenna input. + \item For now, you may have to run as the \textit{root} user. +\end{enumerate} + +\subsection{Overview}% +\label{sub:overview} + +There is a lot of detailed explanation below to be thorough, but an overview is presented here. + +\begin{enumerate} + \item Set up Record Preferences. + \item Scan the Channels. + \item Watch TV by selecting the desired channel. + \item Or set up a batch job to record a program and watch later via \texttt{Ctrl-Alt-s} in the main window. + \item Or record a currently running program by using the buttons in the Record window. + \item Load a previously recorded program. +\end{enumerate} + +\subsection{Initial Setup for DVB Capture}% +\label{sub:initial_setup_dvb_capture} + +Listed below are the steps for the initial DVB setup. Setup will be preserved until you make changes. + +\begin{enumerate} + \item Start cinelerra, and click \texttt{Settings $\rightarrow$ Preferences $\rightarrow$ Recording} + \item Select \textit{File Format} checkbox: \texttt{Realtime TOC} (Table of Contents) + \begin{itemize} + \item It is not necessary to set File Format at this point as it will automatically be set later. + \item Check \textit{Record Audio Tracks}. + \item Check \textit{Record Video Tracks}. + \end{itemize} + \item Select \texttt{Audio In $\rightarrow$ Record Driver: DVB} + \begin{itemize} + \item Set the \texttt{adapter path = /dev/dvb/adapter0} (probably) + \item Set the \texttt{adapter dev = 0} (probably) + \item Set the \texttt{Bits: 16 Bit Linear} (probably) + \item Check: \texttt{Follow audio config} + \item \texttt{Samples read from device}: $2048$ or approximate dev buffer size ($2k-16k$ probably) + \item \texttt{Samples to write to disk}: $131072$ (a good size) + \item \texttt{Sample rate for recording}: $48000$ (will automatically change, probably to $44100$) + \item \texttt{Channels to record}: 2 + \item Uncheck \texttt{Map} $5.1 \rightarrow 2$ + \item \texttt{Gain}: $1.0$ + \item Uncheck: \texttt{Record in real-time priority} + \end{itemize} + \item Select in \textit{Video In}: \texttt{Record Driver: DVB} (note: File Format above changes to \textit{MPEG Stream}) + \begin{itemize} + \item Set the \texttt{DVB adapter} path = \texttt{/dev/dvb/adapter0} (probably) + \item Set the adapter \texttt{dev} = 0 (probably) + \item Check: \texttt{Follow video config} + \item \texttt{Frames to record to disk at a time}: 30 (a good number) + \item \texttt{Frames to buffer in device}: 2 ($2-6$ probably) + \item \texttt{Positioning: Presentation Timestamps} (\textbf{this is important and may not be already set}) + \item Uncheck: \texttt{Sync drives automatically} + \item \texttt{Size of captured frame}: $720x480$ (will automatically change) + \item \texttt{Framerate for recording}: $29.97$ (will automatically change) + \item Click \texttt{OK} + \end{itemize} +\end{enumerate} + +Figure~\ref{fig:recording03} shows the Preferences window as a good example of what you should see. + +\begin{figure}[htpb] + \centering + \includegraphics[width=0.7\linewidth]{images/recording03.png} + \caption{Example of the Recording settings} + \label{fig:recording03} +\end{figure} + +Scan the channels once the devices are setup by performing the following. + +From the main window pulldown use: \texttt{File $\rightarrow$ Record} (lower case \textbf{r}) \& \texttt{resize windows}. + +\begin{itemize} + \item Two windows appear -- the \textit{Recording} and the \textit{Video In}. The Recording window should have \texttt{Monitor video} checked and \texttt{Monitor audio} unchecked. Remember to check the Monitor audio later when you want to listen to a TV program. + \item On the \textit{Video In} toolbar, click the \texttt{antenna} button (\textit{Edit channels} tool tip). + \item When the \textit{Channels} window opens, click \texttt{scan} -- \textit{Scan confirm} window appears. + \item Make sure \texttt{Freq table NTSC\_DVB}, \texttt{Norm NTSC}, and \texttt{input0} are chosen automatically. + \item Click \texttt{OK} and then wait for scan to end which may take several minutes. +\end{itemize} + +Figure~\ref{fig:channels01} on the left shows the Channels window and the popup waiting for scan confirmation. On the right side is the usual Recording window with the Video in window hidden behind. + +\begin{figure}[htpb] + \centering + \includegraphics[width=0.7\linewidth]{images/channels01.png} + \caption{Clockwise: Channels window; Video In (behind); Recording and Scan confirm} + \label{fig:channels01} +\end{figure} + +Figure~\ref{fig:channels02} shows scanning in progress. Note the \textit{Video In} with the antenna icon (3rd symbol). + +\begin{figure}[htpb] + \centering + \includegraphics[width=0.8\linewidth]{images/channels02.png} + \caption{Scanning in progress ($6\%$)} + \label{fig:channels02} +\end{figure} + +Any time after the channels have been scanned, you can edit them from the \textit{Recording} window channel selection dialog (shown on left of screenshot above, such as \textit{Sort}). You do not have to scan the channels every time as they are saved in a database referred to as the \textit{channel-db}. + +\begin{itemize} + \item Click \texttt{chk-OK} when done scanning channels and making any edits you want. +\end{itemize} + +\noindent After the channel-db is ready, you can watch any of the selectable channels. + +\subsection{Watching TV using Cinelerra}% +\label{sub:watching_tv_cinelerra} + +If you have setup for DVB capture as outlined in the section above, just start here to watch TV. + +\begin{itemize} + \item From the main window use \texttt{File $\rightarrow$ Record} to request the \texttt{Recording} application. + \item In the \textit{Video In} window, press the \texttt{down arrow} on the left to see the channel pulldown. + \item Select the desirable channel, and watch TV. You will have to enable the audio by checking the \texttt{Monitor audio} in the Recording window for sound. +\end{itemize} + +\textit{Helpful hints}: for any computer that you might choose to use that is a little slower, you can improve the available resources for watching TV by unchecking \texttt{Audio meters}, checking \texttt{drop overrun frames}, and checking \texttt{fill underrun frames}. Also, uncheck \texttt{Realtime TOC} in the \texttt{references $\rightarrow$ Recording} window. + +Dismiss the \textit{Recording} window with \texttt{chk-OK}, or \texttt{X} to cancel when finished. + +\subsection{Recording TV to Capture at some Future Time via Batch}% +\label{sub:recording_tv_future_time_batch} + +After the initial setup and channel scan completion, with the Recording application down (so that the \texttt{/dev/dvb/adapter0} hardware is not in use) you can scan the DVB channel program data by pressing \texttt{Ctrl-Alt-s} from the main window. It can take a minute or two to scan the channels. The resulting display is a large array of program buttons, with tooltips which are the TV program info text. + +Figure~\ref{fig:channels03} shows \textit{Channel Info} window after the \texttt{Ctrl-Alt-}s completes scanning TV program data. + +\begin{figure}[htpb] + \centering + \includegraphics[width=0.95\linewidth]{images/channels03.png} + \caption{Channels Info window with many TV channels buttons} + \label{fig:channels03} +\end{figure} + +Now if you mouse over a program button, you see the TV program's info. Each of the programs is represented by a button. If you press a button, it preloads the program recording information into the batch record box below. In the bottom right corner box, you should set the \textit{Directory} path of where to write the recording before pressing a button, so that the files will be written to an area of sufficient size to handle the recording (9.5Gb/hr). The two little spinboxes on the Duration line in the right bottom corner are leadin/leadout times to start recording a few minutes early, and end a few minutes late to prevent losing program endpoints. Instead of setting it to the original default of 0, you might want to start 3 minutes ($-3.00$) before and stop 3 minutes after ($+3.00$). Also, be sure your computer has the correct time or it will miss. Check to make sure the \texttt{Start Cron} option is checked (default). The batch job will start monitoring the channel to be ready for capture once you \texttt{chk-OK} and you will see the \textit{Recording} window and the \textit{Video In} window come up. The computer will power off after completion if the \texttt{Poweroff} checkbox is selected (not default). The job line of the active capture in the batch bay will flash continuously once the recording is started. + +In the Channel Info window, lower left hand corner above, there is a \texttt{Find} button which brings up a textbox so you can type in a TV program. When you double click on that program name, the cursor moves to the center of that program name in the list of programs in the window, highlights that program, and the characters that were white on black, turn yellow. + +\subsection{Recording Immediately to Capture a current TV program}% +\label{sub:recording_capture_current_tv_program} + +If you have setup for DVB capture as outlined in the first section above, just start here to record a TV program that is currently playing and stop it whenever you want. Media files can be directly captured from the \textit{Recording} window to include \texttt{Start}, \texttt{Stop}, and then loaded via \texttt{chk-OK}. + +\begin{itemize} + \item Bring up the \textit{Recording} window via the main window \texttt{File $\rightarrow$ Record} (lower case \textbf{r}). + \item Set the \texttt{Path} to the write file Path; be sure there is enough disk space ($9.5Gb/hr$). + \item Set \texttt{Mode} pulldown to \texttt{Untimed} found in the upper left corner area of the window. + \item Press transport \texttt{start recording} button (red round button). + \item Path will flash and update in batch window and remain flashing while recording. + \item Press transport \texttt{stop recording} button (white square button). + \item Before clicking \texttt{chk-OK}, be sure to set the \textit{Insertion strategy}. + \item Pressing \texttt{chk-OK} attempts to load any newly recorded media data for review. + \item Or press \texttt{X-cancel} to terminate and dismiss the \textit{Recording} application. +\end{itemize} + +Figure~\ref{fig:recording04} shows the recording of a currently running broadcast TV program weather report. + +\begin{figure}[htpb] + \centering + \includegraphics[width=0.95\linewidth]{images/recording04.png} + \caption{Recording in real-time a tv weather report} + \label{fig:recording04} +\end{figure} + +\subsection{Record “on the fly” Table of Contents (TOC)}% +\label{sub:record_on_the_fly_toc} + +If the \texttt{Settings $\rightarrow$ Preferences $\rightarrow$ Recording} tab is selected, and the \texttt{video Record Driver} is changed to \textit{DVB}, the file format is switched to \textit{MPEG Stream} automatically (note that the \texttt{audio Record Driver} must also be set to \textit{DVB} for broadcast recording). This kind of record stream can be captured by simply writing the hardware capture stream directly to the record capture asset file path. But by checking the \texttt{Realtime TOC} in the \texttt{Preferences $\rightarrow$ Recording} window, it is possible to scan the stream data \textit{on the fly} on its way to being written while the asset is being captured . The scan is used to generate a TOC – Table of Contents file in the \texttt{\$HOME/.bcast5} directory. This file is used by the mpeg library to view the stream. This avoids the need to scan the file on first open since the TOC builder can run in realtime. + +Figure~\ref{fig:realtime_toc} shows the red-checked \texttt{Realtime TOC} for the \textit{Record Driver} of DVB. + +\begin{figure}[htpb] + \centering + \includegraphics[width=0.8\linewidth]{images/realtime_toc.png} + \caption{Realtime TOC check red button} + \label{fig:realtime_toc} +\end{figure} + +\subsection{Watching a Previously Recorded TV program}% +\label{sub:watching_recorded_tv_program} + +If you have setup for DVB capture as outlined in the section above, just start here to watch a previously recorded TV program. Use the following steps. + +\begin{itemize} + \item In the main window choose \texttt{File $\rightarrow$ Load} files and select the desired media file to watch. + \item Broadcast transport streams may consist of multiple programs that all run together on one channel (for example $9-1$, $9-2$, and $9-3$ are all on channel 9). Therefore when you play the + recorded program back all of these programs will play simultaneously and that is a jumble. In order to select just the one you want, press \texttt{Alt-1} in the main window to select \textit{Asset Program 1} (or \texttt{Alt-1...8} to select the desired asset program number) which removes all of the unrelated audio/video tracks except for the selected program. It also resets the session to match the media. + \item Move timeline to where you would like to start watching. + \item Be sure the Compositor window is up and you will see the pre-recorded program there. Use either the keyboard, a remote control that has been set up, or Android device for controls. To toggle between fullscreen or original size, press \texttt{f} in the Compositor window. +\end{itemize} + +To watch on a large TV screen or monitor which you have connected, you will have to setup for \textit{Dual Screen Mode} as explained in the next section. In addition, you can either use a Remote Control hardware device or special key setup for manipulating the playback. + +\subsection{Dual Screen Mode}% +\label{sub:dual_screen_mode} + +Dual screen mode is useful for displaying cinelerra video/project on a large screen digital Television set or for watching a previously recorded broadcast TV program via Cinelerra. The physical configuration results in one screen (an \textit{Xwindow}) on one monitor and the other screen on the other monitor or TV screen. Before the mode is usable for Cinelerra, X has to be configured in \textit{dual screen mode} --- that is, you must first split the configuration into 2 displays to operate Dual Screen Mode. On some systems, you may be able to get to the dual screen mode by using \textit{Xinerama} allowing for use of 2 physical displays to act as 1 virtual display. + +The main menu pulldown, \texttt{Settings $\rightarrow$ Preferences $\rightarrow$ Playback A} and \texttt{B} Tabs, must be properly configured in order to take advantage of the Dual Screen Mode capability. + +In the main menu Window pulldown there are \textit{Tile left} and \textit{Tile right} options for the 2 monitors. If you have only 1 monitor, you will see no change upon activating these options. Tiling is possible due to the existence of one long horizontal screen display buffer. Tile left takes Cinelerra and moves all of its windows to the $2^{nd}$ monitor/TV and Tile right puts it back to the $1^{st}$ monitor. The left and right monitors are the left part or right part of a Playback A/B Xwindow host referenced in the Video Config Playback A/B for separate X screens. Shortcuts for Tile left and Tile rights are the letters \texttt{a} and \texttt{b} on the keyboard once you have set \textit{Remote Control mode}. Below is a summary of the configuration letters: + +\begin{description} + \item[a] select \textit{playback a} and tile windows left (all on monitor or laptop) + \item[b] select \textit{playback b} and tile windows right (all on $2^{nd}$ monitor or TV) + \item[c] select \textit{playback c} and tile windows left, but composer right (TV mode) This option has the effect of taking the Compositor window and moving it to the $2^{nd}$ monitor/TV without the surrounding borders interfering with the video. +\end{description} + +Since Dual Screen Mode is most widely used for either a demonstration or watching TV, you will want to take advantage of Remote Control mode as described in a following section. In the camera shots below, note the square red box that shows up in the upper left hand corner of the Viewer window (arrow pointing to it but it looks more orange than red) which denotes that the Application/Menu key was used to get into Remote Control mode. + +Figure~\ref{fig:two-monitors01} shows 2 monitors (could just as well be a big-screen TV for the second monitor) with Tile left where all of the cinelerra windows are on the left most monitor. The big red arrow points to the little red square box indicating that Remote Control mode is in effect. + +\begin{figure}[htpb] + \centering + \includegraphics[width=0.8\linewidth]{images/two-monitors01.png} + \caption{} + \label{fig:two-monitors01} +\end{figure} + +Figure~\ref{fig:two-monitors02} shows 2 monitors with Tile right (b key) where all of the cinelerra windows are on the right monitor. The left monitor shows the Suse distro logo and a couple of xterm type windows. + +\begin{figure}[htpb] + \centering + \includegraphics[width=0.8\linewidth]{images/two-monitors02.png} + \caption{} + \label{fig:two-monitors02} +\end{figure} + +Figure~\ref{fig:two-monitors03} shows 2 monitors with Compositor window on the 2nd monitor which was obtained through use of the “c” keypress available when in Remote Control mode. + +\begin{figure}[htpb] + \centering + \includegraphics[width=0.8\linewidth]{images/two-monitors03.png} + \caption{} + \label{fig:two-monitors03} +\end{figure} + +Figure~\ref{fig:two-monitors04} shows 2 monitors with Compositor window on the 2nd monitor in FULLSCREEN mode so that no cinelerra borders are visible to distract from the picture. The big red arrow points to the little red square box indicating that Remote Control mode is in effect. + +\begin{figure}[htpb] + \centering + \includegraphics[width=0.8\linewidth]{images/two-monitors04.png} + \caption{} + \label{fig:two-monitors04} +\end{figure} + +\subsection{Remote Control for DVB}% +\label{sub:remote_control_dvb} + +\begin{wrapfigure}[18]{O}{0.3\linewidth} + \centering + \includegraphics[width=0.5\linewidth]{images/remote01.png} + \caption{Ati-x10 Remote} + \label{fig:remote01} +\end{wrapfigure} + +Cinelerra DVB recording/playback can now easily be done in “couch potato” mode using a remote control. This comes in handy when you want to playback on a big TV screen for multiple person viewing. You can use the Application/Menu key on the keyboard to toggle between standard Cinelerra usage or a Dispatcher methodology through use of a remote control, an Android programmed device such as a tablet, or keyboard. The Application/Menu key on most keyboards is between the Alt and Ctrl keys on the right hand side bottom and depicts a menu on it either with or without a pointer (see image below). An ati-x10 Remote Control device (figure~\ref{fig:remote01}) is currently working with Cinelerra and other remote controls may work but have never been tried. The red/orange box on the top left main screen of Cinelerra indicates Dispatcher Method access is activated which allows for keyboard grab which routes all key strokes until toggled off. Below are the currently defined operations. + +Remote Control Keys (Application/Menu key toggle for ati-x10 remote) + +\begin{tabular}{lc p{10cm}} + up arrow&=&forward 1 minute\\ + + down arrow&=&forward single frame\\ + + left arrow&=&forward slow playback\\ + + right arrow&=&forward normal playback\\ + + d&=&toggle channel scan menu\\ + + f&=&toggle full screen\\ + + a&=&select playback a and tile windows left (all on laptop)\\ + + b&=&select playback b and tile windows right (all on TV)\\ + + c&=&select playback c and tile windows left, but composer right (TV mode)\\ + + 0--9&=&select timeline by 1/10s from beginning to end\\ + + a&=&toggle audio mute\\ + + m&=&toggle audio meters\\ + + keypad /&=&display mpeg ts stream program data\\ + + keypad *&=&display mpeg ts stream channel schedule date\\ + + keypad +&=&change channel, next\\ + + keypad -&=&change channel, prev\\ + + keypad .&=&start channel change by numeric entry\\ + + keypad ..&=&clear channel entry\\ + + book key&=&toggles channel scan (always available)\\ + + hand key&=&terminates cinelerra (always available)\\ +\end{tabular} + +\noindent Plus usual Transport keys: + +\begin{tabular}{lcl} + e&=&??\\ + + f&=&toggle full screen\\ + + <<&=&fast reverse\\ + + >&=&toggles normal playback\\ + + >>&=&fast forward\\ + + red o&=&slow reverse\\ + + square&=&stop\\ + + 2 lines&=&fast reverse\\ +\end{tabular} + +The Application/Menu key \quad +\includegraphics[height=\baselineskip]{images/alt-ctrl.png} \quad +is used to get into remote control mode, even if there is no remote control hardware device in use, allowing for use of the same defined remote control keys to work on the keyboard. Once the Application/Menu key enables remote mode, the remote control keys don't allow the standard Cinelerra keys to work. + +\subsection{Android Remote Control for DVB}% +\label{sub:android_remote_control_dvb} + +Cinelerra GG Infinity has android remote interface code (figure~\ref{fig:remote02}). Any device, such as a tablet or a phone, can be used as long as it is running the Android operating system. Programming an Android Remote Control for DVB is a bit complicated at first, but becomes pretty simple after a bit. + +\begin{enumerate} + \item The Android Remote Control requires you to download and install the android \textit{CineRmt} app package (apk). To install it simply download it (any way you can) to your phone or tablet and click it to install, if it doesn't run automatically. + \item You should be able to open Settings You should be able to open Settings→Preferences→Interface tab. And see Android Remote Control in the Operation section. Enable it using the checkbox. The default port 23432 and default PIN cinelerra are OK. \texttt{Preferences $\rightarrow$ Interface} tab. And see Android Remote Control in the Operation section. Enable it using the checkbox. The default port $23432$ and default PIN cinelerra are OK. + \item After you install the new phone/tablet app in step 1, start it up from your apps menu. +\end{enumerate} + +\begin{figure}[htpb] + \centering + \includegraphics[width=0.9\linewidth]{images/remote02.png} + \caption{Interface tab shows Android Remote Control} + \label{fig:remote02} +\end{figure} + +Before you can use it, the Android device must have the ip address of your computer entered into the configuration menu. The PC you are running Cinelerra on and the Android device have to be on the same network. You can tell it is in communication by tapping the \texttt{Power} (menu) button. When the remote is operated with the \texttt{Power} (menu) button, there is a little orange box on the upper left corner of the display to indicate the remote state is active. If you do not see the little orange box when the menu key is tapped, the communication is broken and must be fixed before proceeding. Follow the directions in the paragraph below. + +BIG NOTICE: the firewalls in your computer and wifi router can stop this thing dead. Re-configuring a firewall is tricky and varies from distro to distro. If possible, during setup it is suggested that you disable the firewall temporarily. For those with advanced skills, use tcpdump or wireshark to look for udp messages from the IP address of the device. + +SECTION NOT COMPLETE – (manualandroid) + +Figure~\ref{fig:remote03} shows an Android Tablet that can be used as a Remote Control for Cinelerra Recording and Playback. + +\begin{figure}[htpb] + \centering + \includegraphics[width=0.6\linewidth]{images/remote03.png} + \caption{A Tablet with Android Remote Control} + \label{fig:remote03} +\end{figure} + +\subsection{Setup a Remote Control Device}% +\label{sub:setup_remote_control_device} + +SECTION NOT DONE !! This section explains how you can take your own brand of remote control and set it up to easily work the way you want with Cinelerra. + +\section{The commercial DB}% +\label{sec:commercial_db} + +While watching broadcast television, it is possible to use Cinelerra to automatically mute commercials being aired during a broadcast capture. Visual muting as well as sound muting is done! You can NOT use ffmpeg for the format when working with the \textit{commercial DB}. This database that was added is a \textit{novel architecture} shared memory database, a \textit{Traveling Data Base} (TDB). With TDB you have direct access to the shared database presence (instead of having to go to the server). + +Basically it works as follows, but there are a few differences in just how it goes about it: + +\begin{enumerate} + \item Identify a zone in a timeline as a commercial. + \item Characterize it concisely, in the audio and video timeline. + \item Store the characterization in a database. +\end{enumerate} + +Then, when capturing media or building a table of contents for an mpeg transport stream (broadcast capture DVB): + +\begin{enumerate} + \item Characterize each I-Frame (a few frames per sec). + \item Search the database in real-time to identify the image. + \item If a match is identified, automatically press the mute button. + \item Unmute if the pattern match fails, or the commercial ends. +\end{enumerate} + +It mostly works, but it takes more time to setup and maintain the database as the advertisements change frequently or vary by a small amount. It would take a small set of personnel to keep the database current and some finessing of the code. + +Currently, to activate the commercial database (db) methods you must do the following as root: + +\begin{lstlisting}[language=bash] +cd /bin +mkdir /cinelerra #yes, currently only in the / filesystem +./cin_db /cinelerra/media.db #to create a new empty commercial capture database +export BC_USE_COMMERCIALS=1 #in the command shell that is starting cinelerra +\end{lstlisting} + +This activates the gui tools and database access. As of yet, all of the requisite permission changes +necessary to run as non-root have not been worked out (initially just easier to run as root). + +When a commercial is \textit{cut}, the following occurs: + +\begin{enumerate} + \item transmits the capture timeline fragment to \texttt{/tmp} + \item scans the snip to characterize it statistically + \item creates a miniature b/w movie of the beginning and end + \item stores all of this into the \texttt{media.db} +\end{enumerate} + +There are 2 ways currently to identify a commercial: + +\begin{enumerate} + \item Load mpeg3 transport media, highlight select the commercial in the timeline, and press \texttt{cut commercial} on the toolbar. + \item Use the remote control interface to indicate the boundary in/out cut points in the realtime capture timeline, and operate a cut command. +\end{enumerate} + +The cut command creates a popup to let you know that it is processing the captured data. This can take several seconds depending on the size and media format. The results from the scan are stored in a new record in the \texttt{media.db}. + +The stats are somewhat disappointing. Image recognition is way past zero, it is not $100$ percent. Broadcast streams have tons of minor variances which hamper digitally perfect reproduction from instance to instance of commercial presentation. This puzzle remains to be solved. + +To review media stored in the \texttt{media.db}, and delete old expired commercial data records, press (\texttt{Shift-M}) from the main window. This will create a media-db window which shows the various captured samples stored there. + +Currently, only a customized \textit{ati-x10} (kernel mod required) radio remote control works. But this can quite readily be modified for other remote control models. + +\section{Transfer VHS/DVD Media into Cinelerra}% +\label{sec:transfer_vhs_dvd_into_cinelerra} + +If you want to transfer the data on a VHS tape or DVD disc into Cinelerra, you can do so by playing the media and recording while playing. This captures the media, which you are able to view as it plays, and writes it to a file so it can be played directly or edited. Because there is so much variation in hardware on both the Computer side and the Media Player side, these “how to” directions are only a guideline. You will most likely still have to do some experimentation and testing to see what works for you. + +The basic strategy consists of 3 operations: connect the relevant outputs to representative inputs, configure the capture card to match the video, and start the Record monitor. Each of these may have to be experimented with to get them correct for your hardware setup. + +\textit{Step 1}: Connect both audio and video from your player hardware to the sound board and/or the capture card of your computer. Sometimes the capture card handles both audio and video but oftentimes audio and video are hooked up separately. + +For example in a test case using the \textit{CX23418} capture card (an older/unusual single chip MPEG-2 encoder with integrated analog video/broadcast audio decoder), one end of an S-Video cable was plugged into the back of a DVD player and the other end plugged into this computer’s Capture card; the audio was plugged into the \textit{line in} on the computer sound card. + +\textit{Step 2}:Setup Cinelerra and it might be best the first time if you start with a default \texttt{.bcast5} file by using a +command line from a window of \\ +\texttt{CIN\_CONFIG=\$HOME/bcast6 {cinelerra\_path}/bin/cin} + +\begin{itemize} + \item Choose \texttt{Settings $\rightarrow$ Preferences} and then the \texttt{Recording} tab in the Preferences menu (figure~\ref{fig:recordingx}). + \item Choose a \textit{File Format} --- a common suggestion is \textit{ffmpeg} with a \textit{file type} of \texttt{mp4}. In some cases depending on your capture card, the File Format will be set to \textit{MPEG stream} capture. Some formats support MPEG stream capture technique, otherwise the data has to be decoded first and then encoded. + \item Check that the \textit{Audio In} section has the \texttt{Record Driver} set to \texttt{Alsa} with \texttt{Device} set to \texttt{default} as the Capture Source. If you are using something besides Alsa, change that selection accordingly. This may not always be default and you may have to change to something else based on your specific hardware. It has to match up what you see in our Control Panel on your computer. So for example, if your device is HDMI, than the \texttt{default} could be \texttt{HDMI}\dots instead. + \item In the \textit{Video In} section, change the\texttt{ Record Driver} to whatever makes sense for your capture card. The test case for the CX23418 would use Video4Linux2 MPEG. If unknown what your card uses, you should experiment with Video4Linux2 or Screencapture as good possibilities. + \item Also, \texttt{Device path} should be verified to be correct in case you have more than 1 device. +\end{itemize} + +\begin{figure}[htpb] + \centering + \includegraphics[width=0.9\linewidth]{images/recording03.png} + \caption{Example of the Preferences menu with the Recording tab highlighted} + \label{fig:recordingx} +\end{figure} + +\textit{Step 3}: Next use the “File” pulldown to choose “Record” and then the Recording menu will popup (figure~\ref{fig:vhs01}). + +\begin{itemize} + \item Click on the Antenna icon ($3^{rd}$ icon from the left on the left side of the right hand screen window). + \item In the popup \textit{Channels} menu, click on \texttt{Add} which brings up the \textit{Edit Channel} menu. + \item Use the down arrow in the \textit{Input} box to display the available options. In the test case, and very likely your case too, \texttt{S-Video 1} should be picked. + \item In the Recording menu, be sure to designate a complete path and filename in the \textit{Path:} textbox which will be used to record/write the playing media. Remember you must have the media on a file in order for Cinelerra to load it on the timeline for editing purposes. +\end{itemize} + +\begin{figure}[htpb] + \centering + \includegraphics[width=0.9\linewidth]{images/vhs01.png} + \caption{Example of the Recording, Video In, and Channels, along with the Add option, menus.} + \label{fig:vhs01} +\end{figure} + +\begin{itemize} + \item Then highlight \texttt{S-Video} in the \textit{Channels} Menu. Again, the choice in the Channels Menu might not be S-Video -- choices could vary widely. Start recording in your Recording menu by clicking on the second icon from the left, next to the \textit{Transport} label (it is usually a round red colored button). + \item Next press \texttt{play} on your media hardware device. If on the \textit{Video In} side window you see only noise, then S-Video or something else was an incorrect choice and you will have to perform some tests to find correct choices. +\end{itemize} + +There are many more parameters that you may want to vary in the Recording menu or for more details on various items, please refer to the section \textit{Record Web Media in real-time} \todo{reference to previous section}. The \textit{Transport} buttons are well defined there also. + +\textit{Step 4}: When the media has finished playing, use the \texttt{Stop} icon on the Recording menu – the fourth icon next to the \textit{Transport} label - to stop the recording (figure~\ref{fig:vhs02}). + +\begin{figure}[htpb] + \centering + \includegraphics[width=0.9\linewidth]{images/vhs02.png} + \caption{Recording menu and Video In screen while capturing media. Note the Transport stop option.} + \label{fig:vhs02} +\end{figure} + +Now you can \textit{Load} the file that you played and recorded via the \textit{Insertion strategy} choices on the bottom of the Recording menu and edit the file as usual. Note, that the audio and video may have started at slightly different times so you might have to initially line them up at the beginning using \texttt{nudge}. Generally once they are correctly aligned they will stay that way. Nudge is in the expanded patchbay. The nudge value is the amount the track is shifted left or right during playback. The track is not displayed shifted on the timeline, but it is shifted when it is played back. +