6fb57e3e9f9b3936a99f9c31bc2409e75211cba9
[goodguy/cin-manual-latex.git] / parts / Recording.tex
1 \chapter{Capturing and Recording Media}%
2 \label{cha:capturing_recording_media}
3
4 This section covers the areas of capturing media from the web or television by the use of recording.
5
6 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.
7
8 \vspace{2ex}
9 \begin{tabular}{lll}
10     Path: & output media file path & \\
11     
12     Start time: & weekday/time of day & to begin capture\\
13     
14     Duration: & hrs:mins:secs & until end of capture\\
15     
16     Source: & channel/device input & selection of input subsource\\
17     
18     \multirow{2}*{Mode:} & timed & use start time/duration \\
19     
20     & untimed & use transport controls\\       
21 \end{tabular}
22
23 \vspace{2ex}
24 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 \hyperref[sec:recording]{Settings/Preferences} 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 $\rightarrow$ qt $\rightarrow$ mp4.qt} with bitrates like $audio/256000$ \& $video/6000000$.
25
26 \section{Record Web Media in real-time}%
27 \label{sec:record_web_media_rt}
28
29 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.
30
31 \begin{enumerate}
32     \item Start \CGG{} 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: \textit{Source $\#1$}. Locate the source which monitors your normal audio output.  For example: \textit{front stereo}.        
33     \item Choose a File Format and File Type (for example: FFMPEG \& qt).
34     \begin{itemize}
35         \item Check \textit{Record audio tracks}.
36         Click \texttt{Audio wrench} tool:
37         \begin{itemize}
38             \item Select \textit{mp4}, for example.
39             \item Set \textit{Bitrate} ($256000$ is a reasonable number).
40         \end{itemize}
41         \item Check \textit{Record video tracks}.
42         \item Click \textit{Video wrench} tool:
43         \begin{itemize}
44             \item Select \textit{mp4} video, for example.
45             \item Set \texttt{Bitrate} $1000000 - 4000000$ (bigger=better, but more cpu)
46         \end{itemize}
47         \item Select \texttt{Audio In $\rightarrow$ Record Driver:  ALSA} (or whatever you have instead)
48         \begin{itemize}
49             \item Set the \textit{Bits}: \textit{16 Bit Linear} (probably, because reasonable and fast)
50             \item Select \textit{Device}: the source from above \textit{pactl} list search, for example Source $\#1$
51             \item Samples read from device: aprox dev buffer size ($2k-16k$ probably)
52             \item Samples to write to disk: $131072$ (a good size)
53             \item Sample rate for recording: $44100$ (will automatically change)
54             \item Channels to record $2$ (probably)
55             \item Uncheck Map $5.1 \rightarrow 2$
56             \item Gain $1.0$
57         \end{itemize}
58         \item Select \texttt{Video In $\rightarrow$ Record Driver}:  \texttt{Screencapture}
59         \begin{itemize}
60             \item Set the \textit{Display}: leave blank (probably) or use "$:0.0$" (default screen/display)
61             \item Frames to record to disk at a time: $30$ (a good number)
62             \item Frames to buffer in device: $(2-6)$ (probably)
63             \item Positioning: \texttt{Software Timing} (important)
64             \item Uncheck: \texttt{Sync drives automatically}
65             \item Size of captured frame: $720x480$ (this is your choice, actual capture size; $600x320$ youtube)
66             \begin{itemize}
67                 \item This defines a \textit{screen capture} rectangular area on the display.
68                 \item Try to make it the size you need to cover the screen playback area.
69             \end{itemize}       
70         \end{itemize}
71         \item Frame rate for recording $23.97 fps$ (a good choice, not all choices work)
72         \item OK
73     \end{itemize}
74     
75 \end{enumerate}
76
77 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.
78
79 Screenshot to illustrate some appropriate settings which are described above/below the image (figure~\ref{fig:recording01}).
80
81 \begin{figure}[htpb]
82     \centering
83     \includegraphics[width=0.8\linewidth]{images/recording01.png}
84     \caption{Recording window with tipical settings}
85     \label{fig:recording01}
86 \end{figure}
87
88 \begin{enumerate}[start=3]    
89     \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 "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.
90     \item From the \textit{Recording window} select a Path file name for the recording.
91     \item Select mode untimed.
92     \item Make sure the \textit{monitor audio} is unchecked else audio becomes looped and is very loud.
93     \item Press Transport \textit{start recording} (red circle button).
94     \item Operate the playback of the media source, i.e. start playing the web video.
95     \item When the media ends, stop on the playback application.
96     \item Press Transport \textit{stop recording} button (white square button).
97     \item Before clicking chk-Ok, be sure to set the \textit{Insertion Strategy}.
98     \item Press chk-Ok to review the capture, or "X" to cancel/dismiss application.    
99 \end{enumerate}
100
101 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.
102 \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.
103 \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 \textit{Frames behind}, frames will be dropped.
104
105 The algorithm for determining how many frames to drop is as follows:
106
107 \begin{itemize}
108     \item If the number of frames behind $> 3$, only $3$ frames will be dropped before it will then do $1$ frame;
109     \item if the number of frames behind is $2$, only drop $1$ frame;
110     \item if only $1$ frame behind, no frames will be dropped.
111 \end{itemize}
112 \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.
113 \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.
114 \paragraph{Transport controls} these control buttons mimic the functions of tape recorders from the old days.
115
116 \begin{itemize}
117     \item \textit{Reverse button/left arrow} --remnant from the past; does the same as the Start button really.
118     \item \textit{Red round button} --this is the Start button to start recording.
119     \item \textit{White square} --this is the Stop button to stop recording.
120     \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
121 \end{itemize}
122 \paragraph{Cron} The batch recording watcher, cron, is either \textit{Idle} or \textit{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.
123 \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.
124 You can select synchronization time source \textit{Positioning} in:
125
126 \texttt{Settings $\rightarrow$ Preferences} under the \textit{Recording} tab.
127
128 \noindent Possible choices for time base are:
129
130 \begin{itemize}
131     \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.
132     \item \textit{Device Position} --this is the device hardware position of where you are.  It is usually only on the audio side.
133     \item \textit{Sample Position} --Sample $\#$ or frame $\#$ divided by frame rate tells you where you are.
134     \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.    
135 \end{itemize}
136
137 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}.
138
139 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.
140
141 Examples of media which usually has a particular type of positioning is:
142
143 \begin{enumerate}
144     \item mpeg has timestamps therefore Presentation Timestamps is a good recording choice;
145     \item raw media streams/screen capture have no timestamps, so tell it time via Software;
146     \item a web cam may supply data at variable rates, so again you would use \textit{Software timing};
147     \item an example of Device Position is audio (timestamps can come off the device);
148     \item if Software Positioning working for you, try Sample Position for really bad audio.
149 \end{enumerate}
150
151 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.
152 \paragraph{Label} create a label.  During capture, put a time marker at the designated spot.  When the recording 
153 gets pulled in later for review, you will see a green arrow marking the spot that was clicked.
154 \paragraph{ClrLbls} clears all of the previously set labels.
155 \paragraph{Check for ads} check for commercials.  In real time, labels are added when a commercial that matches
156 a previous ad is already in the database (the TDB, Traveling Data Base).
157
158 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.
159
160 \begin{figure}[htpb]
161     \centering
162     \includegraphics[width=0.8\linewidth]{images/recording02.png}
163     \caption{new feature v4l2 mpeg}
164     \label{fig:recording02}
165 \end{figure}
166
167 \section{Digital Video Broadcasting (DVB)}%
168 \label{sec:digital_video_broadcasting}
169
170 You can do real-time capture of a full transport stream of Broadcast TV.  Record television programs using \CGG{} by setting up ahead of time to start recording later at the specified time.  Then you can use \CGG{} 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.
171
172 \begin{enumerate}
173     \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.
174     \item Your DVB adapter on your PC should connect to a broadcast antenna input.
175     \item For now, you may have to run as the \textit{root} user.
176 \end{enumerate}
177
178 \subsection{Overview}%
179 \label{sub:overview}
180
181 There is a lot of detailed explanation below to be thorough, but an overview is presented here.
182
183 \begin{enumerate}
184     \item Set up Record Preferences.
185     \item Scan the Channels.
186     \item Watch TV by selecting the desired channel.
187     \item Or set up a batch job to record a program and watch later via Ctrl-Alt-s in the main window.
188     \item Or record a currently running program by using the buttons in the Record window.
189     \item Load a previously recorded program.
190 \end{enumerate}
191
192 \subsection{Initial Setup for DVB Capture}%
193 \label{sub:initial_setup_dvb_capture}
194
195 Listed below are the steps for the initial DVB setup.  Setup will be preserved until you make changes.
196
197 \begin{enumerate}
198     \item Start \CGG{}, and click \textit{Settings $\rightarrow$ Preferences $\rightarrow$ Recording}
199     \item Select \textit{File Format} checkbox: \texttt{Realtime TOC} (Table of Contents)
200     \begin{itemize}
201         \item It is not necessary to set File Format at this point as it will automatically be set later.
202         \item Check \textit{Record Audio Tracks}.
203         \item Check \textit{Record Video Tracks}.
204     \end{itemize}
205     \item Select \texttt{Audio In $\rightarrow$ Record Driver: DVB}
206     \begin{itemize}
207         \item Set the \texttt{adapter path = /dev/dvb/adapter0} (probably)
208         \item Set the \textit{adapter dev = 0} (probably)
209         \item Set the \textit{Bits: 16 Bit Linear} (probably)
210         \item Check: \textit{Follow audio config}
211         \item \textit{Samples read from device}: $2048$ or approximate dev buffer size ($2k-16k$ probably)
212         \item \textit{Samples to write to disk}: $131072$ (a good size)
213         \item \textit{Channels to record}: 2
214         \item Uncheck \textit{Map} $5.1 \rightarrow 2$
215         \item \textit{Gain}: $1.0$
216         \item Uncheck: \textit{Record in real-time priority}
217     \end{itemize}
218     \item Select in \textit{Video In}: \qquad \textit{Record Driver: DVB} (note: File Format above changes to \textit{MPEG Stream})
219     \begin{itemize}
220         \item Set the \texttt{DVB adapter} path = \texttt{/dev/dvb/adapter0} (probably)
221         \item Set the adapter \textit{dev} = 0 (probably)
222         \item Check: \textit{Follow video config}
223         \item \textit{Frames to record to disk at a time}: 30 (a good number)
224         \item \textit{Frames to buffer in device}: 2 ($2-6$ probably)
225         \item \textit{Positioning: Presentation Timestamps} (\textbf{this is important and may not be already set})
226         \item Uncheck: \textit{Sync drives automatically}
227         \item \textit{Size of captured frame}: $720x480$ (will automatically change)
228         \item \textit{Framerate for recording}: $29.97$ (will automatically change)
229         \item Click OK
230     \end{itemize}
231 \end{enumerate}
232
233 Figure~\ref{fig:recording03} shows the Preferences window as a good example of what you should see.
234
235 \begin{figure}[htpb]
236     \centering
237     \includegraphics[width=0.99\linewidth]{images/recording03.png}
238     \caption{Example of the Recording settings}
239     \label{fig:recording03}
240 \end{figure}
241
242 Scan the channels once the devices are setup by performing the following.
243
244 From the main window pulldown use:  \texttt{File $\rightarrow$ Record}  (lower case \textbf{r}) \& \textit{resize windows}.
245
246 \begin{itemize}
247     \item Two windows appear --  the \textit{Recording} and the \textit{Video In}.  The Recording window should have \texttt{Monitor video} checked and \textit{Monitor audio} unchecked.  Remember to check the Monitor audio later when you want to listen to a TV program.
248     \item On the \textit{Video In} toolbar, click the \textit{antenna} button (\textit{Edit channels} tool tip).
249     \item When the \textit{Channels} window opens, click \textit{scan} -- \textit{Scan confirm} window appears.
250     \item Make sure \textit{Freq table NTSC\_DVB}, \textit{Norm NTSC}, and \textit{input0} are chosen automatically.
251     \item Click OK and then wait for scan to end which may take several minutes.
252 \end{itemize}
253
254 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.
255
256 \begin{figure}[htpb]
257     \centering
258     \includegraphics[width=0.99\linewidth]{images/channels01.png}
259     \caption{Clockwise: Channels window; Video In (behind); Recording and Scan confirm}
260     \label{fig:channels01}
261 \end{figure}
262
263 Figure~\ref{fig:channels02} shows scanning in progress.  Note the \textit{Video In} with the antenna icon (3rd symbol).
264
265 \begin{figure}[htpb]
266     \centering
267     \includegraphics[width=0.99\linewidth]{images/channels02.png}
268     \caption{Scanning in progress ($6\%$)}
269     \label{fig:channels02}
270 \end{figure}
271
272 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}.
273
274 \begin{itemize}
275     \item Click chk-OK when done scanning channels and making any edits you want.
276 \end{itemize}
277
278 \noindent After the channel-db is ready, you can watch any of the selectable channels.
279
280 \subsection{Watching TV using \CGG{}}%
281 \label{sub:watching_tv_cinelerra}
282
283 If you have setup for DVB capture as outlined in the section above, just start here to watch TV.
284
285 \begin{itemize}
286     \item From the main window use  \texttt{File $\rightarrow$ Record}   to request  the \textit{Recording} application.
287     \item In the \textit{Video In} window, press the down arrow on the left to see the channel pulldown.
288     \item Select the desirable channel, and watch TV.  You will have to enable the audio by checking the \textit{Monitor audio} in the Recording window for sound.
289 \end{itemize}
290
291 \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 \textit{Audio meters}, checking \textit{drop overrun frames}, and checking \textit{fill underrun frames}.  Also, uncheck \textit{Realtime TOC} in the \texttt{references $\rightarrow$ Recording} window.
292
293 Dismiss the \textit{Recording} window with chk-OK, or "X" to cancel when finished.
294
295 \subsection{Recording TV to Capture at some Future Time via Batch}%
296 \label{sub:recording_tv_future_time_batch}
297
298 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 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.  
299
300 Figure~\ref{fig:channels03} shows \textit{Channel Info} window after the Ctrl-Alt-s completes scanning TV program data.
301
302 \begin{figure}[htpb]
303     \centering
304     \includegraphics[width=1.0\linewidth]{images/channels03.png}
305     \caption{Channels Info window with many TV channels buttons}
306     \label{fig:channels03}
307 \end{figure}
308
309 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 \textit{Start Cron} option is checked (default).  The batch job will start monitoring the channel to be ready for capture once you 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 \textit{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.
310
311 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.
312
313 \subsection{Recording Immediately to Capture a current TV program}%
314 \label{sub:recording_capture_current_tv_program}
315
316 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 \textit{Start}, \textit{Stop}, and then loaded via chk-OK.
317
318 \begin{itemize}
319     \item Bring up the \textit{Recording} window via the main window   \texttt{File $\rightarrow$ Record}   (lower case "r").
320     \item Set the \texttt{Path} to the write file Path; be sure there is enough disk space ($9.5Gb/hr$).
321     \item Set \textit{Mode} pulldown to \textit{Untimed} found in the upper left corner area of the window.
322     \item Press transport \textit{start recording} button (red round button).
323     \item Path will flash and update in batch window and remain flashing while recording.
324     \item Press transport \textit{stop recording} button (white square button).
325     \item Before clicking chk-OK, be sure to set the \textit{Insertion strategy}.
326     \item Pressing chk-OK attempts to load any newly recorded media data for review.
327     \item Or press \textit{X-cancel} to terminate and dismiss the \textit{Recording} application.
328 \end{itemize}
329
330 Figure~\ref{fig:recording04} shows the recording of a currently running broadcast TV program weather report.
331
332 \begin{figure}[htpb]
333     \centering
334     \includegraphics[width=0.95\linewidth]{images/recording04.png}
335     \caption{Recording in real-time a tv weather report}
336     \label{fig:recording04}
337 \end{figure}
338
339 \subsection{Record “on the fly” Table of Contents (TOC)}%
340 \label{sub:record_on_the_fly_toc}
341
342 If the \texttt{Settings $\rightarrow$ Preferences $\rightarrow$ Recording} tab is selected, and the \textit{video Record Driver} is changed to \textit{DVB}, the file format is switched to \textit{MPEG Stream} automatically (note that the \textit{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 \textit{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.
343
344 Figure~\ref{fig:realtime_toc} shows the red-checked \textit{Realtime TOC} for the \textit{Record Driver} of DVB.
345
346 \begin{figure}[htpb]
347     \centering
348     \includegraphics[width=0.8\linewidth]{images/realtime_toc.png}
349     \caption{Realtime TOC check red button}
350     \label{fig:realtime_toc}
351 \end{figure}
352
353 \subsection{Watching a Previously Recorded TV program}%
354 \label{sub:watching_recorded_tv_program}
355
356 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.
357
358 \begin{itemize}
359     \item In the main window choose   \texttt{File $\rightarrow$ Load} files  and select the desired media file to watch.
360     \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
361     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 Alt-1 in the main window to select \textit{Asset Program 1} (or "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.
362     \item Move timeline to where you would like to start watching.
363     \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 "f" in the Compositor window.
364 \end{itemize}
365
366 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.
367
368 \subsection{Dual Screen Mode}%
369 \label{sub:dual_screen_mode}
370
371 Dual screen mode is useful for displaying \CGG{} video/project on a large screen digital Television set or for watching a previously recorded broadcast TV program via \CGG{}.  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 \CGG{}, 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.
372
373 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.
374
375 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 \CGG{} 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:
376
377 \begin{description}
378     \item[a] select \textit{playback a} and tile windows left (all on monitor or laptop)
379     \item[b] select \textit{playback b} and tile windows right (all on $2^{nd}$ monitor or TV)
380     \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.
381 \end{description}
382
383 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.
384
385 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 \CGG{} 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.
386
387 \begin{figure}[htpb]
388     \centering
389     \includegraphics[width=0.85\linewidth]{images/two-monitors01.png}
390     \caption{Dual screen - initial}
391     \label{fig:two-monitors01}
392 \end{figure}
393
394 Figure~\ref{fig:two-monitors02} shows 2 monitors with Tile right (b key) where all of the \CGG{} windows are on the right monitor.  The left monitor shows the Suse distro logo and a couple of xterm type windows.
395
396 \begin{figure}[htpb]
397     \centering
398     \includegraphics[width=0.85\linewidth]{images/two-monitors02.png}
399     \caption{Dual screen - \CGG{} and desktop on different screens}
400     \label{fig:two-monitors02}
401 \end{figure}
402
403 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.
404
405 \begin{figure}[htpb]
406     \centering
407     \includegraphics[width=0.85\linewidth]{images/two-monitors03.png}
408     \caption{Dual screen - \CGG{} compositor on own screen windowed}
409     \label{fig:two-monitors03}
410 \end{figure}
411
412 Figure~\ref{fig:two-monitors04} shows 2 monitors with Compositor window on the 2nd monitor in Fullscreen mode so that no \CGG{} 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.
413
414 \begin{figure}[htpb]
415     \centering
416     \includegraphics[width=0.85\linewidth]{images/two-monitors04.png}
417     \caption{Dual screen - \CGG{} compositor on own screen full screen}
418     \label{fig:two-monitors04}
419 \end{figure}
420
421 \subsection{Remote Control for DVB}%
422 \label{sub:remote_control_dvb}
423
424 \begin{wrapfigure}[18]{O}{0.3\linewidth} 
425     \centering
426     \includegraphics[width=0.5\linewidth]{images/remote01.png}
427     \caption{Ati-x10 Remote}
428     \label{fig:remote01}
429 \end{wrapfigure}
430
431 \CGG{} DVB recording/playback can now easily be done in \textit{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 \CGG{} 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 \CGG{} and other remote controls may work but have never been tried.  The red/orange box on the top left main screen of \CGG{}  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.
432 \newline
433
434 Remote Control Keys (Application/Menu key toggle for ati-x10 remote)
435
436 % Should find something so that the last column width automatically adapts to margin/font/pagesize.
437 \begin{tabular}{lc p{12cm}}
438         \toprule
439     up arrow&=&forward 1 minute\\
440     
441     down arrow&=&forward single frame\\
442     
443     left arrow&=&forward slow playback\\
444     
445     right arrow&=&forward normal playback\\
446     
447     d&=&toggle channel scan menu\\
448     
449     f&=&toggle full screen\\
450     
451     a&=&select playback a and tile windows left (all on laptop)\\
452     
453     b&=&select playback b and tile windows right (all on TV)\\
454     
455     c&=&select playback c and tile windows left, but composer right (TV mode)\\
456     
457     0--9&=&select timeline by 1/10s from beginning to end\\
458     
459     a&=&toggle audio mute\\
460     
461     m&=&toggle audio meters\\
462     
463     keypad /&=&display mpeg ts stream program data\\
464     
465     keypad *&=&display mpeg ts stream channel schedule date\\
466     
467     keypad +&=&change channel, next\\
468     
469     keypad -&=&change channel, prev\\
470     
471     keypad .&=&start channel change by numeric entry\\
472     
473     keypad ..&=&clear channel entry\\
474     
475     book key&=&toggles channel scan (always available)\\
476     
477     hand key&=&terminates \CGG{} (always available)\\ 
478     \bottomrule 
479 \end{tabular}
480
481 \noindent Plus usual Transport keys:
482
483 \begin{tabular}{lcl}
484         \toprule
485     e&=&??\\
486     
487     f&=&toggle full screen\\
488     
489     <<&=&fast reverse\\
490     
491     >&=&toggles normal playback\\
492     
493     >>&=&fast forward\\
494     
495     red o&=&slow reverse\\
496     
497     square&=&stop\\
498     
499     2 lines&=&fast reverse\\
500     \bottomrule   
501 \end{tabular}
502
503 The Application/Menu key  \quad
504 \includegraphics[height=\baselineskip]{images/alt-ctrl.png} \quad
505 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 \CGG{} keys to work.
506
507 \subsection{Android Remote Control for DVB}%
508 \label{sub:android_remote_control_dvb}
509
510 \CGGI{} 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.
511
512 \begin{enumerate}
513     \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.
514     \item In \CGG{}, open \texttt{Settings $\rightarrow$ Preferences $\rightarrow$ Interface} tab, and enable \textit{Android Remote Control} in the Operation section using the checkbox. The default port $23432$ and default PIN value \textit{cinelerra} are OK.
515     \item After you install the new phone/tablet app in step 1, start it up from your apps menu.
516 \end{enumerate}
517
518 \begin{figure}[htpb]
519     \centering
520     \includegraphics[width=0.9\linewidth]{images/remote02.png}
521     \caption{Interface tab shows Android Remote Control}
522     \label{fig:remote02}
523 \end{figure}
524
525 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 \CGG{} 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 \textit{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.
526
527 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.
528
529 SECTION NOT COMPLETE – (manualandroid)
530
531 Figure~\ref{fig:remote03} shows an Android Tablet that can be used as a Remote Control for \CGG{} Recording and Playback.
532
533 \begin{figure}[htpb]
534     \centering
535     \includegraphics[width=0.6\linewidth]{images/remote03.png}
536     \caption{A Tablet with Android Remote Control}
537     \label{fig:remote03}
538 \end{figure}
539
540 \subsection{Setup a Remote Control Device}%
541 \label{sub:setup_remote_control_device}
542
543 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 \CGG{}.
544
545 \section{The commercial DB}%
546 \label{sec:commercial_db}
547
548 While watching broadcast television, it is possible to use \CGG{} 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).
549
550 Basically it works as follows, but there are a few differences in just how it goes about it:
551
552 \begin{enumerate}
553     \item Identify a zone in a timeline as a commercial.
554     \item Characterize it concisely, in the audio and video timeline.
555     \item Store the characterization in a database.
556 \end{enumerate}
557
558 Then, when capturing media or building a table of contents for an mpeg transport stream (broadcast capture DVB):
559
560 \begin{enumerate}
561     \item Characterize each I-Frame (a few frames per sec).
562     \item Search the database in real-time to identify the image.
563     \item If a match is identified, automatically press the mute button.
564     \item Unmute if the pattern match fails, or the commercial ends.
565 \end{enumerate}
566
567 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.
568
569 Currently, to activate the commercial database (db) methods you must do the following as root:
570
571 \begin{lstlisting}[language=bash,numbers=none]
572 cd <cin-path>/bin
573 mkdir /cinelerra              #yes, currently only in the / filesystem
574 ./cin_db /cinelerra/media.db  #to create a new empty commercial     capture database
575 export BC_USE_COMMERCIALS=1   #in the command shell that is starting \CGG{}
576 \end{lstlisting}
577
578 This activates the gui tools and database access.  As of yet, all of the requisite permission changes
579 necessary to run as non-root have not been worked out (initially just easier to run as root).
580
581 When a commercial is \textit{cut}, the following occurs:
582
583 \begin{enumerate}
584     \item transmits the capture timeline fragment to \texttt{/tmp}
585     \item scans the snip to characterize it statistically
586     \item creates a miniature b/w movie of the beginning and end
587     \item stores all of this into the \texttt{media.db}
588 \end{enumerate}
589
590 There are 2 ways currently to identify a commercial:
591
592 \begin{enumerate}
593     \item Load mpeg3 transport media, highlight select the commercial in the  timeline, and press \textit{cut commercial} on the toolbar.
594     \item Use the remote control interface to indicate the boundary in/out cut points in the realtime capture timeline, and operate a cut command.    
595 \end{enumerate}
596
597 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}.
598
599 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.
600
601 To review media stored in the \texttt{media.db}, and delete old expired commercial data records, press (Shift-M) from the main window.  This will create a media-db window which shows the various captured samples stored there.
602
603 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.
604
605 \section{Transfer VHS/DVD Media into \CGG{}}%
606 \label{sec:transfer_vhs_dvd_into_cinelerra}
607
608 If you want to transfer the data on a VHS tape or DVD disc into \CGG{}, 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 \textit{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.
609
610 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.
611
612 \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.
613
614 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.
615
616 \textit{Step 2}:Setup \CGG{} and it might be best the first time if you start with a default \texttt{.bcast5} file by using a
617 command line from a window of \\
618 \texttt{CIN\_CONFIG=\$HOME/bcast6 {cinelerra\_path}/bin/cin}
619
620 \begin{itemize}
621     \item Choose \texttt{Settings $\rightarrow$ Preferences $\rightarrow$ Recording} tab in the Preferences menu (figure~\ref{fig:recordingx}).
622     \item Choose a \textit{File Format} -- a common suggestion is \textit{ffmpeg} with a \textit{file type} of 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.
623     \item Check that the \textit{Audio In} section has the \textit{Record Driver} set to \textit{Alsa} with \textit{Device} set to \textit{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 \textit{default} could be \textit{HDMI}\dots instead.
624     \item In the \textit{Video In} section, change the\textit{ 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.
625     \item Also, \textit{Device path} should be verified to be correct in case you have more than 1 device.
626 \end{itemize}
627
628 \begin{figure}[htpb]
629     \centering
630     \includegraphics[width=0.9\linewidth]{images/recording03.png}
631     \caption{Example of the Preferences menu with the Recording tab highlighted}
632     \label{fig:recordingx}
633 \end{figure}
634
635 \textit{Step 3}: Next use the \textit{File} pulldown to choose \textit{Record} and then the Recording menu will popup (figure~\ref{fig:vhs01}).
636
637 \begin{itemize}
638     \item Click on the Antenna icon ($3^{rd}$ icon from the left on the left side of the right hand screen window).
639     \item In the popup \textit{Channels} menu, click on \texttt{Add} which brings up the \textit{Edit Channel} menu.
640     \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, \textit{S-Video 1} should be picked.
641     \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 \CGG{} to load it on the timeline for editing purposes.    
642 \end{itemize}
643
644 \begin{figure}[htpb]
645     \centering
646     \includegraphics[width=0.9\linewidth]{images/vhs01.png}
647     \caption{Example of the Recording, Video In, and Channels, along with the Add option, menus.}
648     \label{fig:vhs01}
649 \end{figure}
650
651 \begin{itemize}
652     \item Then highlight \textit{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).
653     \item Next press \textit{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.
654 \end{itemize}
655
656 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 \hyperref[sec:record_web_media_rt]{Record Web Media in real-time}. The \textit{Transport} buttons are well defined there also.
657
658 \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}).
659
660 \begin{figure}[htpb]
661     \centering
662     \includegraphics[width=0.9\linewidth]{images/vhs02.png}
663     \caption{Recording menu and Video In screen while capturing media.  Note the Transport stop option.}
664     \label{fig:vhs02}
665 \end{figure}
666
667 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.
668