cunarist / rinf

Rust for native business logic, Flutter for flexible and beautiful GUI
MIT License
1.88k stars 65 forks source link

With ffmpeg crate, Failed to load dynamic library 'hub.dll' #310

Closed J-Mook closed 5 months ago

J-Mook commented 5 months ago

Report

image

I'm making windows desktop app using ffmpeg crate.

Excately there is "hub.dll" with compiled .exe file

Steps to Reproduce

I added ffmpeg-next = "6.1.1" at \native\hub\Cargo.toml to use ffmpeg.

Cargo.toml

ffmpeg-next = "6.1.1" 

when i use ffmpeg-next crate, above problem which load fail hub.dll. For example just (Example Code for using ffmpeg-next)

extern crate ffmpeg_next as ffmpeg;
let _ = ffmpeg::init();

just remove which using ffmpeg code, the error would disappear.

System Information

rustc --version
rustc 1.76.0 (07dca489a 2024-02-04)

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.19.2, on Microsoft Windows [Version 10.0.19045.4170], locale ko-KR)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[X] Android toolchain - develop for Android devices
    X Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.

[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.7.4)
[!] Android Studio (not installed)
[√] VS Code (version 1.87.2)
[√] Connected device (3 available)
[√] Network resources

! Doctor found issues in 2 categories.
temeddix commented 5 months ago

Hi, I'm trying to reproduce the error, but it looks like ffmpeg-next requires some specific system librareis.

  thread 'main' panicked at C:\Users\temed\.cargo\registry\src\index.crates.io-6f17d22bba15001f\ffmpeg-sys-next-6.1.0\build.rs:734:22:
  called `Result::unwrap()` on an `Err` value:
  pkg-config exited with status code 1
  > PKG_CONFIG_PATH=C:\cfg PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 pkg-config --libs --cflags libavformat

  The system library `libavformat` required by crate `ffmpeg-sys-next` was not found.
  The file `libavformat.pc` needs to be installed and the PKG_CONFIG_PATH environment variable must contain its parent directory.
  PKG_CONFIG_PATH contains the following:
      - C
      - \cfg

  HINT: you may need to install a package such as libavformat, libavformat-dev or libavformat-devel.

  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I'm on Windows 11 just like you. Could you describe how you installed ffmpeg system libraries for me?

J-Mook commented 5 months ago

if vcpkg installed on you, Only need following code. vcpkg install ffmpeg --triplet=x64-windows

(maybe installing with around 30 min)

After installed ffmpeg to use vcpkg, if appear the following error, you can install MSYS2 and following gcc compiler

Unable to find libclang: "couldn't find any valid shared libraries matching: ['clang.dll', 'libclang.dll'], set the `LIBCLANG_PATH` environment variable to a path where one of these files can be found (invalid: [])"
pacman -S mingw-w64-i686-gcc
pacman -S mingw-w64-x86_64-gcc

I also tried tons of thing to solve installing ffempg problem. it could be not working on your computer.

if not working these solutions, i can say more options to install ffmpeg

J-Mook commented 5 months ago

I find the solution!!!

the error is generated at load_as.dart>>loadRustLibrary() function.

the function can find hub.dll, but can't find other dll which related ffmpeg.

/avcodec-60.dll 
/avdevice-60.dll 
/avfilter-9.dll 
/avformat-60.dll 
/avutil-58.dll 
/swresample-4.dll 
/swscale-7.dll

located at (Path to ffmpeg)\ffmpeg_x64-windows\bin

So, you can solve this error by putting the above dll file in the exe file location (e.g. \build\windows\x64\runner\Debug).

temeddix commented 5 months ago

Congratulations! Thank you so much for sharing the info :)