\chapter{Overview on Formats and Codecs}%
\label{cha:overview_formats}

Here is an overview of the formats and codecs that are used in \CGG{}, by ffmpeg and the internal engine. Roughly speaking these are divided into uncompressed codecs (or codecs with Intraframe compression, which can be lossy or lossless) and compressed codecs of Interframe type (LongGOP, almost always with lossy compression). The uncompressed codecs are suitable for editing because a cut or other operation on the timeline corresponds to the exact frame on which you are operating. The compressed types use Groups of Pictures (GOP) and a cut or other operation is accurate (and requires no further calculation) only if it coincides with the beginning of the GOP, and not with an internal frame. In addition, heavy compression requires the system to do more encoding/decoding work on the timeline. High quality codecs have high bit rates and bit depths but this also affects the performance of the system, not to mention the increased disk space usage.

\section{FFmpeg Video Vormats}%
\label{sec:FFmpeg_video_formats}

FFmpeg supports hundreds of codecs and formats. Some implement both audio and video, others audio only or video only. We are only describing here a selection of the most well-known and most frequently used ones.

\subsection{High Quality Formats}
\label{sub:high_quality_formats}

High quality formats are also called Mezzanine codecs, Digital Intermediate, Preservation codecs or Editing codecs. These  have intraframe lossless compression or no compression and are suitable for editing, post-processing, mastering and archiving. They are also used for the interchange of files between different programs. They take up a lot of disk space and require a powerful system.
\begin{itemize}
 \item MKV  Open, highly configurable and extensively documented. Can have seeking problems. Belongs to the Matroska family.
 \newline    \textit{Presets: ffv1, ffvyuv}
 \item MXF  Created by Avid. It is probably the best and most advanced container for editing.
 \newline    \textit{Presets: DNxHR, ffv1, AVC\_Intra\_100}
 \item MOV  Created by Apple. It is a suitable format for editing because it organizes the files within the container into hierarchically structured "atoms" described in a header. This brings simplicity and compatibility with various software and does not require continuous encoding/decoding in the timeline.
 \newline    \textit{Presets: DNxHR, ffv1, CineformHD, huffyuv}
 \item PRO  Different extension, but it is still mov.
 \newline    \textit{Presets: ProRes}
 \item QT  Different extension, but it is always mov.
 \newline    \textit{Presets: DNxHD, magicyuv, raw, utvideo}
 \item MP4  mostly used for General Purpose.
 \newline    \textit{Presets: AVC\_Intra\_100}
 \item RGB  Raw format.
 \newline    \textit{Presets: raw}
 \item YUV  Raw format.
 \newline    \textit{Presets: raw}
 \item AVI  Old and limited format (no multi streams, no subtitle, limited metadata) but with high compatibility.
 \newline    \textit{Presets: ffv1}
\end{itemize}

\subsection{General Purpose Formats}
\label{sub:general_purpose_formats}

These are also called Delivery codecs. They are the most used and widespread being suitable for streaming, video sharing, watching TV, smartphones, plus more. Because of lossy compression type Interframe, they produce smaller files with variable quality. They are not suitable for editing, compositing and color correction. Further rendering of these formats worsens the quality exponentially. The most used codecs have hardware support (vaapi, vdpau, nvenc) that make them more efficient.
\begin{itemize}
 \item MOV Created by Apple. It is a suitable format for editing because it organizes the files within the container into hierarchically structured "atoms" described in a header. This brings simplicity and compatibility with various software and does not require continuous encoding/decoding in the timeline.
 \newline    \textit{Presets: mov}
 \item QT Different extension, but it is always mov.
 \newline    \textit{Presets: mjpeg, DV, Div, CinePak}
 \item MP4 The most popular. Many other formats belong to this family (MPEG);
 \newline    h264 is actually x264, open, highly configurable and documented; h265/HEVC is actually x265, open, highly configurable and documented.
 \newline    \textit{Presets: h265, h265, mjpeg, mpeg2, obs2youtube}
 \item WEBM Open; similar to mp4 but not as widespread (it is used by YouTube). In CinGG there are specific Presets with .youtube extension, but they are still webm.
 \newline    \textit{Presets: VP8, VP9, AV1}
 \item MKV Open, highly configurable and widely documented. It might have seeking problems. It belongs to the Matroska family.
 \newline    \textit{Presets: Theora, VP8, VP9}
 \item AVI Old and limited format (no multistreams, no subtitles, limited metadata) but with high compatibility.
 \newline    \textit{Presets: asv, DV, mjpeg, xvid}
 \item MPG Parent of the MPEG family, to which MP4 also belongs. Mpeg is used by CinGG as default for proxies and mpeg2 is the standard for Video DVDs.
 \newline    \textit{Presets: mpeg, mpeg2}
\end{itemize}

\subsection{Image Sequences Formats}
\label{sub:image_sequences_formats}

