MaartenBaert / ssr

SimpleScreenRecorder, a screen recorder for Linux
http://www.maartenbaert.be/simplescreenrecorder/
GNU General Public License v3.0
2.58k stars 290 forks source link

Request: Create new profile for use with VAAPI-based hardware #466

Open Brainiarc7 opened 8 years ago

Brainiarc7 commented 8 years ago

Hello there, @MaartenBaert ,

The latest versions of FFmpeg and Libav support hardware-accelerated H.264 encoding via VAAPI on supported SKUs, see supported feature list per SKU here

It would be good to have (a) profile(s) that can utilize this capability on such hardware, by automatically selecting the appropriate encoder (h264_vaapi or any other *_vaapi - based encoder in both ffmpeg and libav) that also passes the appropriate arguments as shown here for both use-cases. Secondly, these profiles would ideally be configurable should a user need to use advanced ffmpeg options passed to the selected encoder, as is the case with GCN+ - class hardware at the moment using the amdgpu and radeonsi drivers.

That would also ensure SSR's robustness in handling custom encoders as detected from user-built ffmpeg and libav versions, such as the h264_omx -based encoders (For AMD and Raspberry-pi hardware) and NVENC (exposed as h264_nvenc, hevc_nvenc and nvenc encoders when built with appropriate configuration switches).

Thanks and regards,

Brainiarc7

MaartenBaert commented 8 years ago

The problem is that these profiles will show up even for users who don't have compatible hardware, or who don't even have an ffmpeg install with the right flags enabled (NVENC is not there by default). This will lead to confusion.

I can't really handle these things transparently either, because the software and hardware encoders are absolutely not identical, they have different options and different quality vs. compression vs. speed tradeoffs. In some cases the software encoder is preferable. I do not want the software to behave differently on different hardware, because that again leads to confusion.

What I could do instead is add new codecs like:

These would show up in the 'simple' codec selection box, and they would have to automatically generate the required options to make this work. Advanced users can still pick 'other' and configure stuff manually like they do now.

Have you tried whether it is possible to get the Intel and AMD hardware to work with the current state of SSR? Can you get the right options to the encoder, or are changes to SSR necessary to make this work? I know that NVENC works, but I haven't been able to test Intel or AMD.

Brainiarc7 commented 8 years ago

Hello @MaartenBaert ,

Your suggestion on listing the new codecs under the 'simple' codec selection box is excellent, and it meets the requirements for the request, with added flexibility for advanced users. Thanks!

I'll try out the Intel part today when I dual boot, then I can go to "other" and create a profile with advanced options for the encoder.

Expect feedback on this soon.

Regards,

Brainiarc7

AngryPenguinPL commented 7 years ago

Any news? Can we see VAAPI support in SSR soon?

mashu commented 6 years ago

I am currently using Nvidia 960M nv_h264. However this slows down my OpenGL application, so VAAPI would be a really good solution here.

Ffmpeg shows all codes, its up to the user to select the correct one. After all not all options will work with streaming for example. I don't think there is anything confusing by including VAAPI.

I also strongly suggest to remove kbps field or at least make it not mandatory. Some codecs use other rate control, like crf=... instead of kbps. Than kbps must not be used, however simple screen recorder has that field and enforces us to use it.

But I prefer SimpleScreenRecorder over OBS, it works much better and is more flexible. Good work!

MaartenBaert commented 6 years ago

Just set the bitrate to 0 then. Internally FFmpeg requires me to give it a bitrate, I can't remove the option like the command-line tool seems to suggest.

If your FFmpeg copy includes VAAPI support, it should show up in SSR when you set the code to 'other'. I don't have the right hardware setup to test this though, some BIOS issue prevents me from enabling the Intel and NVIDIA GPU at the same time.

mashu commented 6 years ago

Hi,

ffmpeg -encoders | grep vaapi
ffmpeg version 3.4.1-1+b2 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 7 (Debian 7.2.0-19)
  configuration: --prefix=/usr --extra-version=1+b2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
 V..... h264_vaapi           H.264/AVC (VAAPI) (codec h264)
 V..... hevc_vaapi           H.265/HEVC (VAAPI) (codec hevc)
 V..... mjpeg_vaapi          MJPEG (VAAPI) (codec mjpeg)
 V..... mpeg2_vaapi          MPEG-2 (VAAPI) (codec mpeg2video)
 V..... vp8_vaapi            VP8 (VAAPI) (codec vp8)
 V..... vp9_vaapi            VP9 (VAAPI) (codec vp9)

I am using Debian's version of SimpleScreenRecorder and I don't see VAAPI encoders there

==================== SSR started ====================
SimpleScreenRecorder 0.3.8
Compiled with GCC 7.2.0
Qt: header 5.9.2, lib 5.9.2
libavformat: header 57.83.100, lib 57.83.100
libavcodec: header 57.107.100, lib 57.107.100
libavutil: header 55.78.100, lib 55.78.100
libswscale: header 4.8.100, lib 4.8.100

Because I can't compile from git repository, cmake files with some strange behaviour.

cmake -DCMAKE_INSTALL_PREFIX="/usr" -DCMAKE_BUILD_TYPE=Release ..
CMake Error at CMakeLists.txt:3 (cmake_policy):
  Policy "CMP0071" is not known to this version of CMake.

-- Checking for module 'libpulse'
--   Found libpulse, version 11.1
-- Checking for module 'jack'
--   Found jack, version 0.125.0rc1
-- Configuring incomplete, errors occurred!
See also "/home/mateusz/ssr/build-release/CMakeFiles/CMakeOutput.log".
See also "/home/mateusz/ssr/build-release/CMakeFiles/CMakeError.log".

Error suggests it has some issues with pthreads....

/usr/bin/cc   -DCHECK_FUNCTION_EXISTS=pthread_create   -o CMakeFiles/cmTC_cd735.dir/CheckFunctionExists.c.o   -c /usr/share/cmake-3.9/Modules/CheckFunctionExists.c
Linking C executable cmTC_cd735
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_cd735.dir/link.txt --verbose=1
/usr/bin/cc  -DCHECK_FUNCTION_EXISTS=pthread_create    -rdynamic CMakeFiles/cmTC_cd735.dir/CheckFunctionExists.c.o  -o cmTC_cd735 -lpthreads 
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_cd735.dir/build.make:97: recipe for target 'cmTC_cd735' failed

Is my SSR version up to date ? What's the problem with compiling ?

MaartenBaert commented 6 years ago

Policy "CMP0071" is not known to this version of CMake.

You need a newer version of cmake.

/usr/bin/ld: cannot find -lpthreads

This is harmless, cmake is just trying to determine the correct option name by trial and error. The real error is the first one.

I've just figured out that SSR no longer works with nvenc either on my machine (some kind of data corruption it seems), so I'm going to try to fix that first.

lilydjwg commented 5 years ago

I still don't see VAAPI options in the encoders list. I like the simplicity of ssr, but I have to switch to obs-studio for the performance unfortunately.

2xsaiko commented 4 years ago

Same thing here, it doesn't show up in the encoder list when I choose 'other' in SSR. Even manually trying to override the encoder in the SSR settings file makes it pick the first one in the list instead.

2x@invader ~ % ffmpeg -encoders | grep vaapi  
ffmpeg version n4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.2.0 (GCC)
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec --enable-nvenc --enable-omx --enable-shared --enable-version3
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
 V..... h264_vaapi           H.264/AVC (VAAPI) (codec h264)
 V..... hevc_vaapi           H.265/HEVC (VAAPI) (codec hevc)
 V..... mjpeg_vaapi          MJPEG (VAAPI) (codec mjpeg)
 V..... mpeg2_vaapi          MPEG-2 (VAAPI) (codec mpeg2video)
 V..... vp8_vaapi            VP8 (VAAPI) (codec vp8)
 V..... vp9_vaapi            VP9 (VAAPI) (codec vp9)
2x@invader ~ % ffmpeg -help encoder=h264_vaapi
ffmpeg version n4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.2.0 (GCC)
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec --enable-nvenc --enable-omx --enable-shared --enable-version3
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Encoder h264_vaapi [H.264/AVC (VAAPI)]:
    General capabilities: delay hardware 
    Threading capabilities: none
    Supported pixel formats: vaapi_vld
h264_vaapi AVOptions:
  -low_power         <boolean>    E..V..... Use low-power encoding mode (only available on some platforms; may not support all encoding features) (default false)
  -idr_interval      <int>        E..V..... Distance (in I-frames) between IDR frames (from 0 to INT_MAX) (default 0)
  -b_depth           <int>        E..V..... Maximum B-frame reference depth (from 1 to INT_MAX) (default 1)
  -rc_mode           <int>        E..V..... Set rate control mode (from 0 to 6) (default auto)
     auto                         E..V..... Choose mode automatically based on other parameters
     CQP                          E..V..... Constant-quality
     CBR                          E..V..... Constant-bitrate
     VBR                          E..V..... Variable-bitrate
     ICQ                          E..V..... Intelligent constant-quality
     QVBR                         E..V..... Quality-defined variable-bitrate
     AVBR                         E..V..... Average variable-bitrate
  -qp                <int>        E..V..... Constant QP (for P-frames; scaled by qfactor/qoffset for I/B) (from 0 to 52) (default 0)
  -quality           <int>        E..V..... Set encode quality (trades off against speed, higher is faster) (from -1 to INT_MAX) (default -1)
  -coder             <int>        E..V..... Entropy coder type (from 0 to 1) (default cabac)
     cavlc                        E..V.....
     cabac                        E..V.....
     vlc                          E..V.....
     ac                           E..V.....
  -aud               <boolean>    E..V..... Include AUD (default false)
  -sei               <flags>      E..V..... Set SEI to include (default identifier+timing+recovery_point)
     identifier                   E..V..... Include encoder version identifier
     timing                       E..V..... Include timing parameters (buffering_period and pic_timing)
     recovery_point               E..V..... Include recovery points where appropriate
  -profile           <int>        E..V..... Set profile (profile_idc and constraint_set*_flag) (from -99 to 65535) (default -99)
     constrained_baseline              E..V.....
     main                         E..V.....
     high                         E..V.....
  -level             <int>        E..V..... Set level (level_idc) (from -99 to 255) (default -99)
     1                            E..V.....
     1.1                          E..V.....
     1.2                          E..V.....
     1.3                          E..V.....
     2                            E..V.....
     2.1                          E..V.....
     2.2                          E..V.....
     3                            E..V.....
     3.1                          E..V.....
     3.2                          E..V.....
     4                            E..V.....
     4.1                          E..V.....
     4.2                          E..V.....
     5                            E..V.....
     5.1                          E..V.....
     5.2                          E..V.....
     6                            E..V.....
     6.1                          E..V.....
     6.2                          E..V.....
