russelltg / wl-screenrec

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

No usable encoding profile found. #41

Open hholst80 opened 7 months ago

hholst80 commented 7 months ago

Not sure what is going on here. wl-record says vaapi does not support yuv420 but vainfo says it does?

wl-record v0.1.1 compiled via cargo + git.

[I] root@fedora ~
# wl-screenrec --verbose
Using output DP-1
Opening libva device from DRM device /dev/dri/renderD128
+----------+
|    in    |default--[3840x2160 0:1 vaapi]--Parsed_crop_0:default
| (buffer) |
+----------+

                                                            +--------------+
Parsed_scale_vaapi_1:default--[3840x2160 0:1 vaapi]--default|     out      |
                                                            | (buffersink) |
                                                            +--------------+

                                          +---------------+
in:default--[3840x2160 0:1 vaapi]--default| Parsed_crop_0 |default--[3840x2160 0:1 vaapi]--Parsed_scale_vaapi_1:default
                                          |    (crop)     |
                                          +---------------+

                                                     +----------------------+
Parsed_crop_0:default--[3840x2160 0:1 vaapi]--default| Parsed_scale_vaapi_1 |default--[3840x2160 0:1 vaapi]--out:default
                                                     |    (scale_vaapi)     |
                                                     +----------------------+

[h264_vaapi @ 0x561374eff900] No usable encoding profile found.
failed to open encoder in low_power mode (Function not implemented), trying non low_power mode. if you have an intel iGPU, set enable_guc=2 in the i915 module to use the fixed function encoder. pass --low-power=off to suppress this warning
[h264_vaapi @ 0x561374effcc0] No usable encoding profile found.
failed to create encoder: Function not implemented
[I] root@fedora ~
# wl-screenrec --verbose --no-hw
Using output DP-1
Opening libva device from DRM device /dev/dri/renderD128
[Parsed_scale_vaapi_1 @ 0x55eabd2197c0] Hardware does not support output format yuv420p.
[Parsed_scale_vaapi_1 @ 0x55eabd2197c0] Failed to configure output pad on Parsed_scale_vaapi_1
thread 'main' panicked at src/main.rs:1648:18:
called `Result::unwrap()` on an `Err` value: ffmpeg::Error(22: Invalid argument)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[I] root@fedora ~ [101]
# vainfo -a
Trying display: wayland
libva info: VA-API version 1.18.0
libva info: Trying to open /usr/lib64/dri/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_1_18
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.18 (libva 2.18.2)
vainfo: Driver version: Mesa Gallium driver 23.1.9 for AMD Radeon VII (vega20, LLVM 16.0.6, DRM 3.54, 6.5.12-200.fc38.x86_64)
vainfo: Supported config attributes per profile/entrypoint pair
VAProfileMPEG2Simple/VAEntrypointVLD
    VAConfigAttribRTFormat                 : VA_RT_FORMAT_YUV420

VAProfileMPEG2Main/VAEntrypointVLD
    VAConfigAttribRTFormat                 : VA_RT_FORMAT_YUV420

VAProfileNone/VAEntrypointVideoProc
    VAConfigAttribRTFormat                 : VA_RT_FORMAT_YUV420
                                             VA_RT_FORMAT_YUV422
                                             VA_RT_FORMAT_YUV444
                                             VA_RT_FORMAT_YUV400
                                             VA_RT_FORMAT_YUV420_10
                                             VA_RT_FORMAT_RGB32
                                             VA_RT_FORMAT_YUV420_10BPP
[I] root@fedora ~
# ls -alh /dev/dri/*
crw-rw---- 1 root video  226,   0 Nov 26  2023 /dev/dri/card0
crw-rw---- 1 root video  226,   1 Nov 26  2023 /dev/dri/card1
crw-rw-rw- 1 root render 226, 128 Nov 26  2023 /dev/dri/renderD128

/dev/dri/by-path:
total 0
drwxr-xr-x 2 root root 100 Nov 26  2023 ./
drwxr-xr-x 3 root root 120 Nov 26  2023 ../
lrwxrwxrwx 1 root root   8 Nov 26  2023 pci-0000:03:00.0-card -> ../card1
lrwxrwxrwx 1 root root  13 Nov 26  2023 pci-0000:03:00.0-render -> ../renderD128
lrwxrwxrwx 1 root root   8 Nov 26  2023 platform-simple-framebuffer.0-card -> ../card0

[I] root@fedora ~
# lspci |grep 03:00
03:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Vega 20 [Radeon VII] (rev c1)
03:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Vega 20 HDMI Audio [Radeon VII]
hholst80 commented 7 months ago

I do not think the '--no-hw' path is especially attractive solution anyway, but the error message was more informative to why 'No usable encoding profile found' was returned in the default setup.

russelltg commented 7 months ago

Retrospectively --no-hw isn't a great name for the flag, as it still does the pixel format conversion in HW. Does wf-recorder with vaapi work for you? Hard to imagine it does considering vainfo doesn't show any h264 support.....

hholst80 commented 7 months ago

I find it likely that the reason why it works on my other Fedora box is that it uses an Intel GPU and here on the workstation I have a fancy AMD GPU.

The error message "failed to create encoder: Function not implemented" is perhaps not the best, but besides that I do not think there is much you can help me with here.

"Fedora 37 drops VA-API accelerated hardware video decoding support"

https://www.reddit.com/r/linux/comments/xpyggi/comment/iq6nkhn/

russelltg commented 7 months ago

Hmm, this is encode and that is decode. Other people have reported this working fine on AMD GPUs, but I don't have one to test.

Unfortunately that error is from ffmpeg.

russelltg commented 7 months ago

I have happy users with AMD GPU's (#1, #39, #33). What GPU do you have? Does ffmpeg -vaapi_device /dev/dri/renderD128 -f lavfi -i rgbtestsrc=duration=5:size=1280x720:rate=30 -vf hwupload,crop=100:100:200:200,scale_vaapi=format=nv12:w=100:h=100 -c:v h264_vaapi testout.mp4 work?

hholst80 commented 7 months ago

The situation seems to be improving on my side. I got a lot of things in order on the new system. So, I wanted of course to go back and revisit this. This issue was the reason why I changed from Fedora to Arch Linux (Artix flavor) to begin with. :-)

[I] root@neo ~
# ffmpeg -vaapi_device /dev/dri/renderD128 -f lavfi -i rgbtestsrc=duration=5:size=1280x720:rate=30 -vf hwupload,crop=100:100:200:200,scale_vaapi=format=nv12:w=100:h=100 -c:v h264_vaapi testout.mp4
ffmpeg version 6.1-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
  libavutil      58. 29.100 / 58. 29.100
  libavcodec     60. 31.102 / 60. 31.102
  libavformat    60. 16.100 / 60. 16.100
  libavdevice    60.  3.100 / 60.  3.100
  libavfilter     9. 12.100 /  9. 12.100
  libswscale      7.  5.100 /  7.  5.100
  libswresample   4. 12.100 /  4. 12.100
  libpostproc    57.  3.100 / 57.  3.100
Unrecognized option 'vaapi_device'.
Error splitting the argument list: Option not found
[I] root@neo ~ [8]
# 
[I] root@neo ~
# wf-recorder -f test-vaapi.mp4 -c h264_vaapi -d /dev/dri/renderD128
Output file "test-vaapi.mp4" exists. Overwrite? Y/n: y
using VA-API, trying to enable DMA-BUF capture...
enabled DMA-BUF capture, device /dev/dri/renderD128
selected region 0,0 0x0
Using video filter: scale_vaapi=format=nv12:out_range=full
[h264_vaapi @ 0x7f1168002300] No quality level set; using default (20).
[h264_vaapi @ 0x7f1168002300] Driver does not support some wanted packed headers (wanted 0xd, found 0).
[h264_vaapi @ 0x7f1168002300] Driver does not support packed sequence headers, but a global header is requested.
[h264_vaapi @ 0x7f1168002300] No global header will be written: this may result in a stream which is not usable for some purposes (e.g. not muxable to some containers).
Output #0, mp4, to 'test-vaapi.mp4':
  Stream #0:0: Video: h264 (High), vaapi(pc), 3840x2160 [SAR 1:1 DAR 16:9], q=2-31
^C⏎                                                                                                    [I] root@neo ~
# wl-screenrec --dri-device /dev/dri/renderD128
Using output DP-1
Opening libva device from DRM device /dev/dri/renderD128
[h264_vaapi @ 0x564efc28fac0] No usable encoding entrypoint found for profile VAProfileH264High (7).
failed to open encoder in low_power mode (Function not implemented), trying non low_power mode. if you have an intel iGPU, set enable_guc=2 in the i915 module to use the fixed function encoder. pass --low-power=off to suppress this warning
[h264_vaapi @ 0x564efc28fac0] Driver does not support some wanted packed headers (wanted 0xd, found 0).
[h264_vaapi @ 0x564efc28fac0] Driver does not support packed sequence headers, but a global header is requested.
[h264_vaapi @ 0x564efc28fac0] No global header will be written: this may result in a stream which is not usable for some purposes (e.g. not muxable to some containers).
[h264_vaapi @ 0x564efc28fac0] Failed to upload encode parameters: 2 (resource allocation failed).
[h264_vaapi @ 0x564efc28fac0] Encode failed: -5.
thread 'main' panicked at src/main.rs:1426:51:
called `Result::unwrap()` on an `Err` value: ffmpeg::Error(5: Input/output error)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[I] root@neo ~ [101]
# vainfo
Trying display: wayland
vainfo: VA-API version: 1.20 (libva 2.20.0)
vainfo: Driver version: Mesa Gallium driver 23.2.1-arch1.2 for AMD Radeon VII (vega20, LLVM 16.0.6, DRM 3.49, 6.1.64-1-lts)
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc
[I] root@neo ~
# 
[I] root@neo ~ [244]
# ffmpeg -init_hw_device vaapi=hw:/dev/dri/renderD128 -filter_hw_device hw -f lavfi -i rgbtestsrc=duration=5:size=1280x720:rate=30 -vf hwupload,crop=100:100:200:200,scale_vaapi=format=nv12:w=100:h=100 -c:v h264_vaapi
 testout.mp4
ffmpeg version 6.1-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
  libavutil      58. 29.100 / 58. 29.100
  libavcodec     60. 31.102 / 60. 31.102
  libavformat    60. 16.100 / 60. 16.100
  libavdevice    60.  3.100 / 60.  3.100
  libavfilter     9. 12.100 /  9. 12.100
  libswscale      7.  5.100 /  7.  5.100
  libswresample   4. 12.100 /  4. 12.100
  libpostproc    57.  3.100 / 57.  3.100
Device creation failed: -12.
Failed to set value 'vaapi=hw:/dev/dri/renderD128' for option 'init_hw_device': Cannot allocate memory
Error parsing global options: Cannot allocate memory
[I] root@neo ~ [244]
# 

The error message looks strange because radeontop tells me there is plenty of memory.

image

Ristovski commented 7 months ago

Just to be safe, can you show the output of ffmpeg -hwaccels? Should look something like this:

Hardware acceleration methods:
vdpau
vaapi
drm
vulkan

