Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

dmabuf-capture doesn't work #1965

Closed
YaLTeR opened this issue Dec 24, 2019 · 9 comments
Closed

dmabuf-capture doesn't work #1965

YaLTeR opened this issue Dec 24, 2019 · 9 comments

Comments

@YaLTeR
Copy link
Contributor

YaLTeR commented Dec 24, 2019

On my desktop (AMD RX 580):

└─ env WAYLAND_DEBUG=1 examples/dmabuf-capture 29 vaapi /dev/dri/renderD129 libx264 nv12 12 test.mkv
[4053147.922]  -> wl_display@1.get_registry(new id wl_registry@2)
[4053147.943]  -> wl_display@1.sync(new id wl_callback@3)
[4053147.995] wl_display@1.delete_id(3)
[4053148.003] wl_registry@2.global(1, "wl_shm", 1)
[4053148.011] wl_registry@2.global(2, "zwp_linux_dmabuf_v1", 3)
[4053148.017] wl_registry@2.global(3, "wl_drm", 2)
[4053148.024] wl_registry@2.global(4, "wl_compositor", 4)
[4053148.033] wl_registry@2.global(5, "wl_subcompositor", 1)
[4053148.041] wl_registry@2.global(6, "wl_data_device_manager", 3)
[4053148.053] wl_registry@2.global(7, "zwlr_gamma_control_manager_v1", 1)
[4053148.060] wl_registry@2.global(8, "gtk_primary_selection_device_manager", 1)
[4053148.069] wl_registry@2.global(9, "zxdg_output_manager_v1", 3)
[4053148.076] wl_registry@2.global(10, "org_kde_kwin_idle", 1)
[4053148.083] wl_registry@2.global(11, "zwp_idle_inhibit_manager_v1", 1)
[4053148.091] wl_registry@2.global(12, "zwlr_layer_shell_v1", 2)
[4053148.099] wl_registry@2.global(13, "xdg_wm_base", 2)
[4053148.107] wl_registry@2.global(14, "zwp_tablet_manager_v2", 1)
[4053148.115] wl_registry@2.global(15, "org_kde_kwin_server_decoration_manager", 1)
[4053148.126] wl_registry@2.global(16, "zxdg_decoration_manager_v1", 1)
[4053148.136] wl_registry@2.global(17, "zwp_relative_pointer_manager_v1", 1)
[4053148.145] wl_registry@2.global(18, "zwp_pointer_constraints_v1", 1)
[4053148.154] wl_registry@2.global(19, "wp_presentation", 1)
[4053148.163] wl_registry@2.global(20, "zwlr_output_manager_v1", 1)
[4053148.172] wl_registry@2.global(21, "zwlr_export_dmabuf_manager_v1", 1)
[4053148.183]  -> wl_registry@2.bind(21, "zwlr_export_dmabuf_manager_v1", 1, new id [unknown]@4)
[4053148.196] wl_registry@2.global(22, "zwlr_screencopy_manager_v1", 2)
[4053148.207] wl_registry@2.global(23, "zwlr_data_control_manager_v1", 2)
[4053148.216] wl_registry@2.global(24, "zwp_primary_selection_device_manager_v1", 1)
[4053148.226] wl_registry@2.global(25, "zwp_virtual_keyboard_manager_v1", 1)
[4053148.236] wl_registry@2.global(26, "zwlr_input_inhibit_manager_v1", 1)
[4053148.246] wl_registry@2.global(27, "wl_seat", 7)
[4053148.255] wl_registry@2.global(28, "zwp_pointer_gestures_v1", 1)
[4053148.265] wl_registry@2.global(29, "wl_output", 3)
[4053148.278]  -> wl_registry@2.bind(29, "wl_output", 1, new id [unknown]@5)
[4053148.293] wl_registry@2.global(30, "wl_output", 3)
[4053148.303]  -> wl_registry@2.bind(30, "wl_output", 1, new id [unknown]@6)
[4053148.317] wl_callback@3.done(871)
[4053148.373] wl_output@5.geometry(0, 0, 600, 340, 2, "Dell Inc.", "Dell S2716DG", 0)
[4053148.398] wl_output@5.mode(0, 640, 480, 59940)
[4053148.411] wl_output@5.mode(0, 640, 480, 60000)
[4053148.424] wl_output@5.mode(0, 800, 600, 60317)
[4053148.437] wl_output@5.mode(0, 1024, 768, 60004)
[4053148.450] wl_output@5.mode(0, 1280, 720, 59951)
[4053148.461] wl_output@5.mode(0, 1280, 800, 59951)
[4053148.473] wl_output@5.mode(0, 1440, 900, 59951)
[4053148.485] wl_output@5.mode(0, 1280, 1024, 59951)
[4053148.497] wl_output@5.mode(0, 1680, 1050, 59951)
[4053148.509] wl_output@5.mode(0, 1600, 1200, 59951)
[4053148.521] wl_output@5.mode(0, 1920, 1080, 59951)
[4053148.532] wl_output@5.mode(0, 1920, 1200, 59951)
[4053148.544] wl_output@5.mode(0, 2560, 1440, 23971)
[4053148.556] wl_output@5.mode(0, 2560, 1440, 84983)
[4053148.568] wl_output@5.mode(0, 2560, 1440, 99946)
[4053148.579] wl_output@5.mode(0, 2560, 1440, 119998)
[4053148.590] wl_output@5.mode(1, 2560, 1440, 143998)
[4053148.609] wl_output@5.mode(2, 2560, 1440, 59951)
[4053148.622] wl_output@6.geometry(0, 0, 530, 300, 2, "Unknown", "G-SYNC 241910", 0)
[4053148.641] wl_output@6.mode(0, 640, 480, 60000)
[4053148.653] wl_output@6.mode(0, 800, 600, 60000)
[4053148.664] wl_output@6.mode(0, 1024, 768, 60000)
[4053148.676] wl_output@6.mode(0, 1280, 720, 60000)
[4053148.687] wl_output@6.mode(0, 1280, 800, 60000)
[4053148.698] wl_output@6.mode(0, 1440, 900, 60000)
[4053148.709] wl_output@6.mode(0, 1280, 1024, 60000)
[4053148.719] wl_output@6.mode(0, 1680, 1050, 60000)
[4053148.731] wl_output@6.mode(0, 1920, 1080, 59940)
[4053148.741] wl_output@6.mode(0, 1920, 1080, 84905)
[4053148.752] wl_output@6.mode(0, 1920, 1080, 99930)
[4053148.763] wl_output@6.mode(0, 1920, 1080, 119982)
[4053148.775] wl_output@6.mode(1, 1920, 1080, 144001)
[4053148.786] wl_output@6.mode(2, 1920, 1080, 60000)
Capturable output: Dell Inc. Model: Dell S2716DG: ID: 29
Capturable output: Unknown Model: G-SYNC 241910: ID: 30
[libx264 @ 0x559a43b42ec0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x559a43b42ec0] profile High, level 6.2, 4:2:0, 8-bit
[libx264 @ 0x559a43b42ec0] 264 - core 157 r2980 34c06d1 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=2 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=12 lookahead_threads=4 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=1 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=10 rc=abr mbtree=1 bitrate=12000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, matroska, to 'test.mkv':
    Stream #0:0: Video: h264, nv12, 2560x1440, q=2-31, 12000 kb/s, 144 fps, 1k tbn
[4053238.259]  -> zwlr_export_dmabuf_manager_v1@4.capture_output(new id zwlr_export_dmabuf_frame_v1@3, 1, wl_output@5)
[4053238.520] zwlr_export_dmabuf_frame_v1@3.frame(2560, 1440, 0, 0, 0, 1, 875713089, 16777215, 4294967295, 1)
[4053238.572] zwlr_export_dmabuf_frame_v1@3.object(0, fd 9, 15728640, 0, 10240, 0)
[4053245.437] zwlr_export_dmabuf_frame_v1@3.ready(0, 296, 985693242)
[4053245.577]  -> zwlr_export_dmabuf_manager_v1@4.capture_output(new id zwlr_export_dmabuf_frame_v1@7, 1, wl_output@5)
[AVHWFramesContext @ 0x559a43b46b00] Failed to read image from surface 0x2: 1 (operation failed).
[4053245.721]  -> zwlr_export_dmabuf_frame_v1@3.destroy()
[libx264 @ 0x559a43b42ec0] AVFrame.format is not set
[libx264 @ 0x559a43b42ec0] AVFrame.width or height is not set
[4053245.758] zwlr_export_dmabuf_frame_v1@7.frame(2560, 1440, 0, 0, 0, 1, 875713089, 16777215, 4294967295, 1)
[4053245.795] zwlr_export_dmabuf_frame_v1@7.object(0, fd 9, 15728640, 0, 10240, 0)
[libx264 @ 0x559a43b42ec0] Input picture width (2560) is greater than stride (0)
[dmabuf-capture @ 0x7ffc954ef0f0] Error encoding: Generic error in an external library!
[4053252.332] wl_display@1.delete_id(3)
[4053252.367] zwlr_export_dmabuf_frame_v1@7.ready(0, 296, 992605184)
^C[dmabuf-capture @ 0x7ffc954ef0f0] Quitting!
^C

On my laptop (Intel Core i5-5200U):

└─ env WAYLAND_DEBUG=1 examples/dmabuf-capture 29 vaapi /dev/dri/renderD128 libx264 nv12 12 test.mkv
[4121521.525]  -> wl_display@1.get_registry(new id wl_registry@2)
[4121521.578]  -> wl_display@1.sync(new id wl_callback@3)
[4121521.720] wl_display@1.delete_id(3)
[4121521.755] wl_registry@2.global(1, "wl_shm", 1)
[4121521.792] wl_registry@2.global(2, "zwp_linux_dmabuf_v1", 3)
[4121521.819] wl_registry@2.global(3, "wl_drm", 2)
[4121521.844] wl_registry@2.global(4, "wl_compositor", 4)
[4121521.867] wl_registry@2.global(5, "wl_subcompositor", 1)
[4121521.891] wl_registry@2.global(6, "wl_data_device_manager", 3)
[4121521.918] wl_registry@2.global(7, "zwlr_gamma_control_manager_v1", 1)
[4121521.942] wl_registry@2.global(8, "gtk_primary_selection_device_manager", 1)
[4121521.969] wl_registry@2.global(9, "zxdg_output_manager_v1", 3)
[4121521.993] wl_registry@2.global(10, "org_kde_kwin_idle", 1)
[4121522.021] wl_registry@2.global(11, "zwp_idle_inhibit_manager_v1", 1)
[4121522.051] wl_registry@2.global(12, "zwlr_layer_shell_v1", 2)
[4121522.089] wl_registry@2.global(13, "xdg_wm_base", 2)
[4121522.107] wl_registry@2.global(14, "zwp_tablet_manager_v2", 1)
[4121522.137] wl_registry@2.global(15, "org_kde_kwin_server_decoration_manager", 1)
[4121522.167] wl_registry@2.global(16, "zxdg_decoration_manager_v1", 1)
[4121522.195] wl_registry@2.global(17, "zwp_relative_pointer_manager_v1", 1)
[4121522.225] wl_registry@2.global(18, "zwp_pointer_constraints_v1", 1)
[4121522.266] wl_registry@2.global(19, "wp_presentation", 1)
[4121522.297] wl_registry@2.global(20, "zwlr_output_manager_v1", 1)
[4121522.325] wl_registry@2.global(21, "zwlr_export_dmabuf_manager_v1", 1)
[4121522.352]  -> wl_registry@2.bind(21, "zwlr_export_dmabuf_manager_v1", 1, new id [unknown]@4)
[4121522.395] wl_registry@2.global(22, "zwlr_screencopy_manager_v1", 2)
[4121522.424] wl_registry@2.global(23, "zwlr_data_control_manager_v1", 2)
[4121522.449] wl_registry@2.global(24, "zwp_primary_selection_device_manager_v1", 1)
[4121522.478] wl_registry@2.global(25, "zwp_virtual_keyboard_manager_v1", 1)
[4121522.503] wl_registry@2.global(26, "zwlr_input_inhibit_manager_v1", 1)
[4121522.532] wl_registry@2.global(27, "wl_seat", 7)
[4121522.565] wl_registry@2.global(28, "zwp_pointer_gestures_v1", 1)
[4121522.594] wl_registry@2.global(29, "wl_output", 3)
[4121522.633]  -> wl_registry@2.bind(29, "wl_output", 1, new id [unknown]@5)
[4121522.673] wl_callback@3.done(17814)
[4121522.775] wl_output@5.geometry(0, 0, 290, 170, 2, "Sharp Corporation", "0x1420", 0)
[4121522.855] wl_output@5.mode(3, 1920, 1080, 59934)
Capturable output: Sharp Corporation Model: 0x1420: ID: 29
[AVHWDeviceContext @ 0x559fd4e962c0] Failed to initialise VAAPI connection: -1 (unknown libva error).
[dmabuf-capture @ 0x7ffd67abb7a0] Failed to create a hardware device: Input/output error
[4121523.143]  -> zwlr_export_dmabuf_manager_v1@4.destroy()
@YaLTeR
Copy link
Contributor Author

