russelltg / wl-screenrec

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

Bad error message when ffmpeg is too old #34

Closed hholst80 closed 7 months ago

hholst80 commented 8 months ago
[I] root@trump ~/S/code/wl-screenrec-git (master) [101]
# cargo version
cargo 1.73.0
[I] root@trump ~/S/code/wl-screenrec-git (master) [101]
# xbps-query libavutil
architecture: x86_64
automatic-install: yes
build-options: aom dav1d drm nvdec nvenc pulseaudio rist sndio srt svtav1 v4l2 vaapi vdpau vpx vulkan webp x265 ~fdk_aac ~sofa ~zimg
changelog: https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog
filename-sha256: e5c045cba2e6bc62388afcea8cae29832d4413e6c5dc94704a719847ec987b45
filename-size: 305KB
homepage: https://www.ffmpeg.org
install-date: 2023-11-01 17:39 UTC
installed_size: 679KB
license: GPL-3.0-or-later
maintainer: Orphaned <orphan@voidlinux.org>
metafile-sha256: 01ad882a2e83b4747c70d956ce7ba105cbce8baac5328a7d8fb6235fe46332d1
pkgname: libavutil
pkgver: libavutil-4.4.4_4
repository: https://repo-default.voidlinux.org/current
run_depends:
    glibc>=2.36_1
    libX11>=1.2_1
    libdrm>=2.4.6_1
    libva>=2.13.0_1
    libvdpau>=0.4.1_1
    ocl-icd>=2.2.12_1
    vulkan-loader>=1.0.57.0_1
shlib-provides:
    libavutil.so.56
shlib-requires:
    libOpenCL.so.1
    libX11.so.6
    libc.so.6
    libdrm.so.2
    libm.so.6
    libva-drm.so.2
    libva-x11.so.2
    libva.so.2
    libvdpau.so.1
    libvulkan.so.1
short_desc: FFmpeg utility library
source-revisions: ffmpeg:d890a041889
state: installed
I] root@trump ~/S/code/wl-screenrec-git (master)
# cargo install wl-screenrec # stable version
    Updating crates.io index
  Installing wl-screenrec v0.1.0
    Updating crates.io index
   Compiling proc-macro2 v1.0.69
   Compiling unicode-ident v1.0.12
   Compiling libc v0.2.149
   Compiling memchr v2.6.4
   Compiling pkg-config v0.3.27
   Compiling quote v1.0.33
   Compiling glob v0.3.1
   Compiling cc v1.0.83
   Compiling cfg-if v1.0.0
   Compiling minimal-lexical v0.2.1
   Compiling clang-sys v1.6.1
   Compiling autocfg v1.1.0
   Compiling syn v1.0.109
   Compiling regex-syntax v0.8.2
   Compiling memoffset v0.7.1
   Compiling libloading v0.7.4
   Compiling nom v7.1.3
   Compiling bindgen v0.64.0
   Compiling regex-automata v0.4.3
   Compiling cexpr v0.6.0
   Compiling regex v1.10.2
   Compiling libloading v0.8.1
   Compiling wayland-sys v0.31.1
   Compiling bitflags v1.3.2
   Compiling rustc-hash v1.1.0
   Compiling shlex v1.2.0
   Compiling lazy_static v1.4.0
   Compiling peeking_take_while v0.1.2
   Compiling lazycell v1.3.0
   Compiling dlib v0.5.2
   Compiling wayland-backend v0.3.2
   Compiling num_cpus v1.16.0
   Compiling log v0.4.20
   Compiling nix v0.26.4
   Compiling syn v2.0.38
   Compiling quick-xml v0.30.0
   Compiling smallvec v1.11.1
   Compiling downcast-rs v1.2.0
   Compiling scoped-tls v1.0.1
   Compiling utf8parse v0.2.1
   Compiling anstyle-parse v0.2.2
   Compiling wayland-scanner v0.31.0
   Compiling anstyle-query v1.0.0
   Compiling colorchoice v1.0.0
   Compiling anstyle v1.0.4
   Compiling bitflags v2.4.1
   Compiling wayland-client v0.31.1
   Compiling anstream v0.6.4
   Compiling heck v0.4.1
   Compiling ffmpeg-sys-next v6.0.1
   Compiling ffmpeg-next v6.0.0
   Compiling signal-hook v0.3.17
   Compiling thiserror v1.0.50
   Compiling clap_lex v0.6.0
   Compiling drm-fourcc v2.2.0
   Compiling strsim v0.10.0
   Compiling anyhow v1.0.75
   Compiling wayland-protocols v0.31.0
error: failed to run custom build command for `ffmpeg-sys-next v6.0.1`

Caused by:
  process didn't exit successfully: `/tmp/cargo-installQ4K13b/release/build/ffmpeg-sys-next-3bec4842ec4a487e/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=LIBAVUTIL_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

  --- stderr
  thread 'main' panicked at /home/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ffmpeg-sys-next-6.0.1/build.rs:715:14:
  called `Result::unwrap()` on an `Err` value: `PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" PKG_CONFIG_ALLOW_SYSTEM_LIBS="1" "pkg-config" "--libs" "--cflags" "libavutil"` did not exit successfully: exit status: 1
  error: could not find system library 'libavutil' required by the 'ffmpeg-sys-next' crate

  --- stderr
  Package libavutil was not found in the pkg-config search path.
  Perhaps you should add the directory containing `libavutil.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'libavutil' found

  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: failed to compile `wl-screenrec v0.1.0`, intermediate artifacts can be found at `/tmp/cargo-installQ4K13b`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
[I] root@trump ~/S/code/wl-screenrec-git (master) [101]
#
#

So ok that error was easy to fix:

[I] root@trump ~/S/code/AudioStreamer (master)
# xlocate libavutil.pc
xlocate: database outdated, please run xlocate -S.
ffmpeg-devel-32bit-4.4.4_4  /usr/lib32/pkgconfig/libavutil.pc
ffmpeg-devel-4.4.4_4        /usr/lib/pkgconfig/libavutil.pc
[I] root@trump ~/S/code/AudioStreamer (master)
#

So here we go again:

[I] root@trump ~/S/code/wl-screenrec-git (master) [101]
# cargo install wl-screenrec
  Compiling wayland-protocols-wlr v0.2.0
   Compiling clap v4.4.7
   Compiling human-size v0.4.3
   Compiling wl-screenrec v0.1.0
error[E0432]: unresolved import `ffmpeg::ffi::AVChannelOrder`
  --> /home/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wl-screenrec-0.1.0/src/audio.rs:16:64
   |
16 | ..._layout, AVChannelOrder},
   |             ^^^^^^^^^^^^^^ no `AVChannelOrder` in the root

error[E0599]: no variant or associated item named `VAAPI` found for enum `Pixel` in the current scope
  --> /home/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wl-screenrec-0.1.0/src/avhw.rs:51:47
   |
51 |             (*hwframe_casted).format = Pixel::VAAPI.into();
   |                                               ^^^^^ variant or associated item not found in `Pixel`

error[E0609]: no field `ch_layout` on type `AVCodecContext`
   --> /home/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wl-screenrec-0.1.0/src/audio.rs:328:52
    |
328 |     let ch_layout = unsafe { input.as_ptr().read().ch_layout };
    |                                                    ^^^^^^^^^ unknown field
    |
    = note: available fields are: `av_class`, `log_level_offset`, `codec_type`, `codec`, `codec_id` ... and 189 others

error[E0609]: no field `time_base` on type `AVFrame`
   --> /home/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wl-screenrec-0.1.0/src/main.rs:469:42
    |
469 |                     (*surf.as_mut_ptr()).time_base.num = 1;
    |                                          ^^^^^^^^^ unknown field
    |
    = note: available fields are: `data`, `linesize`, `extended_data`, `width`, `height` ... and 49 others

error[E0609]: no field `time_base` on type `AVFrame`
   --> /home/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wl-screenrec-0.1.0/src/main.rs:470:42
    |
470 | ...   (*surf.as_mut_ptr()).time_base.den = 1_000_000_000;
    |                            ^^^^^^^^^ unknown field
    |
    = note: available fields are: `data`, `linesize`, `extended_data`, `width`, `height` ... and 49 others

error[E0599]: no variant or associated item named `VAAPI` found for enum `Pixel` in the current scope
    --> /home/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wl-screenrec-0.1.0/src/main.rs:1119:47
     |
1119 |         EncodePixelFormat::Vaapi(_) => Pixel::VAAPI,
     |                                               ^^^^^ variant or associated item not found in `Pixel`

error[E0599]: no variant or associated item named `VAAPI` found for enum `Pixel` in the current scope
    --> /home/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wl-screenrec-0.1.0/src/main.rs:1200:64
     |
1200 | ...xel::VAAPI) {
     |         ^^^^^ variant or associated item not found in `Pixel`

error[E0599]: no variant or associated item named `VAAPI` found for enum `Pixel` in the current scope
    --> /home/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wl-screenrec-0.1.0/src/main.rs:1579:47
     |
1579 |         EncodePixelFormat::Vaapi(_) => Pixel::VAAPI,
     |                                               ^^^^^ variant or associated item not found in `Pixel`

Some errors have detailed explanations: E0432, E0599, E0609.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `wl-screenrec` (bin "wl-screenrec") due to 8 previous errors
error: failed to compile `wl-screenrec v0.1.0`, intermediate artifacts can be found at `/tmp/cargo-installNDBrFo`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
[I] root@trump ~/S/code/wl-screenrec-git (master) [101]
# 
russelltg commented 8 months ago

I need to have a better way to indicate this situation--your ffmpeg is too old.

galou commented 7 months ago

What is the minimum ffmpeg version with the latest stable?

russelltg commented 7 months ago

I believe ffmpeg 5 is required. It's best tested against 6.

russelltg commented 7 months ago

It doesn't seem like there's a great way to improve this error. The ffmpeg crate I use conditionally exposes features depending on version, so imports fail, which is earlier than any assertion I could add.

It would probably work if I wrapped the whole impl in a module but that's not really worth it for just a better compile error.

I've updated the docs with version info, including a notice that idk if it works on ffmpeg 5. Lmk if you try!