(not sure if this has been merged into upstream ffmpeg, but the "Cannot allocate memory" message might be bogus as per https://patchwork.ffmpeg.org/project/ffmpeg/patch/484c6644-dfcd-1ad9-95fe-4bf2a06b30e7@jkqxz.net/)

hholst80 commented 7 months ago

It only shows vdpau ... ?

Just to be clear, I have an [AMD/ATI] Vega 20 [Radeon VII] (rev c1) GPU. I have disabled the Intel integrated GPU such that the OS only sees the PEG device. vainfo seems to work fine and also wf-recorder seems to be using the GPU (both CPU and GPU utilization is low during recording.)

Ristovski commented 7 months ago

It only shows vdpau ... ?

@hholst80 That is weird, its as if your ffmpeg build does not have vaapi enabled for some reason. vdpau is only for hw accelerated decoding.

Can you check the output of ffmpeg -buildconf | grep -Ei "vdpau|vaapi"?

For me it shows both --enable-vaapi and --enable-vdpau (which correlates to my ffmpeg -hwaccels output)

hholst80 commented 7 months ago

Classic "well, this is embarrassing" situation.

ffmpeg version 6.1-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
[I] root@neo ~
# which ffmpeg
/home/root/.local/bin/ffmpeg
# mv /home/root/.local/bin/ffmpeg{,-static}
#

Fixing that I get:

Hardware acceleration methods:
vdpau
cuda
vaapi
qsv
drm
opencl
vulkan
# I to increase w and h to 300 because driver complined 100x100 was too small.
# ffmpeg -init_hw_device vaapi=hw:/dev/dri/renderD128 -filter_hw_device hw -f lavfi -i rgbtestsrc=duration=5:size=1280x720:rate=30 -vf hwupload,crop=100:100:200:200,scale_vaapi=format=nv12:w=300:h=300 -c:v h264_vaapi testout.mp4

image

russelltg commented 7 months ago

Could wl-screenrec be using the wrong ffmpeg? ldd $(which wl-screenrec)

hholst80 commented 7 months ago

Looks like ffmpeg and wl-screenrec are using the same libs.

ffmpeg.txt wl-screenrec.txt

diff:

https://github.com/russelltg/wl-screenrec/assets/6200749/51677f50-8fda-48ad-b16b-2af32c63bbdb

hholst80 commented 7 months ago

Perhaps this is just due to a more permissive error handling in wf-recorder vs. wl-screenrec?

# wf-recorder -f test-vaapi.mp4 -c h264_vaapi -d /dev/dri/renderD128
Output file "test-vaapi.mp4" exists. Overwrite? Y/n: y
using VA-API, trying to enable DMA-BUF capture...
enabled DMA-BUF capture, device /dev/dri/renderD128
selected region 0,0 0x0
Using video filter: scale_vaapi=format=nv12:out_range=full
[h264_vaapi @ 0x7f38c0002300] No quality level set; using default (20).
[h264_vaapi @ 0x7f38c0002300] Driver does not support some wanted packed headers (wanted 0xd, found 0).
[h264_vaapi @ 0x7f38c0002300] Driver does not support packed sequence headers, but a global header is requested.
[h264_vaapi @ 0x7f38c0002300] No global header will be written: this may result in a stream which is not usable for some purposes (e.g. not muxable to some containers).
Output #0, mp4, to 'test-vaapi.mp4':
  Stream #0:0: Video: h264 (High), vaapi(pc), 3840x2160 [SAR 1:1 DAR 16:9], q=2-31
^C⏎                                                                                                    [I] root@neo ~
# 
+ wl-screenrec --low-power=off --encode-resolution 1920x1080 --audio
Using output DP-1
Opening libva device from DRM device /dev/dri/renderD128
[h264_vaapi @ 0x55f9bf3ef4c0] Driver does not support some wanted packed headers (wanted 0xd, found 0).
[h264_vaapi @ 0x55f9bf3ef4c0] Driver does not support packed sequence headers, but a global header is requested.
[h264_vaapi @ 0x55f9bf3ef4c0] No global header will be written: this may result in a stream which is not usable for some purposes (e.g. not muxable to some containers).
0 fps
[h264_vaapi @ 0x55f9bf3ef4c0] Failed to upload encode parameters: 2 (resource allocation failed).
[h264_vaapi @ 0x55f9bf3ef4c0] Encode failed: -5.
thread 'main' panicked at src/main.rs:1426:51:
called `Result::unwrap()` on an `Err` value: ffmpeg::Error(5: Input/output error)
stack backtrace:
   0:     0x55f9bdc94ee1 - std::backtrace_rs::backtrace::libunwind::trace::h938efb7ac3b4b9bb
                               at /builddir/build/BUILD/rustc-1.74.0-src/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x55f9bdc94ee1 - std::backtrace_rs::backtrace::trace_unsynchronized::hdb3130afb00196b2
                               at /builddir/build/BUILD/rustc-1.74.0-src/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x55f9bdc94ee1 - std::sys_common::backtrace::_print_fmt::h99aab20d4d0542ff
                               at /builddir/build/BUILD/rustc-1.74.0-src/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x55f9bdc94ee1 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h91f0c6dac97584ac
                               at /builddir/build/BUILD/rustc-1.74.0-src/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x55f9bdc5be4c - core::fmt::rt::Argument::fmt::hccd1db59d85bec3c
                               at /builddir/build/BUILD/rustc-1.74.0-src/library/core/src/fmt/rt.rs:138:9
   5:     0x55f9bdc5be4c - core::fmt::write::hadb576d8cc22952d
                               at /builddir/build/BUILD/rustc-1.74.0-src/library/core/src/fmt/mod.rs:1114:21
   6:     0x55f9bdc92b6d - std::io::Write::write_fmt::hd3784cb8817c312c
                               at /builddir/build/BUILD/rustc-1.74.0-src/library/std/src/io/mod.rs:1763:15
   7:     0x55f9bdc94cc5 - std::sys_common::backtrace::_print::h330d475718a82b03
                               at /builddir/build/BUILD/rustc-1.74.0-src/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x55f9bdc94cc5 - std::sys_common::backtrace::print::hfd68e0b6fc4a7be7
                               at /builddir/build/BUILD/rustc-1.74.0-src/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x55f9bdc961b3 - std::panicking::default_hook::{{closure}}::h50dd6a5c8f27eca4
                               at /builddir/build/BUILD/rustc-1.74.0-src/library/std/src/panicking.rs:272:22
  10:     0x55f9bdc95f02 - std::panicking::default_hook::hfcea74576cf59f61
                               at /builddir/build/BUILD/rustc-1.74.0-src/library/std/src/panicking.rs:292:9
  11:     0x55f9bdc9669b - std::panicking::rust_panic_with_hook::hd001ca82f62340ad
                               at /builddir/build/BUILD/rustc-1.74.0-src/library/std/src/panicking.rs:731:13
  12:     0x55f9bdc9659e - std::panicking::begin_panic_handler::{{closure}}::h815b59c3e229799b
                               at /builddir/build/BUILD/rustc-1.74.0-src/library/std/src/panicking.rs:609:13
  13:     0x55f9bdc953c6 - std::sys_common::backtrace::__rust_end_short_backtrace::h4a443d64544d51c7
                               at /builddir/build/BUILD/rustc-1.74.0-src/library/std/src/sys_common/backtrace.rs:170:18
  14:     0x55f9bdc96342 - rust_begin_unwind
                               at /builddir/build/BUILD/rustc-1.74.0-src/library/std/src/panicking.rs:597:5
  15:     0x55f9bdbff855 - core::panicking::panic_fmt::he1d13495b4d13340
                               at /builddir/build/BUILD/rustc-1.74.0-src/library/core/src/panicking.rs:72:14
  16:     0x55f9bdbffcf3 - core::result::unwrap_failed::h416d273107a0926d
                               at /builddir/build/BUILD/rustc-1.74.0-src/library/core/src/result.rs:1652:5
  17:     0x55f9bdcd6aa0 - wl_screenrec::EncState::process_ready::hb8c0be31b72cbe8f
  18:     0x55f9bdccda9a - <wl_screenrec::State as wayland_client::event_queue::Dispatch<wayland_protocols_wlr::screencopy::v1::generated::client::zwlr_screencopy_frame_v1::ZwlrScreencopyFrameV1,()>>::event::h8d49ba548dfd364f
  19:     0x55f9bdce6b91 - wayland_client::event_queue::queue_callback::h12f54bcc24edc7dc
  20:     0x55f9bdce8a95 - wayland_client::event_queue::EventQueue<State>::dispatching_impl::h0a6f117edb30a3be
  21:     0x55f9bdce8dcf - wayland_client::event_queue::EventQueue<State>::blocking_dispatch::h1514ecc02112bec1
  22:     0x55f9bdcd94be - wl_screenrec::main::h5606d1205275c550
  23:     0x55f9bdd07753 - std::sys_common::backtrace::__rust_begin_short_backtrace::hd914cf76d5a3b902
  24:     0x55f9bdd00639 - std::rt::lang_start::{{closure}}::hb732c73c09ab0374
  25:     0x55f9bdc8e55f - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::hcab3a09e04d63fe7
                               at /builddir/build/BUILD/rustc-1.74.0-src/library/core/src/ops/function.rs:284:13
  26:     0x55f9bdc8e55f - std::panicking::try::do_call::h8427747ad0e09c1b
                               at /builddir/build/BUILD/rustc-1.74.0-src/library/std/src/panicking.rs:504:40
  27:     0x55f9bdc8e55f - std::panicking::try::h82c1b474e0405a64
                               at /builddir/build/BUILD/rustc-1.74.0-src/library/std/src/panicking.rs:468:19
  28:     0x55f9bdc8e55f - std::panic::catch_unwind::h91cc7393872dbf91
                               at /builddir/build/BUILD/rustc-1.74.0-src/library/std/src/panic.rs:142:14
  29:     0x55f9bdc8e55f - std::rt::lang_start_internal::{{closure}}::h39807600b3c8b3ee
                               at /builddir/build/BUILD/rustc-1.74.0-src/library/std/src/rt.rs:148:48
  30:     0x55f9bdc8e55f - std::panicking::try::do_call::hf61bc514e36736df
                               at /builddir/build/BUILD/rustc-1.74.0-src/library/std/src/panicking.rs:504:40
  31:     0x55f9bdc8e55f - std::panicking::try::hb982ff816c4ba4b3
                               at /builddir/build/BUILD/rustc-1.74.0-src/library/std/src/panicking.rs:468:19
  32:     0x55f9bdc8e55f - std::panic::catch_unwind::h6298355f030b7719
                               at /builddir/build/BUILD/rustc-1.74.0-src/library/std/src/panic.rs:142:14
  33:     0x55f9bdc8e55f - std::rt::lang_start_internal::h3650e9192e2d4912
                               at /builddir/build/BUILD/rustc-1.74.0-src/library/std/src/rt.rs:148:20
  34:     0x55f9bdcdfd45 - main
  35:     0x7fcd21445cd0 - <unknown>
  36:     0x7fcd21445d8a - __libc_start_main
  37:     0x55f9bdc04625 - _start
  38:                0x0 - <unknown>
[I] root@neo ~
# 
russelltg commented 7 months ago

I don't think so. You're welcome to test this patch against latest main:

diff --git a/src/main.rs b/src/main.rs
index fd62896..a2790ad 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1423,7 +1423,9 @@ impl EncState {
             .is_ok()
         {
             // encoder has same time base as the filter, so don't do any time scaling
-            self.enc_video.send_frame(&yuv_frame).unwrap();
+            if let Err(e) = self.enc_video.send_frame(&yuv_frame) {
+                eprintln!("Failed to encode: {e}")
+            }
         }

         let mut encoded = Packet::empty();

I'll probably push this patch anyways as it's less nasty than a panic, and I suppose maybe sometimes that error isn't fatal. It's hard to say.

I would be interested in full strace outputs from those two commands to see exactly what is failing.

hholst80 commented 4 months ago

on git sha 6110ba66495c65b913cf50afb595eab7b992cb34 I get this.

Seems to be the same error message as I got on the "new machine" (called "goblin") in #64

This is on the same hardware as before on my "neo" machine.

[I] root@neo ~
# wl-screenrec --low-power=off --encode-resolution 1920x1080 --audio
Using output DP-1
Opening libva device from DRM device /dev/dri/renderD128
[Parsed_crop_0 @ 0x57ec399cf580] Invalid too big or non positive size for width '3840' or height '2160'
[Parsed_crop_0 @ 0x57ec399cf580] Failed to configure input pad on Parsed_crop_0
thread 'main' panicked at src/main.rs:1706:18:
called `Result::unwrap()` on an `Err` value: ffmpeg::Error(22: Invalid argument)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[I] root@neo ~ [101]
#
[I] root@neo ~
# vainfo
Trying display: wayland
vainfo: VA-API version: 1.20 (libva 2.20.1)
vainfo: Driver version: Mesa Gallium driver 24.0.1-arch1.1 for AMD Radeon VII (radeonsi, vega20, LLVM 16.0.6, DRM 3.57, 6.7.5-zen1-1-zen)
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc
[I] root@neo ~
#

vvv.txt

hholst80 commented 4 months ago

Aha! This might be related to non-integer scaling (I am exploring the best way to do HiDPI in a portable way between my many machines.).

If I use an integer scaling, like 2 instead of 2.4 like I am using now on both neo and goblin, I get this more familiar error message:

[I] root@neo ~/Apps/wl-screenrec (main)
# wl-screenrec --low-power=off --encode-resolution 1920x1080 --audio
Opening libva device from DRM device /dev/dri/renderD128
[h264_vaapi @ 0x588bbf9c5cc0] Driver does not support some wanted packed headers (wanted 0xd, found 0x1).
[h264_vaapi @ 0x588bbf9c5cc0] Failed to upload encode parameters: 2 (resource allocation failed).
[h264_vaapi @ 0x588bbf9c5cc0] Encode failed: -5.
thread 'main' panicked at src/main.rs:1505:51:
called `Result::unwrap()` on an `Err` value: ffmpeg::Error(5: Input/output error)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[I] root@neo ~/Apps/wl-screenrec (main) [101]
#

Another codec will work, it records a video, but with some yellow warnings:

image mp

russelltg commented 4 months ago

Does

ffmpeg -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -f lavfi -i testsrc=duration=10:size=1280x720 -filter_complex 'hwupload,scale_vaapi=format=nv12' -c:v h264_vaapi -loglevel 80 test.mp4

work and create a valid video?

SArpnt commented 1 month ago

i've recorded videos with this program before, but i started having this exact issue some time ago and i'm not sure what caused it.

sarpnt@mime-cube 
---------------- 
OS: Arch Linux x86_64 
Kernel: 6.9.2-zen1-1-zen 
Uptime: 1 hour, 10 mins 
Packages: 1298 (pacman) 
Shell: fish 3.7.1 
Resolution: 1920x1080 
WM: sway 
Theme: oomox-darker-than-fusion [GTK2/3] 
Icons: breeze-dark [GTK2/3] 
Terminal: foot 
CPU: Intel i5-4690K (4) @ 3.900GHz 
GPU: Intel HD Graphics 
GPU: AMD ATI Radeon RX 470/480/570/570X/580/580X/590 
Memory: 3708MiB / 11828MiB 
sarpnt@mime-cube ~> wl-screenrec
Opening libva device from DRM device /dev/dri/renderD129
[h264_vaapi @ 0x5604f2686d40] No usable encoding entrypoint found for profile VAProfileH264High (7).
failed to open encoder in low_power mode (Function not implemented), trying non low_power mode. if you have an intel iGPU, set enable_guc=2 in the i915 module to use the fixed function encoder. pass --low-power=off to suppress this warning
[h264_vaapi @ 0x5604f2686d40] Driver does not support some wanted packed headers (wanted 0xd, found 0x1).
[h264_vaapi @ 0x5604f2686d40] Failed to upload encode parameters: 2 (resource allocation failed).
[h264_vaapi @ 0x5604f2686d40] Encode failed: -5.
thread 'main' panicked at src/main.rs:1564:51:
called `Result::unwrap()` on an `Err` value: ffmpeg::Error(5: Input/output error)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
sarpnt@mime-cube ~ [101]> wl-screenrec --no-hw
Opening libva device from DRM device /dev/dri/renderD129
[Parsed_scale_vaapi_1 @ 0x634217b0d580] Hardware does not support output format yuv420p.
[Parsed_scale_vaapi_1 @ 0x634217b0d580] Failed to configure output pad on Parsed_scale_vaapi_1
thread 'main' panicked at src/main.rs:1782:18:
called `Result::unwrap()` on an `Err` value: ffmpeg::Error(22: Invalid argument)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

vainfo shows the amd card should work and ffmpeg with vaapi encoding works fine