YaLTeR commented Dec 24, 2019

vainfo for desktop:

└─ vainfo
vainfo: VA-API version: 1.5 (libva 2.5.0)
vainfo: Driver version: Mesa Gallium driver 19.3.1 for Radeon RX 580 Series (POLARIS10, DRM 3.26.0, 4.18.16-zen1-1-zen, LLVM 9.0.0)
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileVC1Simple              :	VAEntrypointVLD
      VAProfileVC1Main                :	VAEntrypointVLD
      VAProfileVC1Advanced            :	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointEncSlice
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointEncSlice
      VAProfileHEVCMain               :	VAEntrypointVLD
      VAProfileHEVCMain               :	VAEntrypointEncSlice
      VAProfileHEVCMain10             :	VAEntrypointVLD
      VAProfileJPEGBaseline           :	VAEntrypointVLD
      VAProfileNone                   :	VAEntrypointVideoProc

vainfo for laptop:

└─ vainfo
vaInitialize failed with error code -1 (unknown libva error),exit

@cyanreg
Copy link

cyanreg commented Dec 24, 2019

Issue one is that on AMD you can't use VAAPI to encode from the screen because the AMD drivers cannot implicitly convert from bgr0 to nv12, while Intel allows to do this implicitly while encoding.
This is a known limitation (#992 (comment)), and could be solved with the libavutil Vulkan scaling filter that could do the conversion explicitly, whenever it gets merged. You need to use the opencl interop like ./dmabuf-capture vaapi /dev/dri/renderD128 libx264rgb bgr0 12 dmabuf_recording_01.mkv.

Issue two is probably that wlroots is sending dmabuf-capture a frame containing 2 dmabuf objects with 2 layers, but libavutil can only import single-object frames, "[AVHWFramesContext @ 0x55efabde80c0] VAAPI can only map frames made from a single DRM object.". This is a regression and incorrect, since all RGB drm format IDs are composed of single layer. Worse, it might cause other clients to crash because the number of layers is determined via the drm format sent, yet wlroots is referencing a second layer while sending objects.
The format id given is also 0x34325241, which corresponds to DRM_FORMAT_ARGB8888. This also seems like a regression because it should be and used to be DRM_FORMAT_XRGB8888. Its still okay as long as the alpha channel is all 0xff, but its not guaranteed like with XRGB, and to keep encoders and filters working would need to be relabled as XRGB by the client since interpreting the alpha channel on full screen capture is definitely not what you want.

@YaLTeR
Copy link
Contributor Author

YaLTeR commented Dec 24, 2019

This is the output with bgr0:

└─ env WAYLAND_DEBUG=1 examples/dmabuf-capture 29 vaapi /dev/dri/renderD129 libx264rgb bgr0 12 test.mkv
[3777168.054]  -> wl_display@1.get_registry(new id wl_registry@2)
[3777168.081]  -> wl_display@1.sync(new id wl_callback@3)
[3777168.156] wl_display@1.delete_id(3)
[3777168.166] wl_registry@2.global(1, "wl_shm", 1)
[3777168.175] wl_registry@2.global(2, "zwp_linux_dmabuf_v1", 3)
[3777168.181] wl_registry@2.global(3, "wl_drm", 2)
[3777168.187] wl_registry@2.global(4, "wl_compositor", 4)
[3777168.193] wl_registry@2.global(5, "wl_subcompositor", 1)
[3777168.201] wl_registry@2.global(6, "wl_data_device_manager", 3)
[3777168.212] wl_registry@2.global(7, "zwlr_gamma_control_manager_v1", 1)
[3777168.221] wl_registry@2.global(8, "gtk_primary_selection_device_manager", 1)
[3777168.231] wl_registry@2.global(9, "zxdg_output_manager_v1", 3)
[3777168.240] wl_registry@2.global(10, "org_kde_kwin_idle", 1)
[3777168.251] wl_registry@2.global(11, "zwp_idle_inhibit_manager_v1", 1)
[3777168.260] wl_registry@2.global(12, "zwlr_layer_shell_v1", 2)
[3777168.271] wl_registry@2.global(13, "xdg_wm_base", 2)
[3777168.281] wl_registry@2.global(14, "zwp_tablet_manager_v2", 1)
[3777168.291] wl_registry@2.global(15, "org_kde_kwin_server_decoration_manager", 1)
[3777168.301] wl_registry@2.global(16, "zxdg_decoration_manager_v1", 1)
[3777168.311] wl_registry@2.global(17, "zwp_relative_pointer_manager_v1", 1)
[3777168.321] wl_registry@2.global(18, "zwp_pointer_constraints_v1", 1)
[3777168.332] wl_registry@2.global(19, "wp_presentation", 1)
[3777168.342] wl_registry@2.global(20, "zwlr_output_manager_v1", 1)
[3777168.352] wl_registry@2.global(21, "zwlr_export_dmabuf_manager_v1", 1)
[3777168.363]  -> wl_registry@2.bind(21, "zwlr_export_dmabuf_manager_v1", 1, new id [unknown]@4)
[3777168.379] wl_registry@2.global(22, "zwlr_screencopy_manager_v1", 2)
[3777168.389] wl_registry@2.global(23, "zwlr_data_control_manager_v1", 2)
[3777168.399] wl_registry@2.global(24, "zwp_primary_selection_device_manager_v1", 1)
[3777168.409] wl_registry@2.global(25, "zwp_virtual_keyboard_manager_v1", 1)
[3777168.420] wl_registry@2.global(26, "zwlr_input_inhibit_manager_v1", 1)
[3777168.429] wl_registry@2.global(27, "wl_seat", 7)
[3777168.439] wl_registry@2.global(28, "zwp_pointer_gestures_v1", 1)
[3777168.449] wl_registry@2.global(29, "wl_output", 3)
[3777168.465]  -> wl_registry@2.bind(29, "wl_output", 1, new id [unknown]@5)
[3777168.481] wl_registry@2.global(30, "wl_output", 3)
[3777168.491]  -> wl_registry@2.bind(30, "wl_output", 1, new id [unknown]@6)
[3777168.505] wl_callback@3.done(144092)
[3777168.572] wl_output@5.geometry(0, 0, 600, 340, 2, "Dell Inc.", "Dell S2716DG", 0)
[3777168.620] wl_output@5.mode(0, 640, 480, 59940)
[3777168.632] wl_output@5.mode(0, 640, 480, 60000)
[3777168.647] wl_output@5.mode(0, 800, 600, 60317)
[3777168.668] wl_output@5.mode(0, 1024, 768, 60004)
[3777168.687] wl_output@5.mode(0, 1280, 720, 59951)
[3777168.706] wl_output@5.mode(0, 1280, 800, 59951)
[3777168.724] wl_output@5.mode(0, 1440, 900, 59951)
[3777168.743] wl_output@5.mode(0, 1280, 1024, 59951)
[3777168.762] wl_output@5.mode(0, 1680, 1050, 59951)
[3777168.780] wl_output@5.mode(0, 1600, 1200, 59951)
[3777168.799] wl_output@5.mode(0, 1920, 1080, 59951)
[3777168.818] wl_output@5.mode(0, 1920, 1200, 59951)
[3777168.828] wl_output@5.mode(0, 2560, 1440, 23971)
[3777168.846] wl_output@5.mode(0, 2560, 1440, 84983)
[3777168.864] wl_output@5.mode(0, 2560, 1440, 99946)
[3777168.881] wl_output@5.mode(0, 2560, 1440, 119998)
[3777168.898] wl_output@5.mode(1, 2560, 1440, 143998)
[3777168.917] wl_output@5.mode(2, 2560, 1440, 59951)
[3777168.937] wl_output@6.geometry(0, 0, 530, 300, 2, "Unknown", "G-SYNC 241910", 0)
[3777168.973] wl_output@6.mode(0, 640, 480, 60000)
[3777168.993] wl_output@6.mode(0, 800, 600, 60000)
[3777169.012] wl_output@6.mode(0, 1024, 768, 60000)
[3777169.027] wl_output@6.mode(0, 1280, 720, 60000)
[3777169.041] wl_output@6.mode(0, 1280, 800, 60000)
[3777169.054] wl_output@6.mode(0, 1440, 900, 60000)
[3777169.068] wl_output@6.mode(0, 1280, 1024, 60000)
[3777169.082] wl_output@6.mode(0, 1680, 1050, 60000)
[3777169.096] wl_output@6.mode(0, 1920, 1080, 59940)
[3777169.109] wl_output@6.mode(0, 1920, 1080, 84905)
[3777169.123] wl_output@6.mode(0, 1920, 1080, 99930)
[3777169.135] wl_output@6.mode(0, 1920, 1080, 119982)
[3777169.148] wl_output@6.mode(1, 1920, 1080, 144001)
[3777169.160] wl_output@6.mode(2, 1920, 1080, 60000)
Capturable output: Dell Inc. Model: Dell S2716DG: ID: 29
Capturable output: Unknown Model: G-SYNC 241910: ID: 30
[libx264rgb @ 0x55d73fd3a180] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264rgb @ 0x55d73fd3a180] profile High 4:4:4 Predictive, level 6.2, 4:4:4, 8-bit
[libx264rgb @ 0x55d73fd3a180] 264 - core 157 r2980 34c06d1 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=2 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=12 lookahead_threads=4 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=1 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=10 rc=abr mbtree=1 bitrate=12000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, matroska, to 'test.mkv':
    Stream #0:0: Video: h264, bgr0, 2560x1440, q=2-31, 12000 kb/s, 144 fps, 1k tbn
