[FFmpeg-devel] [PATCH 5/5] lavd: Add KMS frame grabber
sw at jkqxz.net
Fri Sep 15 02:59:11 EEST 2017
On 15/09/17 00:15, Andy Furniss wrote:
> Andy Furniss wrote:
>> Mark Thompson wrote:
>>> Now sets the trusted packet flag; otherwise unchanged.
>>> configure | 1 +
>>> libavdevice/Makefile | 1 +
>>> libavdevice/alldevices.c | 1 +
>>> libavdevice/kmsgrab.c | 455 +++++++++++++++++++++++++++++++++++++++++++++++
>>> 4 files changed, 458 insertions(+)
>>> create mode 100644 libavdevice/kmsgrab.c
>>> diff --git a/configure b/configure
>>> index 6581c53c1a..76a7591ceb 100755
>>> --- a/configure
>>> +++ b/configure
>>> @@ -3040,6 +3040,7 @@ gdigrab_indev_select="bmp_decoder"
>>> jack_indev_deps_any="sem_timedwait dispatch_dispatch_h"
>> Doesn't get built for me = doesn't show up as indev after configure anything special needed?
> Never mind I found --enable-libdrm (had tried --enable-kmsgrab)
I assume you're going to try AMD + Mesa + VAAPI.
VAAPI_DISABLE_INTERLACE=1 ./ffmpeg_g -y -format bgr0 -device /dev/dri/card1 -f kmsgrab -i - -vsync 0 -init_hw_device vaapi=v:/dev/dri/renderD129 -filter_hw_device v -vf 'hwmap,scale_vaapi=w=1920:h=1080:format=nv12' -c:v h264_vaapi -profile 578 -bf 0 out.mp4
Three Mesa issues I had to get around:
* Device derivation doesn't work because the Mesa driver doesn't want to initialise on the DRM master device for some reason; making the matching device separately does work.
* Against current git, you need to reapply the VAAPI_DISABLE_INTERLACE patch and use it - if not, the colour conversion just barfs because it wants interlaced surfaces.
* The postproc scaler seems to only write the luma plane when converting from RGB - this is also visible when uploading normal RGB images, so just a bug somewhere.
With that, it works to record the screen in greyscale...
I have some other Mesa stuff to do queued up (libva2 with VAAPI export for EGL import on AMD), so I'll pursue these further soonish.
More information about the ffmpeg-devel