single character fix in Plugins for corrected punctuation of subsampling
[goodguy/cin-manual-latex.git] / parts / DVD.tex
index 60c88c1d20662226651fff161656d192bf21ba30..08c59c5abba3994732a020fa83259a92fe4c939e 100644 (file)
@@ -3,14 +3,17 @@
 \index{DVD}
 \index{BluRay}
 
-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 \CGG{} 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.  On 32-bit systems, like Debian, the creation of Blu-ray media is not supported and will hang your session. 
+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 \CGG{} 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.
+In \CGG{} DVD and Bluray creation is a convenience for users who want to edit and then just make basic media without having to work too hard, therefore
+all features will not be available.
 
 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 \CGG{} 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{<install\_directory\_path/bin/cin}).
+run the \CGG{} 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{<install\_directory\_path/bin/cin} or 
+ \texttt{<install\_directory\_path/<your\_version>.AppImage}).
 
 A warning here -- writing blu-ray BDs and  regular SDs can take a large amount of clock time.  Keep in mind that a blu-ray can contain 25 hours of viewing, so would take multiple hours to just write one.
 
@@ -33,6 +36,7 @@ A quick set of basic steps to create DVDs is immediately below and usually just
     \item If not logged in as root, you will get an error message in order to avoid doing a lot of work and then failing out because root is required for automount and to write on DVD hardware.
     \item Load your input source media via: \texttt{File $\rightarrow$ Load files}.
     \item Choose PAL or NTSC for SD/dvd or 1080P/24 for blu-ray in \texttt{Settings $\rightarrow$ Format}.
+    \item If DVD "Interlace Mode" of Bottom Field First is wanted, you MUST set that in \texttt{Settings $\rightarrow$ Format}. If you do, then also remember to change it when you no longer want BFF.
     \item For blu-ray, choose BD Render or for PAL/NTSC, choose DVD \textit{Render} in  \textit{File} menu.
     \item Designate a \textit{work path} with sufficient disk space and then Chk-OK.
     \item When the Batch Render window comes up, click on \textit{Start} and the batch jobs will run.
@@ -58,7 +62,9 @@ Any problems encountered will require that you read more information in this sec
 
 The general design of the DVD/blu-ray generation operations is to first render media using batch rendering and then terminate \CGG{} 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{<target>/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{<target>/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}. 
+For blu-ray, the filesystem generation is slightly harder.  First, it creates an empty filesystem image \texttt{<target>/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.
+The actual calculation for the mkudffs size is yourfile.m2ts size-in-bytes/2048 + 4096.
+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:
 
@@ -125,14 +131,23 @@ Explanation of the choice boxes as seen in figure~\ref{fig:bluray_dvd} for both
 
 \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.
+In the case of DVD only, for interlaced media when you do not check the Deinterlace option, it will always be done as Top Field First.  
+To get DVD media to be Bottom Field First, you MUST set the "Interlace Mode" in \texttt{Settings $\rightarrow$ Format}.
     \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[Profile] for bluray only, use the default bluray.m2ts or choose bluray\_lpcm.m2ts for linear pulse code modulation for digitally encoding uncompressed audio information.
+    \item[use tsmuxer] for bluray only, to use tsMuxer as a transport stream muxer for remuxing/muxing elementary streams, check this box.  Usage of tsmuxer requires that your computer have the tsmuxer software installed along with any of its prerequisites. The default is do not use tsmuxer.
     \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 \CGG{} and mark the chapter labels yourself by hand.  In that case, you should checkbox \textit{Chapters at Labels} so that the automatic 10-minute labels are not created.  This checkbox is not currently available for blu-ray.
+    \item[Chapters at Labels] for DVDs without this checked, chapter 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 \CGG{} and mark the chapter labels yourself by hand.  In that case, you should check the box \textit{Chapters at Labels} so that the automatic 5-minute labels are not created.  This checkbox is not currently available for blu-ray, but you can easily create
+chapters on blu-ray by adding '-c timeinterval in ticks' as the first argument to bdwrite in the bd.sh job
+generated by “BD Render” and then executing that job manually.  On 1 test computer 100 ticks equalled 20 seconds.  When "use tsmuxer" option is included, there is by default a chapter every 5 minutes.  This
+can be customized by modifying the bd.meta file associated with your current
+job, changing the '--auto-chapters=5' to your choice in minutes instead of 5, and then rerunning the 
+pertinent lines seen in your window.
 \end{description}
 
 \begin{figure}[htpb]
@@ -482,13 +497,56 @@ With this option enabled, improved chroma results will be obtained from your DV
 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 \CGG{} and avoid Chroma errors for interlaced 4:2:0 video, check the box as follows:
 
-\texttt{Settings $\rightarrow$ Performance $\rightarrow$ YUV420P DVD Interlace Mode}
+\texttt{Settings $\rightarrow$ Preferences, Interface tab, Operation section, Use yuv420p dvd interlace format}
 
 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{DVD with LPCM or MP2 audio}%
+\label{sec:dvd_lpcm_audio}
+
+By default, the audio when creating a DVD is always \textit{AC3}. However you can switch to \textit{PCM} (Pulse Code Modulator) or MP2 with just a few additional steps as outlined below.
+Note that Audio must be $48Khz$ or $96Khz$, nothing else is supported, even by ffmpeg's dvd pcm encoder.
+
+\begin{enumerate}
+       \item Start \CGG{} from a terminal window so you will be able to see what is happening. Only the final step when you actually want to write to a
+DVD media writer, requires privileges of either root or the system has
+granted the user this privilege.
+       \item Make sure you have your video with audio loaded and edited to your satisfaction and you are positioned at the start of the video.
+       \item Use the \texttt{File} pulldown and select the \textit{DVD Render} option.
+       \item In the\textit{Create DVD} window, accept the defaults or select different values and then click \texttt{OK}.  Do not check "Use FFMPEG" as that may not work.
+       \item When the \textit{Batch Render} window pops up, in the big box towards the bottom will be 2 lines with the first line for \textit{Video} already highlighted.  Instead, click on the second line, which is for \textit{Audio}, so that it is highlighted.
+       \item On the top left, you will see the \textit{File Format} set as AC3.  Use the down arrow next to    the box and change it to \textit{Raw PCM} or \textit{MPEG Audio} by clicking on it.
+       \item When you switch to Raw PCM or MPEG Audio, you see the extension in the \texttt{Output path} above change to pcm or mp3
+       instead of ac3.  Now just reset the extension from pcm to lpcm or mp2 as that is required. In most cases if you click on the \texttt{Audio} wrench to see the settings, you will find that the standard settings of 16 bit Linear / Signed / Hi Lo work for Raw PCM.  For mp2, you will have to click
+on the Audio wrench and change the default Layer III to Layer II.
+       \item Now click on the \texttt{Start} box in the bottom left hand corner and \CGG{}     will process what it can of the job and put you back at your terminal startup window.
+       \item You will see a few lines of output, some of which are shown below, to include the ERROR:
+       \begin{lstlisting}[style=sh]
+               running /dev/shm//dvd_20240116-182336/dvd.sh
+               INFO: [mplex] mplex version 2.1.0 (2.2.7 $Date: 2012/11/17 01:55:16 $)
+               **ERROR: [mplex] Unable to open file
+               /dev/shm/dvd_20240116-182336/dvd.ac3 for reading.
+       \end{lstlisting}
+       \item Change directory to the location as shown on the terminal window of \texttt{dvd.sh}.
+       \item Using an editor, modify the line in dvd.sh to change \texttt{dvd.ac3} to \texttt{dvd.lpcm} or to \texttt{dvd.mp2} for mp2.  In addition ONLY for Raw PCM you have to change the mplex parameter to include:
+       \begin{lstlisting}[style=sh]
+               -L  48000:2:16
+       \end{lstlisting}
+       The full line will look like this:
+       \begin{lstlisting}[style=sh]
+               mplex -f 8 -L 48000:2:16 -o $dir/dvd.mpg $dir/dvd.m2v $dir/dvd.lpcm
+       \end{lstlisting}
+       \item Now the script is ready to run in the same manner it would have had it been ac3. That is just run via:
+       \begin{lstlisting}[style=sh]
+               ./dvd.sh
+       \end{lstlisting}
+       \item Check to make sure there are no errors in the output shown on the window and proceed as usual.
+\end{enumerate}
+
+
 \section{MPEG utility programs}%
 \label{sec:mpeg_utility_programs}
 
@@ -535,21 +593,59 @@ zmpeg3cc2txt -o - /dvb_data/channel5.ts
 
 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}
-\index{BluRay!HDV without re-encoding}
+\section{Creating Blu-ray Without Re-encoding}%
+\label{sec:bluray_without_reencoding}
+\index{BluRay!without re-encoding}
+\index{BluRay!camcorders}
+\index{BluRay!AVCHD}
+
+If you have video that is already in Blu-ray format AND you do not want to use \CGG{} to do
+any editing, you can create blu-ray video media using Cinelerra's \textit{bdwrite} program.  This
+could be the case if you are working with media from a modern Digital Camcorder.  Camcorders
+usually record in a legacy tape-based format or the current file-based format.  The most common
+digital camcorder formats and whether or not they need to be re-encoded are:
 
-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. 
+\begin{itemize}
+        \item DV (1995) to SD-blu-ray video - process in \CGG{} using the File pulldown of
+BD Render as previously described or use programs documented in their manuals to re-encode
+video to mpeg2 and then re-encode DV LPCM audio to Blu-ray LPCM.
+        \item HDV (2004) to blu-ray video - process in \CGG{} using the File pulldown of
+BD Render as previously described or use programs documented in their manuals to
+ copy mpeg2
+video and then re-encode MP2 audio to Blu-ray LPCM or AC3.
+        \item AVCHD (2006-current) to blu-ray video; these are the types of videos that do
+not have to be re-encoded if you do not want to edit anything.
+\end{itemize}
+For an explanation of the differences between HDV vs AVCHD see:
+  {\small \url{http://www.differencebetween.net/technology/difference-between-hdv-and-avchd}}
 
-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 \CGG{}.  It has been tested on 10 different MTS files.
+Besides digital camcorder file-based format of AVCHD, there are video files in MTS format
+that are also candidates for burning to blu-ray video media without re-encoding.
+An MTS file is a video file saved in the high-definition (HD) MPEG Transport Stream video format/H264, commonly called \textit{AVCHD}.  It contains HD video compatible with Blu-ray video 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 video disc, if you have these HD MPEG-2 media types that are in blu-ray video format, you can save the original quality of your work, rather than rendering it to another format.
+Note that for older media or media which used MP1 or MP2 audio codecs which will not work on
+blu-ray video discs, it may be necessary to first transcode the audio while leaving video intact.
+An example of the transcode line to use if using ffmpeg version 5.1 or higher is shown next.
+If using a lower ffmpeg version substitute ac3 for pcm\_bluray:
+
+\begin{lstlisting}[numbers=none]
+ffmpeg -i hdv -c:v copy -c:a pcm_bluray -mpegts_m2ts_mode 1 new_hdv.mts
+\end{lstlisting}
+
+Follow the next 2 sets of steps to create the  blu-ray video disc.
 \begin{lstlisting}[style=sh]
-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.
+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 -b 2048 /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.
+\end{lstlisting}
+In order to create the udfs file, you will need access to Cinelerra's \textit{bdwrite} program.
+If you do not do your own build and compile, but use the AppImage instead, you will have to first
+extract \textit{bdwrite} from the AppImage as described in the NOTE at \ref{sub:managing_appimage}.
+\begin{lstlisting}[style=sh]
 /<cinelerra_installed_path>/bin/bdwrite /mntX /tmp/yourHDVfile.MTS   # Substitute \CGG{} path.
-umount /mntX                           # You must unmount the udfs filesystem
+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}
@@ -571,7 +667,8 @@ Also, be sure to do a \texttt{mkdir bluray} in your \texttt{/home/name} director
 \label{sec:bluray_multiple_cinelerra_output}
 \index{BluRay!multiple output}
 
-Writing prepared multiple \CGG{} 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.
+Writing prepared multiple \CGG{} output files, \texttt{bd.m2ts}, to a single bluray video 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 blu-ray video media. If using AppImage, you will have to first extract the \textit{bdwrite} program as explained in the NOTE at \ref{sub:managing_appimage}.  You can
+use any other software program that works instead.
 
 Usage of the final preparation taken from the bdwrite program comments: