russelltg / wl-screenrec

High performance wlroots screen recording, featuring hardware encoding
Apache License 2.0
266 stars 10 forks source link

ffmpeg cannot allocate memory error? #32

Closed felixsanz closed 8 months ago

felixsanz commented 8 months ago

Hi! My va-api / hardware acceleration works fine but with wl-screenrec i'm seeing this:

[nix-shell:~]$ wl-screenrec -g "$(slurp)" -v
Using output DP-2
Opening libva device from DRM device /dev/dri/renderD128
[AVHWFramesContext @ 0x56034beabd40] Failed to create surface: 14 (the requested RT Format is not supported).
[AVHWFramesContext @ 0x56034beabd40] Unable to allocate a surface from internal buffer pool.
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ffmpeg::Error(12: Cannot allocate memory)', src/main.rs:1226:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

this is what vainfo returns:

Trying display: wayland
libva info: VA-API version 1.19.0
libva info: User environment variable requested driver 'nvidia'
libva info: Trying to open /run/opengl-driver/lib/dri/nvidia_drv_video.so
libva info: Found init function __vaDriverInit_1_0
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.19 (libva 2.20.0)
vainfo: Driver version: VA-API NVDEC driver [direct backend]
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain12             : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD
      VAProfileHEVCMain444            : VAEntrypointVLD

Any idea what could be? Thanks

russelltg commented 8 months ago

Does wf-recorder -c h264_vaapi -d /dev/dri/card0 work?

What hardware are you on? I think that driver only supports decode not encode....

felixsanz commented 8 months ago

Does wf-recorder -c h264_vaapi -d /dev/dri/card0 work?

What hardware are you on? I think that driver only supports decode not encode....

wf-recorder -c h264_vaapi -d /dev/dri/card0   # doesn't work
wf-recorder -d /dev/dri/card0                 # doesn't work
wf-recorder                                   # works

# doesn't work also
ffmpeg -vaapi_device /dev/dri/renderD128 -i recording.mkv -c:v h264_vaapi rec_vaapi.mkv

I'm on AMD ryzen 2700X with a 2070 RTX.

i'm using this btw: https://github.com/elFarto/nvidia-vaapi-driver

Hardware decoding only, encoding is not supported.

ouch