user20984: I'm using the following command to capture my screen cast and 
laptop video camera at the same time. Video from the camera
appears in a smallish window in bottom right of the screen cast.
This works, however there is a snag; I can't see the video of
myself on screen while I'm recording and I want to be able
to see myself in the bottom right window so I can be sure I
align myself with the camera. How can I do this?
ffmpeg -f alsa -i default \
-f x11grab -s `xdpyinfo | grep 'dimensions:'|awk '{print $2}'` -r 25 \
-i :0.0 -f video4linux2 \
-i /dev/video0 -filter_complex '[2:v]scale=380:-1[cam];[1:v][cam]overlay=W-w-8:H-h-8' \
-c:a flac \
-qscale 0 screen_and_video_grab.mkv


user20984: This solution works in Linux. 
To screen cast with inset video of yourself on screen where you have a video camera that is located at /dev/video0, paste the following into a text file and name it start_recording.sh or something similar and make it executable
#!/bin/bash




#####  set variables below ####

location_dir=$HOME/Desktop

T="$(date +%d-%m-%Y-%H-%M-%S)".mkv

#echo $T

video_window_title="$T"

#echo $video_window_title




####  Place video camera on own screen & detach the process  ####
ffplay -window_title "$video_window_title" /dev/video0 &




####  Record everything on the screen  ####
ffmpeg -y -f x11grab -s \
`xdpyinfo | grep 'dimensions:'|awk '{print $2}'` \
-i :0.0 -f alsa \
-i default $HOME/$T

To stop recording, paste the following into a text file and name it stop_recording.sh or something similar and make it executable
#!/bin/bash

# kills the ffmpeg and ffplay processes     
pkill ffmpeg && pkill ffplay

The below two line script will make your inset video the always on top window, or not. Simply put the below two lines below in a text file, call it something like toggle_video_inset_to_always_above_layer_or_normal_layer.sh or something you can remember, and make it executable. 
#!/bin/bash

wmctrl -r $(wmctrl -lx | grep ffplay | grep -oE "[0-9a-z\._-]{20,25}$") -b toggle,above


20984: <p>I'm using the following command to capture my screen cast and 
laptop video camera at the same time. Video from the camera
appears in a smallish window in bottom right of the screen cast.
This works, however there is a snag; I can't see the video of
myself on screen while I'm recording and I want to be able
to see myself in the bottom right window so I can be sure I
align myself with the camera. How can I do this?</p>

<pre><code>ffmpeg -f alsa -i default \
-f x11grab -s `xdpyinfo | grep 'dimensions:'|awk '{print $2}'` -r 25 \
-i :0.0 -f video4linux2 \
-i /dev/video0 -filter_complex '[2:v]scale=380:-1[cam];[1:v][cam]overlay=W-w-8:H-h-8' \
-c:a flac \
-qscale 0 screen_and_video_grab.mkv
</code></pre>
 20984: <p>This solution works in Linux. 
To screen cast with inset video of yourself on screen where you have a video camera that is located at /dev/video0, paste the following into a text file and name it <code>start_recording.sh</code> or something similar and make it executable</p>

<pre><code>#!/bin/bash




#####  set variables below ####

location_dir=$HOME/Desktop

T="$(date +%d-%m-%Y-%H-%M-%S)".mkv

#echo $T

video_window_title="$T"

#echo $video_window_title




####  Place video camera on own screen &amp; detach the process  ####
ffplay -window_title "$video_window_title" /dev/video0 &amp;




####  Record everything on the screen  ####
ffmpeg -y -f x11grab -s \
`xdpyinfo | grep 'dimensions:'|awk '{print $2}'` \
-i :0.0 -f alsa \
-i default $HOME/$T
</code></pre>

<p>To stop recording, paste the following into a text file and name it <code>stop_recording.sh</code> or something similar and make it executable</p>

<pre><code>#!/bin/bash

# kills the ffmpeg and ffplay processes     
pkill ffmpeg &amp;&amp; pkill ffplay
</code></pre>

<p>The below two line script will make your inset video the always on top window, or not. Simply put the below two lines below in a text file, call it something like <code>toggle_video_inset_to_always_above_layer_or_normal_layer.sh</code> or something you can remember, and make it executable. </p>

<pre><code>#!/bin/bash

wmctrl -r $(wmctrl -lx | grep ffplay | grep -oE "[0-9a-z\._-]{20,25}$") -b toggle,above
</code></pre>
