[FFmpeg-devel] [PATCH 4/4] lavd: Add KMS frame grabber

Michael Niedermayer michael at niedermayer.cc
Mon Sep 4 20:40:25 EEST 2017


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 ...

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many things microsoft did are stupid, but not doing something just because
microsoft did it is even more stupid. If everything ms did were stupid they
would be bankrupt already.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170904/e830c310/attachment.sig>


More information about the ffmpeg-devel mailing list