+
+\section{Create a frame for a PiP}%
+\label{sec:create_frame_pip}
+
+In \CGG{} it is quick and easy to create \textit{Picture-in-Picture} (PiP) using the Camera and Projector tools. You can read about how to use these at \nameref{sub:camera_and_projector}.
+
+PiPs created with Camera and Projector, however, do not have a frame. You can add it with the \textit{Sketcher} plugin that allows for drawing on the canvas of the Compositor window. Such a frame remains fixed in the position where it was created and can only be moved manually, with a movement that must be in accordance with the movement of the PiP. Unfortunately, this is very complicated and imprecise work.
+A convenient workaround is to use the \textit{Sketcher} plugin together with the \textit{Crop\&Position} plugin. Here is a description of how to do this.
+
+Consider an example of a main video (\texttt{bbb\_sunflower\_1080p\_30fps\_ normal.mp4}) and a still image example (\texttt{Rodents.png}). You want to insert a crop of the image surrounded by a colored frame inside the video. Later you can move the PiP with its frame by using keyframes.
+
+\begin{enumerate}
+ \item First, create a project with 3 video tracks. From top to bottom name them: \texttt{V3\_Frame 4Picture}, \texttt{V2\_Picture}, \texttt{V1\_Video}.
+ \item In V1\_Video put the video file. In V2\_Picture put the image (extending it to the length of the video by simply dragging the right edge) - or you can put another video instead of a still image. The V3\_Frame4Picture track is left empty.
+ \item In V2\_Picture, if needed put the \textit{Scale} plugin, and then 2 separate \textit{Crop\&Position} plugins. The \textit{Scale} plugin may be needed to scale the image - maybe to use it with the Camera tool, however it is not needed for the creation of the frame and PiP. Depending on its use, you can put it in the first or second position in the plugin stack. The first \textit{Crop\&Position} plugin (the topmost one, which is processed first in \textit{Temporary} and whose output becomes the input to the next plugin) will be used only to make the desired crop for our image (Crop Only). The second \textit{Crop\&Position} plugin will be used to place the PiP in the desired position (Position Only).
+ \item In V3\_Frame4Picture, select the length of the video track and apply the \textit{Sketcher} plugin. Either highlight the region in which to apply the plugin or assign \textit{In/Out Points}, because you can not add plugins to an empty track. Now add the \textit{Shared Effects} of the \textit{Crop\&Position} plugin, taking care to choose the second plugin (Position Only) which is further down the stack (for shared effects see: \nameref{sec:shared_effect_tracks}).
+\end{enumerate}
+
+This is what the timeline should look like:
+
+\begin{lstlisting}[numbers=none]
+ - V3_Frame4Picture
+ -> Sketcher
+ -> Shared V2_Picture:Crop&Position (Position ONLY)
+ - V2_Picture
+ -> Rodents.png
+ -> Crop&Position (Crop ONLY)
+ -> Scale
+ -> Crop&Position (Position ONLY)
+ - V1_Video
+ -> bbb_sunflower_1080p_30fps_normal.mp4
+\end{lstlisting}
+
+
+as you can see in figure~\ref{fig:Frame_on_PiP}.
+
+\begin{figure}[htpb]
+ \centering
+ \includegraphics[width=1.0\linewidth]{Frame_on_PiP.png}
+ \caption{Setting effects}
+ \label{fig:Frame_on_PiP}
+\end{figure}
+
+All that remains is to create the frame on the image that has already been cropped to the desired size. Drawing the frame with the \textit{Sketcher} plugin is not difficult but requires precision. You can draw the 4 corner points imprecisely (\texttt{Shift + LMB}) and then arrange the created points by dragging them to exactly the right coordinates (\texttt{Ctrl+LMB}), or you can impose the coordinates on the 4 corner points by entering the exact numbers in the \texttt{X} and \texttt{Y Input} windows. You can also adjust the thickness of the frame and the color (see \nameref{sub:Sketcher}).
+
+If you want to move the PiP to another position you have to go back to \textit{Crop\&Position} (Position Only) and change the coordinates. Now you can see that the frame also moves along with the image thanks to the Shared effect present in the V3\_Frame4Picture track, which returns the same coordinates to the \textit{Sketcher} plugin.
+
+Finally, you can animate the position of the PiP as well as the thickness and color of the frame throughout the video using the keyframes (see \nameref{cha:keyframes}).
+