Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-28T15:39:23.253Z
Answers.LastActivityDate: 2017-12-28T23:54:53.833Z
Answers.LastEditDate: 2017-12-28T23:54:53.833Z
Answers.UserDisplayName: Kes
Body: <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>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-12-26T02:49:08.797Z
Comments.Text: Open the webcam stream with a player, such as `ffplay -noborder /dev/video0`, then record desktop.
Comments.UserDisplayName: llogan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-12-28T15:40:01.607Z
Comments.Text: @LordNeckbeard Thanks. That helped me get to the solution I have posted.
Comments.UserDisplayName: Kes
Tags: <ffmpeg><video-recording><screen-casting>
Title: Screen cast and capture video cam and show both on screen using ffmpeg
UserDisplayName: Kes
ThreadText: # Screen cast and capture video cam and show both on screen using ffmpeg
  
  (Asked by: username_0 on 2017-12-24)
  
  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
  
  ```
  
  **Tags:** ffmpeg, video-recording, screen-casting
  
  > **Comments:**
  > **username_1**: Open the webcam stream with a player, such as `ffplay -noborder /dev/video0`, then record desktop.  
  > **username_0**: @LordNeckbeard Thanks. That helped me get to the solution I have posted.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2017-12-28. Score: 1 | Accepted answer
  
  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
  
  ```
  
  
  ---
  
  