[3777253.142]  -> zwlr_export_dmabuf_manager_v1@4.capture_output(new id zwlr_export_dmabuf_frame_v1@3, 1, wl_output@5)
[3777253.264] zwlr_export_dmabuf_frame_v1@3.frame(2560, 1440, 0, 0, 0, 1, 875713089, 16777215, 4294967295, 1)
[3777253.286] zwlr_export_dmabuf_frame_v1@3.object(0, fd 9, 15728640, 0, 10240, 0)
[3777254.507] zwlr_export_dmabuf_frame_v1@3.ready(0, 12905, 896814219)
[3777254.573]  -> zwlr_export_dmabuf_manager_v1@4.capture_output(new id zwlr_export_dmabuf_frame_v1@7, 1, wl_output@5)
[3777254.642] zwlr_export_dmabuf_frame_v1@7.frame(2560, 1440, 0, 0, 0, 1, [AVHWFramesContext @ 0x55d73fd3dd40] Failed to read image from surface 0x2: 1 (operation failed).
875713089, 16777215, 4294967295, 1)
[3777254.706] zwlr_export_dmabuf_frame_v1@7.object(0, fd 10, 15728640, 0, 10240, 0)
[3777254.723]  -> zwlr_export_dmabuf_frame_v1@3.destroy()
[libx264rgb @ 0x55d73fd3a180] AVFrame.format is not set
[libx264rgb @ 0x55d73fd3a180] AVFrame.width or height is not set
fish: “env WAYLAND_DEBUG=1 examples/dm…” terminated by signal SIGSEGV (Address boundary error)
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007f726b7acf73 in x264_8_trellis_coefn () from /usr/lib/libx264.so.157
[Current thread is 1 (Thread 0x7f71db498700 (LWP 64647))]

