You are not logged in.

#1 2017-02-05 06:51:03

Simargol
Member
Registered: 2015-06-11
Posts: 10

[SOLVED] Capturing screen with FFmpeg gives black screen.

Example from FFmpeg ArchWiki page

$ ffmpeg -f x11grab -s 1600x900 -r 25 -i $DISPLAY -f alsa -i default -c:v libx264 -b:v 200k -s 1280x720 test.mp4

gives me

ffmpeg version 3.2.2 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 6.2.1 (GCC) 20160830
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-netcdf --enable-shared --enable-version3 --enable-x11grab
  libavutil      55. 34.100 / 55. 34.100
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.100 / 57. 56.100
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libavresample   3.  1.  0 /  3.  1.  0
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100
[x11grab @ 0x55ede6c536c0] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, x11grab, from ':0':
  Duration: N/A, start: 1486276608.609997, bitrate: N/A
    Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1600x900, 25 fps, 1000k tbr, 1000k tbn, 1000k tbc
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, alsa, from 'default':
  Duration: N/A, start: 1486276608.617785, bitrate: 1536 kb/s
    Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
No pixel format specified, yuv444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 0x55ede6c9aa20] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x55ede6c9aa20] profile High 4:4:4 Predictive, level 3.1, 4:4:4 8-bit
[libx264 @ 0x55ede6c9aa20] 264 - core 148 r2708 86b7198 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=200 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'test.mp4':
  Metadata:
    encoder         : Lavf57.56.100
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv444p, 1280x720, q=-1--1, 200 kb/s, 25 fps, 12800 tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.64.101 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
    Stream #0:1: Audio: aac (LC) ([64][0][0][0] / 0x0040), 48000 Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc57.64.101 aac
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
  Stream #1:0 -> #0:1 (pcm_s16le (native) -> aac (native))
Press [q] to stop, [?] for help
[alsa @ 0x55ede6c5c240] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
frame=  186 fps= 25 q=-1.0 Lsize=     111kB time=00:00:07.32 bitrate= 124.5kbits/s speed=0.968x    
video:24kB audio:81kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 6.339501%
[libx264 @ 0x55ede6c9aa20] frame I:1     Avg QP:44.16  size:   247
[libx264 @ 0x55ede6c9aa20] frame P:47    Avg QP: 6.15  size:   157
[libx264 @ 0x55ede6c9aa20] frame B:138   Avg QP: 6.82  size:   116
[libx264 @ 0x55ede6c9aa20] consecutive B-frames:  1.1%  0.0%  0.0% 98.9%
[libx264 @ 0x55ede6c9aa20] mb I  I16..4:  0.0% 99.9%  0.0%
[libx264 @ 0x55ede6c9aa20] mb P  I16..4:  0.0%  0.0%  0.0%  P16..4:  0.0%  0.0%  0.0%  0.0%  0.0%    skip:99.9%
[libx264 @ 0x55ede6c9aa20] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  0.2%  0.0%  0.0%  direct: 0.0%  skip:99.8%  L0:57.8% L1:42.2% BI: 0.0%
[libx264 @ 0x55ede6c9aa20] final ratefactor: 4.44
[libx264 @ 0x55ede6c9aa20] 8x8 transform intra:92.3% inter:6.4%
[libx264 @ 0x55ede6c9aa20] coded y,u,v intra: 3.1% 0.0% 0.0% inter: 0.0% 0.0% 0.0%
[libx264 @ 0x55ede6c9aa20] i16 v,h,dc,p: 93%  6%  1%  0%
[libx264 @ 0x55ede6c9aa20] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21%  2% 78%  0%  0%  0%  0%  0%  0%
[libx264 @ 0x55ede6c9aa20] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 10% 52%  2%  8%  3%  1%  2%  2%
[libx264 @ 0x55ede6c9aa20] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x55ede6c9aa20] ref P L0: 95.0%  0.0%  5.0%
[libx264 @ 0x55ede6c9aa20] ref B L0: 69.6% 29.8%  0.7%
[libx264 @ 0x55ede6c9aa20] ref B L1: 99.1%  0.9%
[libx264 @ 0x55ede6c9aa20] kb/s:25.37
[aac @ 0x55ede6c9bdc0] Qavg: 162.751

Video: http://s000.tinyupload.com/index.php?fi … 8532694107
Screen is black. Mouse is captured at the bottom of the screen when it is on browser, and not captured at the top of the screen when it is on terminal.

This happens on notebook with discrete Nvidia GPU. Maybe this problem is related to that?

Last edited by Simargol (2018-08-26 12:24:10)

Offline

#2 2017-02-05 13:28:53

seth
Member
Registered: 2012-09-03
Posts: 49,981

Re: [SOLVED] Capturing screen with FFmpeg gives black screen.

What kind of session is that? Gnome, KDE, xfce, ...
Is there a running compositor?

Offline

#3 2017-02-05 13:40:59

Simargol
Member
Registered: 2015-06-11
Posts: 10

Re: [SOLVED] Capturing screen with FFmpeg gives black screen.

I'm using default Gnome3 package. And I don't know much about X11 architecture.

Last edited by Simargol (2017-02-05 14:22:24)

Offline

#4 2017-02-05 14:57:06

seth
Member
Registered: 2012-09-03
Posts: 49,981

Re: [SOLVED] Capturing screen with FFmpeg gives black screen.

The gnome WM is a compositing one - on top of OpenGL.

First ensure you're not on (nouveau and) gnome on wayland - explicitly choose "gnome on wayland" on login.
If it still fails, install something like icewm or fluxbox (neither are compositing) and test with that session.

Offline

#5 2017-02-05 15:22:05

Simargol
Member
Registered: 2015-06-11
Posts: 10

Re: [SOLVED] Capturing screen with FFmpeg gives black screen.

There are:
  - gnome (I am logging with this one, assuming it is "gnome on wayland")
  - gnome classic
  - gnome on xorg

And I'm using proprietary driver:

$ lsmod | grep -E 'nouveau|nvidia'
nvidia_modeset        782336  0
nvidia              11870208  1 nvidia_modeset

$ pacman -Qs 'nouveau|nvidia'
local/bumblebee 3.2.1-12
    NVIDIA Optimus support for Linux through VirtualGL
local/lib32-mesa 13.0.4-1
    an open-source implementation of the OpenGL specification (32-bit)
local/lib32-nvidia-utils 375.26-2
    NVIDIA drivers utilities (32-bit)
local/libvdpau 1.1.1-2
    Nvidia VDPAU library
local/mesa 13.0.4-1
    an open-source implementation of the OpenGL specification
local/nvidia 375.26-6
    NVIDIA drivers for linux
local/nvidia-utils 375.26-2
    NVIDIA drivers utilities

I'll try those WM you mentioned tomorrow. It is night here already. Thank you for reply.

Last edited by Simargol (2017-02-05 15:33:00)

Offline

#6 2017-02-05 15:49:37

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,425

Re: [SOLVED] Capturing screen with FFmpeg gives black screen.

I'm fairly certain seth meant to say you should use Gnome on Xorg and explicitly not gnome on wayland, an unfortunate typo

Last edited by V1del (2017-02-05 15:50:30)

Offline

#7 2017-02-06 04:13:36

Simargol
Member
Registered: 2015-06-11
Posts: 10

Re: [SOLVED] Capturing screen with FFmpeg gives black screen.

Got it.
Gnome on XOrg + ffmpeg gives me normal ouput. Thank you.
Does this mean a problem is in wayland compositor?

Offline

#8 2017-02-06 06:36:16

HiImTye
Member
From: Halifax, NS, Canada
Registered: 2012-05-09
Posts: 1,072

Re: [SOLVED] Capturing screen with FFmpeg gives black screen.

the problem is that x11grab uses the X11 windowing system

I'm not aware of an ffmpeg plugin for Wayland/Weston that provides this functionality

Offline

#9 2017-02-06 07:31:11

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,425

Re: [SOLVED] Capturing screen with FFmpeg gives black screen.

And it also is inherently against a few security related design principles of wayland that one application would be able to grab the screen. It might take a while till people agree on a protocol to have specific programs allow such functionality and then have this implemented in wayland and ffmpeg and the implementing compositor.

Offline

#10 2017-02-06 08:13:53

seth
Member
Registered: 2012-09-03
Posts: 49,981

Re: [SOLVED] Capturing screen with FFmpeg gives black screen.

And you're likely using wayland (by default) because this seems to be an optimus system, ie. you're running gnome on the intel chip (3.22/wayland iirc doesn't work with the nvidia blob)

Offline

Board footer

Powered by FluxBB