How do I capture my second monitor using avconv?

2

With this command:

avconv -f x11grab -s 2560x1440 -i :0.0

I can stream video from my main monitor. I also have a second, 1080p monitor on which I do my gaming. I want to stream from that monitor. This doesn't work:

avconv -f x11grab -s 1920x1080 -i :0.1

I assume I have to use -i :0.0 and somehow specify that it should capture 1920x1080 pixels from X position 2560 and Y position 0. My gaming monitor is placed to the right of my main monitor. Unfortunately the man page for avconv is miles long, so I haven't had any luck figuring this out on my own.

I have tried

Using -vf with crop like this:

-vcodec libx264 ... -vf "crop=$IN_WIDTH:$IN_HEIGHT:2560:360"

But that only displayed 1080p video from the top left corner of my main display.

Hubro

Posted 2014-06-13T14:27:23.880

Reputation: 4 846

Answers

1

I figured one way to do it. My command now looks something like this:

avconv \
  -f x11grab -s "4480x1440" -r "30" -i :0.0 \
  -vcodec libx264 -s "1280x720" -preset slow -vf "crop=1920:1080:2560:360"

This basically captures both my monitors and crops the output to the second monitor. I'm guessing this adds some unnecessary work for my PC, but it's the only way I've managed to do this so far.

Hubro

Posted 2014-06-13T14:27:23.880

Reputation: 4 846

1

x=your_left_monitor_x-size;
y=if_you_want_to_crop_from_top/bottom;
bitrate=8192;
avconv -f alsa -i pulse -acodec libmp3lame -ab 192k -f x11grab -r 60 -s 1920x1080 -i :0.0+${x},${y} -vcodec libx264 -vb ${bitrate}k -threads 4 -y video.mp4

Dorian MJ

Posted 2014-06-13T14:27:23.880

Reputation: 11

This worked for me, and before I tried to set -i :0.0+1440+400, which did not work, however, it was copied from xrandr information directly. So much about the difference between comma and plus sign :) – piotao – 2019-03-13T11:10:00.227