Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solution for error in Windows: non-exhaustive patterns #154

Open
altunenes opened this issue Jul 8, 2023 · 7 comments
Open

solution for error in Windows: non-exhaustive patterns #154

altunenes opened this issue Jul 8, 2023 · 7 comments

Comments

@altunenes
Copy link

altunenes commented Jul 8, 2023

TL/DR: #155

First of all, thank you for this beautiful contribution. ❤️

I wanted to use rust-ffmpeg in one of my projects and it compiles on MAC without any problem. But when I try it on Windows 11 I get an error: 😢

error[E0004]: non-exhaustive patterns: sys::AVPixelFormat::AV_PIX_FMT_P212BE, sys::AVPixelFormat::AV_PIX_FMT_P212LE, sys::AVPixelFormat::AV_PIX_FMT_P412BE and 1 more not covered

error[E0004]: non-exhaustive patterns: sys::AVCodecID::AV_CODEC_ID_PDV sys::AVCodecID::AV_CODEC_ID_EVC, sys::AVCodecID::AV_CODEC_ID_RTV1 and 3 more not covered

I made the following implementations and my problem was solved: 🥳

src/util/format/pixel.rs

pub enum Pixel {

I updated the Pixel enum to include all possible pixel formats like so:

#[derive(Eq, PartialEq, Copy, Clone, Debug)]
pub enum Pixel {
    None,
    P212BE,
    P212LE,
    P412BE,
    P412LE,
    //others...
}

Then, I updated the implementation of From for Pixel and From for AVPixelFormat to include these new enumerations.

impl From<AVPixelFormat> for Pixel {
    #[inline]
    fn from(value: AVPixelFormat) -> Self {
        match value {
            AV_PIX_FMT_NONE => Pixel::None,
            AV_PIX_FMT_P212BE => Pixel::P212BE,
            AV_PIX_FMT_P212LE => Pixel::P212LE,
            AV_PIX_FMT_P412BE => Pixel::P412BE,
            AV_PIX_FMT_P412LE => Pixel::P412LE,
            //others...
        }
    }
}
impl From<Pixel> for AVPixelFormat {
    #[inline]
    fn from(value: Pixel) -> AVPixelFormat {
        match value {
            Pixel::None => AV_PIX_FMT_NONE,
            Pixel::P212BE => AV_PIX_FMT_P212BE,
            Pixel::P212LE => AV_PIX_FMT_P212LE,
            Pixel::P412BE => AV_PIX_FMT_P412BE,
            Pixel::P412LE => AV_PIX_FMT_P412LE,
            //others...
        }
    }
}

In the id.rs file, I updated the Id enum and did a similar update for the From for Id and From for AVCodecID implementations:
src/codec/id.rs

pub enum Id {

#[allow(non_camel_case_types)]
#[derive(Eq, PartialEq, Clone, Copy, Debug)]
pub enum Id {
    None,
    PDV,
    EVC,
    RTV1,

    VMIX,
    AC4,
    SMPTE2038,
    //others...
}

impl From<AVCodecID> for Id {
    fn from(value: AVCodecID) -> Self {
        match value {
            AV_CODEC_ID_NONE => Id::None,
            AV_CODEC_ID_PDV => Id::PDV,
            AV_CODEC_ID_EVC => Id::EVC,
            AV_CODEC_ID_RTV1 => Id::RTV1,

            AV_CODEC_ID_VMIX => Id::VMIX,
            AV_CODEC_ID_AC4 => Id::AC4,
            AV_CODEC_ID_SMPTE_2038 => Id::SMPTE2038,
            //others...
        }
    }
}

impl From<Id> for AVCodecID {
    fn from(value: Id) -> AVCodecID {
        match value {
            Id::None => AV_CODEC_ID_NONE,
            Id::PDV => AV_CODEC_ID_PDV,
            Id::EVC => AV_CODEC_ID_EVC,
            Id::RTV1 => AV_CODEC_ID_RTV1,

            Id::VMIX => AV_CODEC_ID_VMIX,
            Id::AC4 => AV_CODEC_ID_AC4,
            Id::SMPTE2038 => AV_CODEC_ID_SMPTE_2038,
            //others...
        }
    }
}

after these implementations, all is okay now
happy coding. 😸

@altunenes altunenes changed the title solution for error: failed to run custom build command for ffmpeg-sys-next v6.0.1 solution for error: failed to run custom build command for non-exhaustive patterns Jul 8, 2023
@altunenes altunenes changed the title solution for error: failed to run custom build command for non-exhaustive patterns solution for error: non-exhaustive patterns Jul 8, 2023
@altunenes altunenes changed the title solution for error: non-exhaustive patterns solution for error in Windows: non-exhaustive patterns Jul 8, 2023
@altunenes altunenes reopened this Jul 27, 2023
@thewh1teagle
Copy link

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

@Polochon-street
Copy link
Collaborator

Hi!

We just merged some things for ffmpeg 6.1 support - this should work for you now :)

We're always lagging behind a bit for new releases, so that explains why windows (whose build downloads automatically the latest ffmpeg version) sometimes fails to compile. Hopefully we fixed it!

@thewh1teagle
Copy link

@Polochon-street
Do you know if it's possible to statically link ffmpeg for windows in msys2 when using this library?
I have static libraries installed but it doesn't link them statically

@Polochon-street
Copy link
Collaborator

@thewh1teagle I remember it was a pain, and I'm not even sure I managed. It seems possible, but given that there all whole projects dedicated to that, I'm thinking shipping the dlls might be the easiest

@thewh1teagle
Copy link

thewh1teagle commented Jan 9, 2024

@Polochon-street
It has to be something with bindgen (build.rs)
I have the static build files of ffmpeg already, just need to make rust use them

@thewh1teagle
Copy link

thewh1teagle commented Jan 9, 2024

@Polochon-street
As I thought the problem with rust-ffmpeg-sys in this line build.rs#L654C52-L654C63.
It looks for .a files to link them but in windows it's .dll.a.
maybe related?

@altunenes
Copy link
Author

altunenes commented Mar 25, 2024

Thank you to both of you! <3 We migrated to GStreamer after encountering this specific issue, so I'm not certain if updating the version could resolve the error. :-(

Again, thank you for this beautiful repo and your time ❤️
(you can close this issue if you want: because I can't confirm if the latest update fix the issue :(( )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants