dbermond / screencast

Interface to record a X11 desktop
GNU General Public License v2.0
115 stars 9 forks source link

Add VAAPI hardware acceleraction encoder #1

Closed AngryPenguinPL closed 7 years ago

AngryPenguinPL commented 7 years ago

Hi.

FFMPEG from 3.1+ series support VAAPI HW encoding for Intel and AMD (closed and open drivers). So If we use old build FFMPEG like in Ubuntu 16.X we need manually compiling FFMPEG with flag vaapi but for new build FMMPEG this is enabled in default (for e.g in Ubuntu 17.04). So we can record in FFMPEG with VAAPI hardware accelerated encoder like on nvidia with nvenc! Basic Linux screen recorders can use it but they need only create new profiles to use vaapi hw encoder in h264 like in this request: https://github.com/MaartenBaert/ssr/issues/466 or this https://obsproject.com/forum/threads/experimental-ffmpeg-vaapi-plugin.61529/

Also you can learn more about vaapi hw encode here: https://gist.github.com/Brainiarc7/4b49f463a08377530df6cecb8171306a and here: https://gist.github.com/Brainiarc7/95c9338a737aa36d9bb2931bed379219

and few more directly in Brainiarc7 github page: https://gist.github.com/Brainiarc7

Can you add this VAAPI hw encoding for screencast?

dbermond commented 7 years ago

Hi, thank you for the interest in screencast.

I'll take a look at it as soon as I can.

dbermond commented 7 years ago

Do you have the a proper configured system and the supported hardware to make some tests?

AngryPenguinPL commented 7 years ago

Yes I can try it.

x@x-Aspire-7551G:~$ vainfo
libva info: VA-API version 0.39.4
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/r600_drv_video.so
libva info: Found init function __vaDriverInit_0_39
libva info: va_openDriver() returns 0
vainfo: VA-API version: 0.39 (libva 1.7.3)
vainfo: Driver version: mesa gallium vaapi
vainfo: Supported profile and entrypoints

So should work.

dbermond commented 7 years ago

I hope that your vainfo shows profiles with VAEntrypointEncSlice. This entrypoint means vaapi encoding capability.

VAEntrypointVLD is for decoding only. So probably it will not work if your vainfo shows only profiles with this entrypoint.

AngryPenguinPL commented 7 years ago

Oh, sorry for the problem, I thought that also means support for encoding.

Maybe I should write in the forums or the reddit asking for help in VAAPI tests in the screencast - I think more people should help.

dbermond commented 7 years ago

Ok, no problem. But if you have VAEntrypointEncSlice in vainfo you're ready to go.

Anyway, let me implement it first. I didn't had the time yet. I'll let you know when it will be ready to test.

dbermond commented 7 years ago

VAAPI hardware accelerated video encoding support has been added. It supports H.264, HEVC, VP8 and VP9 encoders.

The default DRM render node used by screencast is /dev/dri/renderD128. If in need to use another render node, it can be specified with the --vaapi-device (-A) option. Note that when wanting to use the default render node it does not need to be specified by the -A option.

Some usage examples:

Use the default /dev/dri/renderD128 DRM render node, which doesn't need to be specified by the -A option: $ screencast -u -s 1280x720 -p 200,234 -v h264_vaapi

Use /dev/dri/renderD129 DRM render node: $ screencast -u -s 1280x720 -p 200,234 -v h264_vaapi -A /dev/dri/renderD129

Just make sure that you have a supported graphics card and the proper configured system for the desired encoder.

Brainiarc7 commented 7 years ago

Awesome work, @dbermond , thanks for this.

AngryPenguinPL commented 7 years ago

Thanks. Good work. I create topic on reddit linux here: https://www.reddit.com/r/linux/comments/6pnkll/screencast_with_support_for_vaapi_hardware/

Looks like it work fine.

dbermond commented 7 years ago

@Brainiarc7 Thank you for the interest in this project. Please enjoy.

@AngryPenguinPL Good to know that it is working. Thank you for promoting the project on reddit.

Closing this issue.