russelltg / wl-screenrec

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

Doesn't build: ffmpeg-next non-exhaustive patterns #92

Open 1over137 opened 1 month ago

1over137 commented 1 month ago

System: Gentoo, ffmpeg version is 6.1.2

error[E0004]: non-exhaustive patterns: `sys::AVPixelFormat::AV_PIX_FMT_SAND128`, `sys::AVPixelFormat::AV_PIX_FMT_SAND64_10`, `sys::AVPixelFormat::AV_PIX_FMT_SAND64_16` and 2 more not covered
   --> /home/z/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ffmpeg-next-7.1.0/src/util/format/pixel.rs:481:15
    |
481 |         match value {
    |               ^^^^^ patterns `sys::AVPixelFormat::AV_PIX_FMT_SAND128`, `sys::AVPixelFormat::AV_PIX_FMT_SAND64_10`, `sys::AVPixelFormat::AV_PIX_FMT_SAND64_16` and 2 more not covered
    |
note: `sys::AVPixelFormat` defined here
   --> /tmp/cargo-installyH6KkV/release/build/ffmpeg-sys-next-6ee1392f1e7f8563/out/bindings.rs:3:161458
    |
3   | ...)] pub enum AVPixelFormat { AV_PIX_FMT_NONE = - 1 , AV_PIX_FMT_YUV420P = 0 , AV_PIX_FMT_YUYV422 = 1 , AV_PIX_FMT_RGB24 = 2 , AV_PIX_FMT_BGR24 = 3 , AV_PIX_FMT_YUV422P = 4 , AV_PIX_FMT_YUV444P = 5 , AV_PIX_FMT_YUV410P = 6 , AV_PIX_FMT_YUV411P = 7 , AV_PIX_FMT_GRAY8 = 8 , AV_PIX_FMT_MONOWHITE = 9 , AV_PIX_FMT_MONOBLACK = 10 , AV_PIX_FMT_PAL8 = 11 , AV_PIX_FMT_YUVJ420P = 12 , AV_PIX_FMT_YUVJ422P = 13 , AV_PIX_FMT_YUVJ444P = 14 , AV_PIX_FMT_UYVY422 = 15 , AV_PIX_FMT_UYYVYY411 = 16 , AV_PIX_FMT_BGR8 = 17 , AV_PIX_FMT_BGR4 = 18 , AV_PIX_FMT_BGR4_BYTE = 19 , AV_PIX_FMT_RGB8 = 20 , AV_PIX_FMT_RGB4 = 21 , AV_PIX_FMT_RGB4_BYTE = 22 , AV_PIX_FMT_NV12 = 23 , AV_PIX_FMT_NV21 = 24 , AV_PIX_FMT_ARGB = 25 , AV_PIX_FMT_RGBA = 26 , AV_PIX_FMT_ABGR = 27 , AV_PIX_FMT_BGRA = 28 , AV_PIX_FMT_GRAY16BE = 29 , AV_PIX_FMT_GRAY16LE = 30 , AV_PIX_FMT_YUV440P = 31 , AV_PIX_FMT_YUVJ440P = 32 , AV_PIX_FMT_YUVA420P = 33 , AV_PIX_FMT_RGB48BE = 34 , AV_PIX_FMT_RGB48LE = 35 , AV_PIX_FMT_RGB565BE = 36 , AV_PIX_FMT_RGB565LE = 37 , AV_PIX_FMT_RGB555BE = 38 , AV_PIX_FMT_RGB555LE = 39 , AV_PIX_FMT_BGR565BE = 40 , AV_PIX_FMT_BGR565LE = 41 , AV_PIX_FMT_BGR555BE = 42 , AV_PIX_FMT_BGR555LE = 43 , AV_PIX_FMT_VAAPI = 44 , AV_PIX_FMT_YUV420P16LE = 45 , AV_PIX_FMT_YUV420P16BE = 46 , AV_PIX_FMT_YUV422P16LE = 47 , AV_PIX_FMT_YUV422P16BE = 48 , AV_PIX_FMT_YUV444P16LE = 49 , AV_PIX_FMT_YUV444P16BE = 50 , AV_PIX_FMT_DXVA2_VLD = 51 , AV_PIX_FMT_RGB444LE = 52 , AV_PIX_FMT_RGB444BE = 53 , AV_PIX_FMT_BGR444LE = 54 , AV_PIX_FMT_BGR444BE = 55 , AV_PIX_FMT_YA8 = 56 , AV_PIX_FMT_BGR48BE = 57 , AV_PIX_FMT_BGR48LE = 58 , AV_PIX_FMT_YUV420P9BE = 59 , AV_PIX_FMT_YUV420P9LE = 60 , AV_PIX_FMT_YUV420P10BE = 61 , AV_PIX_FMT_YUV420P10LE = 62 , AV_PIX_FMT_YUV422P10BE = 63 , AV_PIX_FMT_YUV422P10LE = 64 , AV_PIX_FMT_YUV444P9BE = 65 , AV_PIX_FMT_YUV444P9LE = 66 , AV_PIX_FMT_YUV444P10BE = 67 , AV_PIX_FMT_YUV444P10LE = 68 , AV_PIX_FMT_YUV422P9BE = 69 , AV_PIX_FMT_YUV422P9LE = 70 , AV_PIX_FMT_GBRP = 71 , AV_PIX_FMT_GBRP9BE = 72 , AV_PIX_FMT_GBRP9LE = 73 , AV_PIX_FMT_GBRP10BE = 74 , AV_PIX_FMT_GBRP10LE = 75 , AV_PIX_FMT_GBRP16BE = 76 , AV_PIX_FMT_GBRP16LE = 77 , AV_PIX_FMT_YUVA422P = 78 , AV_PIX_FMT_YUVA444P = 79 , AV_PIX_FMT_YUVA420P9BE = 80 , AV_PIX_FMT_YUVA420P9LE = 81 , AV_PIX_FMT_YUVA422P9BE = 82 , AV_PIX_FMT_YUVA422P9LE = 83 , AV_PIX_FMT_YUVA444P9BE = 84 , AV_PIX_FMT_YUVA444P9LE = 85 , AV_PIX_FMT_YUVA420P10BE = 86 , AV_PIX_FMT_YUVA420P10LE = 87 , AV_PIX_FMT_YUVA422P10BE = 88 , AV_PIX_FMT_YUVA422P10LE = 89 , AV_PIX_FMT_YUVA444P10BE = 90 , AV_PIX_FMT_YUVA444P10LE = 91 , AV_PIX_FMT_YUVA420P16BE = 92 , AV_PIX_FMT_YUVA420P16LE = 93 , AV_PIX_FMT_YUVA422P16BE = 94 , AV_PIX_FMT_YUVA422P16LE = 95 , AV_PIX_FMT_YUVA444P16BE = 96 , AV_PIX_FMT_YUVA444P16LE = 97 , AV_PIX_FMT_VDPAU = 98 , AV_PIX_FMT_XYZ12LE = 99 , AV_PIX_FMT_XYZ12BE = 100 , AV_PIX_FMT_NV16 = 101 , AV_PIX_FMT_NV20LE = 102 , AV_PIX_FMT_NV20BE = 103 , AV_PIX_FMT_RGBA64BE = 104 , AV_PIX_FMT_RGBA64LE = 105 , AV_PIX_FMT_BGRA64BE = 106 , AV_PIX_FMT_BGRA64LE = 107 , AV_PIX_FMT_YVYU422 = 108 , AV_PIX_FMT_YA16BE = 109 , AV_PIX_FMT_YA16LE = 110 , AV_PIX_FMT_GBRAP = 111 , AV_PIX_FMT_GBRAP16BE = 112 , AV_PIX_FMT_GBRAP16LE = 113 , AV_PIX_FMT_QSV = 114 , AV_PIX_FMT_MMAL = 115 , AV_PIX_FMT_D3D11VA_VLD = 116 , AV_PIX_FMT_CUDA = 117 , AV_PIX_FMT_0RGB = 118 , AV_PIX_FMT_RGB0 = 119 , AV_PIX_FMT_0BGR = 120 , AV_PIX_FMT_BGR0 = 121 , AV_PIX_FMT_YUV420P12BE = 122 , AV_PIX_FMT_YUV420P12LE = 123 , AV_PIX_FMT_YUV420P14BE = 124 , AV_PIX_FMT_YUV420P14LE = 125 , AV_PIX_FMT_YUV422P12BE = 126 , AV_PIX_FMT_YUV422P12LE = 127 , AV_PIX_FMT_YUV422P14BE = 128 , AV_PIX_FMT_YUV422P14LE = 129 , AV_PIX_FMT_YUV444P12BE = 130 , AV_PIX_FMT_YUV444P12LE = 131 , AV_PIX_FMT_YUV444P14BE = 132 , AV_PIX_FMT_YUV444P14LE = 133 , AV_PIX_FMT_GBRP12BE = 134 , AV_PIX_FMT_GBRP12LE = 135 , AV_PIX_FMT_GBRP14BE = 136 , AV_PIX_FMT_GBRP14LE = 137 , AV_PIX_FMT_YUVJ411P = 138 , AV_PIX_FMT_BAYER_BGGR8 = 139 , AV_PIX_FMT_BAYER_RGGB8 = 140 , AV_PIX_FMT_BAYER_GBRG8 = 141 , AV_PIX_FMT_BAYER_GRBG8 = 142 , AV_PIX_FMT_BAYER_BGGR16LE = 143 , AV_PIX_FMT_BAYER_BGGR16BE = 144 , AV_PIX_FMT_BAYER_RGGB16LE = 145 , AV_PIX_FMT_BAYER_RGGB16BE = 146 , AV_PIX_FMT_BAYER_GBRG16LE = 147 , AV_PIX_FMT_BAYER_GBRG16BE = 148 , AV_PIX_FMT_BAYER_GRBG16LE = 149 , AV_PIX_FMT_BAYER_GRBG16BE = 150 , AV_PIX_FMT_XVMC = 151 , AV_PIX_FMT_YUV440P10LE = 152 , AV_PIX_FMT_YUV440P10BE = 153 , AV_PIX_FMT_YUV440P12LE = 154 , AV_PIX_FMT_YUV440P12BE = 155 , AV_PIX_FMT_AYUV64LE = 156 , AV_PIX_FMT_AYUV64BE = 157 , AV_PIX_FMT_VIDEOTOOLBOX = 158 , AV_PIX_FMT_P010LE = 159 , AV_PIX_FMT_P010BE = 160 , AV_PIX_FMT_GBRAP12BE = 161 , AV_PIX_FMT_GBRAP12LE = 162 , AV_PIX_FMT_GBRAP10BE = 163 , AV_PIX_FMT_GBRAP10LE = 164 , AV_PIX_FMT_MEDIACODEC = 165 , AV_PIX_FMT_GRAY12BE = 166 , AV_PIX_FMT_GRAY12LE = 167 , AV_PIX_FMT_GRAY10BE = 168 , AV_PIX_FMT_GRAY10LE = 169 , AV_PIX_FMT_P016LE = 170 , AV_PIX_FMT_P016BE = 171 , AV_PIX_FMT_D3D11 = 172 , AV_PIX_FMT_GRAY9BE = 173 , AV_PIX_FMT_GRAY9LE = 174 , AV_PIX_FMT_GBRPF32BE = 175 , AV_PIX_FMT_GBRPF32LE = 176 , AV_PIX_FMT_GBRAPF32BE = 177 , AV_PIX_FMT_GBRAPF32LE = 178 , AV_PIX_FMT_DRM_PRIME = 179 , AV_PIX_FMT_OPENCL = 180 , AV_PIX_FMT_GRAY14BE = 181 , AV_PIX_FMT_GRAY14LE = 182 , AV_PIX_FMT_GRAYF32BE = 183 , AV_PIX_FMT_GRAYF32LE = 184 , AV_PIX_FMT_YUVA422P12BE = 185 , AV_PIX_FMT_YUVA422P12LE = 186 , AV_PIX_FMT_YUVA444P12BE = 187 , AV_PIX_FMT_YUVA444P12LE = 188 , AV_PIX_FMT_NV24 = 189 , AV_PIX_FMT_NV42 = 190 , AV_PIX_FMT_VULKAN = 191 , AV_PIX_FMT_Y210BE = 192 , AV_PIX_FMT_Y210LE = 193 , AV_PIX_FMT_SAND128 = 194 , AV_PIX_FMT_SAND64_10 = 195 , AV_PIX_FMT_SAND64_16 = 196 , AV_PIX_FMT_RPI4_8 = 197 , AV_PIX_FMT_RPI4_10 = ...
    |       ^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ------------------         --------------------         --------------------         -----------------         ------------------ not covered
    |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |                          |                            |                            |
    |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |                          |                            |                            not covered
    |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |                          |                            not covered
    |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |                          not covered
    |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            not covered
    = note: the matched value is of type `sys::AVPixelFormat`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms
    |
824 ~             AV_PIX_FMT_GBRAP14LE => Pixel::GBRAP14LE,
825 ~             _ => todo!(),
    |

For more information about this error, try `rustc --explain E0004`.
error: could not compile `ffmpeg-next` (lib) due to 1 previous error
error: failed to compile `wl-screenrec v0.1.5`, intermediate artifacts can be found at `/tmp/cargo-installyH6KkV`.
russelltg commented 1 month ago

What is your ffmpeg version

russelltg commented 1 month ago

This seems to be a bug in ffmpeg-next, this should workaround it

diff --git a/Cargo.toml b/Cargo.toml
index 86bdc01..f7f7bb5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -27,7 +27,7 @@ wayland-protocols = { version = "0.32", features = [
     "staging",
 ] }
 wayland-protocols-wlr = { version = "0.3", features = ["client"] }
-ffmpeg-next = "7.0.1"
+ffmpeg-next = { version = "7.0.1", features=["rpi"] }
 ffmpeg-sys-next = "7.0.0" # need direct dep on -sys to get metadata to consume in build.rs
 thiserror = "1.0.38"
 human-size = "0.4.2"
1over137 commented 1 month ago

Thanks, it seems to have worked

hholst80 commented 3 weeks ago

I think I have a similar issue with ffmpeg-next:

# ffmpeg -v
ffmpeg version 7.0.2 Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 13.2.0 (GCC)
  configuration: --prefix=/usr --cpu=skylake
  libavutil      59.  8.100 / 59.  8.100
  libavcodec     61.  3.100 / 61.  3.100
  libavformat    61.  1.100 / 61.  1.100
  libavdevice    61.  1.100 / 61.  1.100
  libavfilter    10.  1.100 / 10.  1.100
  libswscale      8.  1.100 /  8.  1.100
  libswresample   5.  1.100 /  5.  1.100
Missing argument for option 'v'.
Error splitting the argument list: Invalid argument
root@xps ~/wl-screenrec (main)
# git status
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean
root@xps ~/wl-screenrec (main)
# git reflog 
269c189 (HEAD -> main, origin/main, origin/HEAD) HEAD@{0}: checkout: moving from main to main
269c189 (HEAD -> main, origin/main, origin/HEAD) HEAD@{1}: checkout: moving from daa9b176dffe74fa0c19607f9c2325dd4ad8910e to main
daa9b17 (tag: v0.1.5) HEAD@{2}: checkout: moving from main to v0.1.5
269c189 (HEAD -> main, origin/main, origin/HEAD) HEAD@{3}: pull: Fast-forward
e5e651c HEAD@{4}: clone: from https://github.com/russelltg/wl-screenrec.git
root@xps ~/wl-screenrec (main)
# cargo build --release
   Compiling ffmpeg-next v7.1.0
   Compiling wl-screenrec v0.1.5 (/root/wl-screenrec)
error[E0425]: cannot find value `AV_PKT_DATA_FRAME_CROPPING` in this scope
   --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ffmpeg-next-7.1.0/src/codec/packet/side_data.rs:202:37
    |
202 |             Type::FRAME_CROPPING => AV_PKT_DATA_FRAME_CROPPING,
    |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `AV_PKT_DATA_LCEVC` in this scope
    --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ffmpeg-next-7.1.0/src/codec/packet/side_data.rs:204:28
     |
204  |             Type::LCEVC => AV_PKT_DATA_LCEVC,
     |                            ^^^^^^^^^^^^^^^^^ help: a unit variant with a similar name exists: `AV_PKT_DATA_A53_CC`
     |
    ::: /root/wl-screenrec/target/release/build/ffmpeg-sys-next-6e05e3935ed5bb17/out/bindings.rs:6559:5
     |
6559 |     AV_PKT_DATA_A53_CC = 23,
     |     ------------------ similarly named unit variant `AV_PKT_DATA_A53_CC` defined here

For more information about this error, try `rustc --explain E0425`.
error: could not compile `ffmpeg-next` (lib) due to 2 previous errors

Huge caveat that I do not understand how Cargo.toml handles versions. The toml says "7.0.1" but the compile log references to "7.1.0"? Very confusing.

russelltg commented 3 weeks ago

That's strange--this seems like a bug in ffmpeg-sys. What distro are you on?

Re cargo versions: version constraings are "semver minimums" in that any semver compat version is OK. So, cargo is allowed to select 7.1 when I specify 7.0 but it's not allowed to select 8.0.

https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html if you're curious