man ffmpeg
有这个:
X11 grabbing
Grab the X11 display with ffmpeg via
ffmpeg -f x11grab -video_size cif -framerate 25 -i :0.0 /tmp/out.mpg
0.0 is display.screen number of your X11 server, same as the DISPLAY environment variable.
ffmpeg -f x11grab -video_size cif -framerate 25 -i :0.0+10,20 /tmp/out.mpg
0.0 is display.screen number of your X11 server, same as the DISPLAY environment variable. 10 is the x-offset and 20 the y-offset for the grabbing.
除最后一条命令外,以下命令均有效:
sleep 5s && ffmpeg -f x11grab -video_size cif -framerate 25 -i :0.0+10,20 ~/"$(date +%H%M%S)".mpg
sleep 5s && ffmpeg -f x11grab -video_size cif -framerate 25 -i :0.0+20,30 ~/"$(date +%H%M%S)".mpg
sleep 5s && ffmpeg -f x11grab -video_size cif -framerate 25 -i :0.0+30,40 ~/"$(date +%H%M%S)".mpg
sleep 5s && ffmpeg -f x11grab -video_size cif -framerate 25 -i :0.0+50,50 ~/"$(date +%H%M%S)".mpg
sleep 5s && ffmpeg -f x11grab -video_size cif -framerate 25 -i :0.0+100,200 ~/"$(date +%H%M%S)".mpg
sleep 5s && ffmpeg -f x11grab -video_size cif -framerate 25 -i :0.0+100,500 ~/"$(date +%H%M%S)".mpg
最后一个命令(不起作用的命令)的输出是这样的:
$ sleep 5s && ffmpeg -f x11grab -video_size cif -framerate 25 -i :0.0+100,500 ~/"$(date +%H%M%S)".mpg
ffmpeg version N-79139-gde1a0d4 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.1)
configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libfreetype --enable-gnutls --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab
libavutil 55. 19.100 / 55. 19.100
libavcodec 57. 30.100 / 57. 30.100
libavformat 57. 29.101 / 57. 29.101
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 40.102 / 6. 40.102
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
[x11grab @ 0x3975f00] Capture area 352x288 at position 100.500 outside the screen size 1366x768
:0.0+100,500: Invalid argument
$
有人可以帮我修复最后一个命令,以便我可以捕获任何屏幕区域?
答案1
您的屏幕高度为 768 像素。您的捕获区域高度为 288 像素。您的 y 偏移量为 500 像素。288+500=788。这超出了您的屏幕高度。捕获区域高度为 288 时,最大 y 偏移量为 480。