The image sequences can be uncompressed, with lossy or lossless compression but always Intraframe. They are suitable for post-processing, compositing (VFX), and color correction.
\begin{itemize}
 \item DPX Film standard; uncompressed; high quality.
 \item PNG Uncompressed or lossless compression. Supports alpha channel.
 \item WEBP, TIFF, GIF, JPEG, etc. Variable compression, size and quality.
\end{itemize}

\subsection{Old Pro Formats}
\label{sub:old_pro_formats}

\begin{itemize}
 \item AVI old and limited format but with high compatibility.
 \newline    \textit{Presets: DV\_pal, DV\_ntsc, mjpeg}
 \item QT belongs to the Apple mov family.
 \newline    \textit{Presets: DV, mjpeg}
 \item DVD format for DVD (mpeg2)
 \newline    \textit{Presets: dvd}
 \item M2TS format for Bluray (mpeg4).
 \newline    \textit{Presets: AVC422, Lossless, Bluray, hevc}
 \item MP4 Belongs to the MPEG family. Motionjpeg has jpeg compression, then Intra, so it maintains good quality and fluidity in editing. It is now an old and limited codec.
 \newline    \textit{Presets: mjpeg}
\end{itemize}

\section{FFmpeg Audio Formats}%
\label{sec:FFmpeg_audio_formats}

Audio formats and codecs take much less resources and space than video ones, so they are often used without compression for maximum quality. However these are compressed formats and codecs widely used in streaming and sharing.
\begin{itemize}
 \item FLAC Open; used for storing music. It has lossless compression.
 \newline    preset: flac
 \item PCM Raw format that encodes the signal with modified pulse modulation (pcm). FFmpeg does not support pcm audio if you use mp4 as a container.
 \newline    \textit{Presets: s8, s16, s24, s32}
 \item WAV Raw format created by Microsoft. 32-bit addressing leading to the 4 GB recording limit. It is a widely used standard.
 \newline    \textit{Presets: s24le, s32le}
 \item W64 Wave format created by Sony to override the 4GB recording limit. Poorly supported.
 \newline    \textit{Presets: s16le, s24le, s32le}
 \item MKA Open, highly configurable and documented. It belongs to the Matroska family. Uncompressed pcm type.
 \newline    \textit{Presets: s16le, s24le, s32le}
 \item FLAC Open; used for storing music. It has lossless compression.
\end{itemize}

\subsection{General Purpose Formats}
\label{sub:general_purpose_formats}

\begin{itemize}
 \item MP3 Belongs to the MPEG family. The most widely used in streaming and sharing.
 \newline   preset: mp3
 \item OGG Open, highly configurable and documented. It belongs to the Matroska family. Flac has lossless compression; opus is compressed but modern and of good quality, superior to mp3. Vorbis is compressed and dated, but lightweight and compatible.
 \newline    \textit{Presets: flac, opus, vorbis}
 \item PRO Created by Apple; compressed audio codec, competing with mp3.
 \newline    \textit{Presets: acc256k}
\end{itemize}

\section{\CGG{} Internal Engine}%
\label{sec:internal_engine}

FFmpeg is the default engine, but you can also use its internal engine, which is limited in supported formats but efficient and of high quality.

\subsection{Video general purpose}
\label{sub:video_general_purpose}

\begin{itemize}
 \item RAW DV supports the DV standard.
 \newline    \textit{Presets: dv}
 \item MPEG Video highly configurable. Extension .m2v.
 \newline    \textit{Presets: mpeg1, mpeg2}
 \item OGG (Theora/Vorbis) Open, easily configurable. Theora for video, Vorbis for audio.
 \newline    \textit{Presets: theora, vorbis}
\end{itemize}

\subsection{Image Sequences general purpose}
\label{sub:image_sequences_general_purpose}

There are quite a few formats available. 
\begin{itemize}
 \item OpenEXR (Open Standard) is a competing film standard to DPX. 
 \item Ppm is RGB Raw.
 \item Tga is RGB(A) compressed or uncompressed.
 \item Tiff is RGB(A) or RGB(A)-Float with various compression types.
 \newline    \textit{Presets: jpg, gif, EXR, png, ppm, tga, tiff}
\end{itemize}

\subsection{Audio general purpose}
\label{sub:audio_general_purpose}

\begin{itemize}
 \item AC3 widely used multichannel standard (Dolby Digital). Format with lossy compression.
 \newline    \textit{Presets: ac3}
 \item Apple/SGI AIFF Created by Apple; is an uncompressed format (pcm type) or with 32/64-bit floating point compression.
 \newline    \textit{Presets: aif}
 \item Sun/Next AU created by Sun and used in Unix environment, now in disuse. It can be of pcm type or with lossy compression.
 \newline    \textit{Presets: au}
 \item Flac Open, lossless compression, very good quality.
 \newline    preset: flac
 \item Microsoft WAV created by Microsoft. It can have 16-24-32-bit linear or float compression.
 \newline    \textit{Presets: wav}
 \item MPEG Audio Very widespread standard. Extension .mp3.
 \newline    \textit{Presets: mp3}
\end{itemize}
