[FFmpeg-devel] [PATCH 4/4] lavd: Add KMS frame grabber
jamrial at gmail.com
Mon Sep 4 20:59:11 EEST 2017
On 9/4/2017 2:40 PM, Michael Niedermayer wrote:
> On Sat, Sep 02, 2017 at 11:21:35PM +0100, Mark Thompson wrote:
>> The idea here is to be able to capture the screen with little CPU interaction by encoding KMS scanout planes. Given X running on KMS, it can capture both X and virtual consoles, including transitions between them while recording.
>> Unfortunately, it's rather inconvenient to use: the KMS API doesn't quite support the necessary set of things to work all the parameters out cleanly - framebuffer parameters (including the pixel format) need to be supplied by the user. For finding plane/CRTC IDs, the libdrm modetest program is useful (luckily the IDs are all global). Formats may have to be found by guessing until the output looks right. It also requires either DRM master or CAP_SYS_ADMIN to run (needed to access the framebuffer attached to the scanout plane).
>> On Intel gen9 / Linux 4.12, I can capture and encode with:
>> ./ffmpeg_g -y -framerate 60 -format bgr0 -crtc_id 26 -f kmsgrab -i - -init_hw_device vaapi=v:/dev/dri/renderD128 -filter_hw_device v -vf 'hwmap,scale_vaapi=w=1920:h=1080:format=nv12' -c:v h264_vaapi -frames:v 1000 out.mp4
>> There is some tiling going on which should need the format modifier to be set, but the Intel VAAPI driver is able to find it by magic so it isn't required for this example. On the other hand, mapping to the CPU does not give a sensible result because of that.
>> Given how tricky it is to use, I'm not really sure whether it is actually useful for this to be in ffmpeg. On the other hand, it does use a lot less CPU than xcbgrab! Thoughts welcome.
> My thought, if its less energy intensive than what we have then its
> worth having.
> A tiny contribution to reducing carbon emissions ...
I have to say this is a really silly reason to support implementing a
new, less CPU intensive screen grabber.
The real gain here is of course longer battery life on laptops.
More information about the ffmpeg-devel