Ubuntu: How to put a webcam recording and a desktop recording side by side with ffmpeg



Question:

I want to directly put 2 ffmpeg outut side by side in order to output a video that has both videos.

The recording ares

  1. a 640x480 webcam recording with:

    ffmpeg -f v4l2 -framerate 25 -video_size 640x480 -i /dev/video0 webcam.mkv  
  2. a desktop recording video of 1600x900 with

    ffmpeg -f x11grab -r 100 -s 1600x900 -i :0.0 -acodec pcm_s16le -vcodec libx264 -preset ultrafast -threads 3 desktop.mkv                  ---------------                |             |     |----------|   desktop   |     |  webcam  |             |     --------------------------  


Solution:1

ffmpeg \  -f v4l2 -framerate 25 -video_size 640x480 -i /dev/video0 \  -f x11grab -framerate 100 -video_size 1600x900 -i :0.0 \  -filter_complex "[0:v]pad=iw:900:0:(oh-ih)/2[left];[left][1:v]hstack" \  output  
  • Use -framerate instead of -r and -video_size instead of -s for x11grab.
  • The hstack filter will use the frame rate of the first input, so you may add the fps filter after the pad filter if desired.
  • -framerate 100 seems high and may not be sustainable.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »