FFmpeg X11 在 Ubuntu 服务器上抓取黑屏

FFmpeg X11 在 Ubuntu 服务器上抓取黑屏

我一直试图用 FFmpeg 抓取第二个显示服务器的输出,但是当我在 PC 上使用 VLC 打开视频时,它似乎是一个黑屏。我尝试过使用 apt 中的 FFmpeg 和我自己构建的 FFmpeg,但它们都得到了相同的输出。

这是我在视频中使用的命令:

ffmpeg -y -framerate 30 -f x11grab -video_size 1024x576 -i :1 -vcodec qtrle out.mov

以下是 FFmpeg 的输出

ffmpeg version N-92272-g0e9c01f Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609
  configuration: --prefix=/home/nas/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/nas/ffmpeg_build/include --extra-ldflags=-L/home/nas/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/nas/bin --enable-gpl --enable-libaom --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxcb --enable-nonfree
  libavutil      56. 20.100 / 56. 20.100
  libavcodec     58. 34.100 / 58. 34.100
  libavformat    58. 19.102 / 58. 19.102
  libavdevice    58.  4.106 / 58.  4.106
  libavfilter     7. 38.100 /  7. 38.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc    55.  2.100 / 55.  2.100
[x11grab @ 0x33a5a00] XFixes not available, cannot draw the mouse.
Input #0, x11grab, from ':1':
  Duration: N/A, start: 1540586402.265804, bitrate: N/A
    Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1024x576, 30 fps, 30 tbr, 1000k tbn, 1000k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> qtrle (native))
Press [q] to stop, [?] for help
Output #0, mov, to 'out.mov':
  Metadata:
    encoder         : Lavf58.19.102
    Stream #0:0: Video: qtrle (rle  / 0x20656C72), rgb24, 1024x576, q=2-31, 200 kb/s, 30 fps, 15360 tbn, 30 tbc
    Metadata:
      encoder         : Lavc58.34.100 qtrle
frame=  260 fps= 30 q=-0.0 Lsize=     424kB time=00:00:08.63 bitrate= 402.7kbits/s speed=1.01x
video:423kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.432202%
Exiting normally, received signal 2.

这是显示的 xdpyinfo:

name of display:    :1
version number:    11.0
vendor string:    AT&T Laboratories Cambridge
vendor release number:    3332
maximum request size:  4194300 bytes
motion buffer size:  256
bitmap unit, bit order, padding:    32, LSBFirst, 32
image byte order:    LSBFirst
number of supported pixmap formats:    2
supported pixmap formats:
    depth 1, bits_per_pixel 1, scanline_pad 32
    depth 24, bits_per_pixel 32, scanline_pad 32
keycode range:    minimum 8, maximum 255
focus:  window 0x1800001, revert to Parent
number of extensions:    7
    BIG-REQUESTS
    MIT-SHM
    MIT-SUNDRY-NONSTANDARD
    SHAPE
    SYNC
    XC-MISC
    XTEST
default screen number:    0
number of screens:    1

screen #0:
  dimensions:    1024x576 pixels (347x195 millimeters)
  resolution:    75x75 dots per inch
  depths (1):    24
  root window id:    0x25
  depth of root window:    24 planes
  number of colormaps:    minimum 1, maximum 1
  default colormap:    0x21
  default number of colormap cells:    256
  preallocated pixels:    black 0, white 16777215
  options:    backing-store YES, save-unders YES
  largest cursor:    1024x576
  current input event mask:    0x4a0003
    KeyPressMask             KeyReleaseMask           StructureNotifyMask
    SubstructureNotifyMask   PropertyChangeMask
  number of visuals:    1
  default visual id:  0x22
  visual:
    visual id:    0x22
    class:    TrueColor
    depth:    24 planes
    available colormap entries:    256 per subfield
    red, green, blue masks:    0xff0000, 0xff00, 0xff
    significant bits in color specification:    8 bits

如果需要更多信息(或视频样本),请告诉我,我会让他们使用。

任何帮助,将不胜感激

答案1

我遇到了同样的问题,这个链接帮助我解决了它:https://bbs.archlinux.org/viewtopic.php?id=222780

基本上,默认情况下,Gnome 使用 OpenGL 来渲染屏幕,因此 x11grab 不会捕获它。注销并使用选项“Gnome on Xorg”登录。ffmpeg 录制就是这样工作的。

答案2

在 xfce4 和 IceWM 上也遇到了同样的问题。应用此选项后问题消失

-draw_mouse 0

我不需要鼠标光标,所以我只是简单地禁用它(尽管正确的解决方案是处理各种 xfixes 选项,以防您需要光标:-))。

相关内容