rust-ffmpeg icon indicating copy to clipboard operation
rust-ffmpeg copied to clipboard

ffmpeg-next won't build on windows. Non exhaustive patterns.

Open ThatNerdUKnow opened this issue 3 years ago • 7 comments

OS: Windows 10 Ffmpeg version: ffmpeg-master-latest-win64-gpl-shared. 12/24/2022

I followed the installation guide from the wiki for building on windows. I have downloaded the latest ffmpeg windows build and set the FFMPEG_DIR variable accordingly.

I get the following error when building my project that depends on ffmpeg-next in windows. This project compiles just fine in linux

cargo build
    Blocking waiting for file lock on build directory
   Compiling ffmpeg-next v5.1.1
error[E0004]: non-exhaustive patterns: `sys::AVPixelFormat::AV_PIX_FMT_VUYA`, `sys::AVPixelFormat::AV_PIX_FMT_RGBAF16BE`, `sys::AVPixelFormat::AV_PIX_FMT_RGBAF16LE` and 13 more not covered
    --> C:\Users\brand\.cargo\registry\src\github.com-1ecc6299db9ec823\ffmpeg-next-5.1.1\src\util\format\pixel.rs:434:15
     |
434  |         match value {
     |               ^^^^^ patterns `sys::AVPixelFormat::AV_PIX_FMT_VUYA`, `sys::AVPixelFormat::AV_PIX_FMT_RGBAF16BE`, `sys::AVPixelFormat::AV_PIX_FMT_RGBAF16LE` and 13 more not covered
     |
note: `sys::AVPixelFormat` defined here
    --> C:\Users\brand\repos\libvmaf-rs\target\debug\build\ffmpeg-sys-next-f6d84f95db8b1f08\out/bindings.rs:4792:1
     |
4792 | pub enum AVPixelFormat {
     | ^^^^^^^^^^^^^^^^^^^^^^
     = 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
     |
731  ~             AV_PIX_FMT_P416LE => Pixel::P416LE,
732  ~             _ => todo!(),
     |

error[E0004]: non-exhaustive patterns: `sys::AVCodecID::AV_CODEC_ID_RADIANCE_HDR`, `sys::AVCodecID::AV_CODEC_ID_WBMP`, `sys::AVCodecID::AV_CODEC_ID_MEDIA100` and 5 more not covered
    --> C:\Users\brand\.cargo\registry\src\github.com-1ecc6299db9ec823\ffmpeg-next-5.1.1\src\codec\id.rs:633:15
     |
633  |         match value {
     |               ^^^^^ patterns `sys::AVCodecID::AV_CODEC_ID_RADIANCE_HDR`, `sys::AVCodecID::AV_CODEC_ID_WBMP`, `sys::AVCodecID::AV_CODEC_ID_MEDIA100` and 5 more not covered
     |
note: `sys::AVCodecID` defined here
    --> C:\Users\brand\repos\libvmaf-rs\target\debug\build\ffmpeg-sys-next-f6d84f95db8b1f08\out/bindings.rs:8866:1
     |
8866 | pub enum AVCodecID {
     | ^^^^^^^^^^^^^^^^^^
     = note: the matched value is of type `sys::AVCodecID`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms
     |
1235 ~             AV_CODEC_ID_DFPWM => Id::DFPWM,
1236 ~             _ => todo!(),
     |

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

ThatNerdUKnow avatar Dec 25 '22 05:12 ThatNerdUKnow

It seems that the following enums were missing some match arms. I've cloned this repo and had my editor automatically generate the missing match arms:

This compiler error doesn't seem to affect linux builds.

impl<From<AVPixelFormat> for Pixel{
// Current match arms elided
            AV_PIX_FMT_VUYA => todo!(),
            AV_PIX_FMT_RGBAF16BE => todo!(),
            AV_PIX_FMT_RGBAF16LE => todo!(),
            AV_PIX_FMT_VUYX => todo!(),
            AV_PIX_FMT_P012LE => todo!(),
            AV_PIX_FMT_P012BE => todo!(),
            AV_PIX_FMT_Y212BE => todo!(),
            AV_PIX_FMT_Y212LE => todo!(),
            AV_PIX_FMT_XV30BE => todo!(),
            AV_PIX_FMT_XV30LE => todo!(),
            AV_PIX_FMT_XV36BE => todo!(),
            AV_PIX_FMT_XV36LE => todo!(),
            AV_PIX_FMT_RGBF32BE => todo!(),
            AV_PIX_FMT_RGBF32LE => todo!(),
            AV_PIX_FMT_RGBAF32BE => todo!(),
            AV_PIX_FMT_RGBAF32LE => todo!(),
}
impl From<AVCodecID> for Id{
// Current match arms elided
            AV_CODEC_ID_RADIANCE_HDR => todo!(),
            AV_CODEC_ID_WBMP => todo!(),
            AV_CODEC_ID_MEDIA100 => todo!(),
            AV_CODEC_ID_VQC => todo!(),
            AV_CODEC_ID_BONK => todo!(),
            AV_CODEC_ID_MISC4 => todo!(),
            AV_CODEC_ID_APAC => todo!(),
            AV_CODEC_ID_FTR => todo!(),
}

Could this be a matter of creating enum variants for Pixel and Id like so?

pub enum Pixel{
// Current variants elided
#[cfg(target_os = "windows")]
YUVA
}

and then the following match arms in the From implementations?

impl From<AVPixelFormat> for Pixel{
// Current match arms elided
#[cfg(target_os = "windows")]
 AV_PIX_FMT_VUYA => Pixel::YUVA,
}

Also if it's relevant, my installed version of ffmpeg is ffmpeg version 4.2.3

ThatNerdUKnow avatar Jan 22 '23 21:01 ThatNerdUKnow

happens for me too, should I just build it on linux from now on?

fooeyround avatar Jul 25 '23 20:07 fooeyround

I can build it outside of the other crate on windows, but that crate won't compile....

fooeyround avatar Jul 25 '23 20:07 fooeyround

my issue seems to be with

----------------------
...
4587 |     AV_PIX_FMT_P212BE = 222,
     |     ^^^^^^^^^^^^^^^^^ not covered
4588 |     #[doc = "< interleaved chroma YUV 4:2:2, 24bpp, data in the high bits, little-endian"]
4589 |     AV_PIX_FMT_P212LE = 223,
     |     ^^^^^^^^^^^^^^^^^ not covered
4590 |     #[doc = "< interleaved chroma YUV 4:4:4, 36bpp, data in the high bits, big-endian"]
4591 |     AV_PIX_FMT_P412BE = 224,
     |     ^^^^^^^^^^^^^^^^^ not covered
4592 |     #[doc = "< interleaved chroma YUV 4:4:4, 36bpp, data in the high bits, little-endian"]
4593 |     AV_PIX_FMT_P412LE = 225,

fooeyround avatar Jul 25 '23 21:07 fooeyround

It seems to not like to build in its dev env, not knowing the things that are missing, but works when the branches are added and just used in another crate. Is this a quirk of how rust bindings work?

fooeyround avatar Jul 26 '23 03:07 fooeyround

(I probably missed something when adding them (may be feature flag stuff.))

fooeyround avatar Jul 26 '23 03:07 fooeyround

It's related to what version of ffmpeg library you use. Currently ffmpeg-next supported FFmpeg versions: 3.4.x through 4.4.x.

thewh1teagle avatar Jan 09 '24 20:01 thewh1teagle