thread apply all bt full

@cyanreg
Copy link

cyanreg commented Dec 24, 2019

Its probably because of issue 2 like I said.

@emersion
Copy link
Member

Thanks for the explanation, @cyanreg

@cyanreg
Copy link

cyanreg commented Mar 11, 2020

Ping?
Wanted to test ffmpeg's new vulkan code mapping but since kmsgrab has stopped working for me on newer kernel versions and wlroots seems to be doing something wrong with the protocol, I can't.

@emersion
Copy link
Member

Issue two is probably that wlroots is sending dmabuf-capture a frame containing 2 dmabuf objects with 2 layers, but libavutil can only import single-object frames

What is the modifier? Many Intel modifiers use two planes.

kmsgrab has stopped working

Yes, they need to use drmModeGetFB2.

wlroots seems to be doing something wrong with the protocol

I don't think that's true, see above.

@cyanreg
Copy link

cyanreg commented Mar 11, 2020

0x100000000000004 which seems to be I915_FORMAT_MOD_Y_TILED_CCS.
Now it makes sense, its a compressed texture, the second plane contains the color control surface. libavutil doesn't yet support such, so I think this bug can be closed.
Although, I think the format wlroots gives should be BGR0, since it makes no sense for full screen recording post-compositing to have alpha. Otherwise users will need to correct it themselves.

@emersion
Copy link
Member

emersion commented Mar 11, 2020

Alright, closing as a libavutil bug. Note that one can disable modifiers temporarily by setting WLR_DRM_NO_MODIFIERS=1.

Although, I think the format wlroots gives should be BGR0, since it makes no sense for full screen recording post-compositing to have alpha. Otherwise users will need to correct it themselves.

I think it's fine if clients need to strip the alpha channel manually. DMA-BUFs coming from clients may have an alpha channel, so clients should better be prepared for this anyway. Also some consumers might require an alpha channel (e.g. KMS planes sometimes accept ARGB but not XRGB).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

3 participants