toazd commented 4 years ago

Same as @lilydjwg and @2xsaiko I do not see any vaapi choices. I have used ffmpeg successfully via command line already with hevc_vaapi and others so I know at least it is working. I'm not sure if I'm doing something wrong (is it named something else on the SSR menu?) or if just isn't supported.

uname -r

5.7.2-arch1-1

pacman -Qi simplescreenrecorder

Name            : simplescreenrecorder
Version         : 0.4.2-1
Description     : A feature-rich screen recorder that supports X11 and OpenGL.
Architecture    : x86_64
URL             : https://www.maartenbaert.be/simplescreenrecorder/
Licenses        : GPL3
Groups          : None
Provides        : None
Depends On      : qt5-base  qt5-x11extras  ffmpeg  alsa-lib  libpulse  jack  libgl  glu  libx11  libxext  libxfixes  libxi  libxinerama  desktop-file-utils
                  gtk-update-icon-cache
Optional Deps   : lib32-simplescreenrecorder: OpenGL recording of 32-bit applications [installed]
Required By     : None
Optional For    : None
Conflicts With  : None
Replaces        : None
Installed Size  : 3.75 MiB
Packager        : Kyle Keen <keenerd@gmail.com>
Build Date      : Mon 18 May 2020 10:46:41 PM EDT
Install Date    : Tue 16 Jun 2020 12:00:45 PM EDT
Install Reason  : Explicitly installed
Install Script  : Yes
Validated By    : Signature

ffmpeg -encoders | grep -i vaapi

ffmpeg version n4.2.3 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 10.1.0 (GCC)
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec --enable-nvenc --enable-omx --enable-shared --enable-version3
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
 V..... h264_vaapi           H.264/AVC (VAAPI) (codec h264)
 V..... hevc_vaapi           H.265/HEVC (VAAPI) (codec hevc)
 V..... mjpeg_vaapi          MJPEG (VAAPI) (codec mjpeg)
 V..... mpeg2_vaapi          MPEG-2 (VAAPI) (codec mpeg2video)
 V..... vp8_vaapi            VP8 (VAAPI) (codec vp8)
 V..... vp9_vaapi            VP9 (VAAPI) (codec vp9)

Choices after choosing Other...Codec Name drop-down (as they appear):

alias_pix
apng
asv1
asv2
bmp
cinepak
dnxhd
dpx
dvvideo
ffv1
ffvhuff
flashsv
flashsv2
flv
h261
h263
h263_v4l2m2m
h263p
h264_nvenc
h264_omx
h264_qsv
h264_v4l2m2m
hevc_nvenc
hevc_qsv
hevc_v4l2m2m
huffyuv
jpeg2000
jpegls
libaom-av1
libopenjpeg
librav1e
libtheora
libvpx
libvpx-vp9
libwebp
libwebp_anim
libx264
libx264rgb
libx265
libxvid
ljpeg
magicyuv
mjpeg_qsv
mpeg1video
mpeg2_qsv
mpeg2video
mpeg4
mpeg4_omx
mpeg4_v4l2m2m
msmpeg4
msmpeg4v2
nvenc
nvenc_h264
nvenc_hevc
pam
pcx
pgmyuv
png
ppm
qtrle
rawvideo
rv10
rv20
sgi
snow
sunrast
targa
tiff
utvideo
v210
v308
vc2
vp8_v4l2m2m
vp9_qsv
wmv1
wmv2
wrapped_avframe
xwd
yuv4
zlib
MaartenBaert commented 4 years ago

FFmpeg requires a custom 'pixel format' called AV_PIX_FMT_VAAPI to interface with VAAPI, this pixel format is really more of a completely different format for transmitting images which SSR currently doesn't implement. Unfortunately I don't have hardware with VAAPI support at the moment, so without a way to test any of this, I can't really develop an implementation.

toazd commented 4 years ago

FFmpeg requires a custom 'pixel format' called AV_PIX_FMT_VAAPI to interface with VAAPI, this pixel format is really more of a completely different format for transmitting images which SSR currently doesn't implement. Unfortunately I don't have hardware with VAAPI support at the moment, so without a way to test any of this, I can't really develop an implementation.

Thank you for explaining it that makes sense. I wish I could help in some way but I don't believe I have the skills necessary.

I will simply use one of the many existing high quality encoders already supported thanks to the great work you and the other 35 contributors have already done.