larksuite / rsmpeg

A Rust crate that exposes FFmpeg's power as much as possible.
https://docs.rs/rsmpeg/latest/rsmpeg/
MIT License
668 stars 40 forks source link

Static link ffmpeg #140

Open thewh1teagle opened 10 months ago

thewh1teagle commented 10 months ago

How can I statically link ffmpeg into executable when compiling in windows inside msys2 ucrt64? (windows-gnu rustc)

ldm0 commented 10 months ago

You can check this: https://github.com/CCExtractor/rusty_ffmpeg?tab=readme-ov-file#fine-grained-usage. In short, set FFMPEG_PKG_CONFIG_PATH if you have pkg-config files; set FFMPEG_LIBS_DIR + FFMPEG_INCLUDE_DIR vise versa.

thewh1teagle commented 10 months ago

@ldm0 I'm not sure where I can find ready to use statically linked ffmpeg libraries, and if I should compile it (maybe it will take long time to compile...) Did you tried it in msys2?

ldm0 commented 10 months ago

@ldm0 I'm not sure where I can find ready to use statically linked ffmpeg libraries and if I should compile it.

It's not recommended to use prebuilt statically linked FFmpeg libraries due to the verbosity of build options and license issues(usage of different build options result in libraries with different open source licenses). You should compile it locally and tweak the build options according to your project requirements.

(maybe it will take long time to compile...)

People only need to compile FFmpeg once as long as they don't change FFmpeg source code & version. BTW, FFmpeg compilation won't take that long time if you have disable the artifacts you don't want.

Did you tried it in msys2?

Nope. I compile FFmpeg for Windows with MinGW. But it should work fine as rsmpeg only needs to link the final static libraries.

Here are some references you may need to compile FFmpeg with MSYS2

  1. https://trac.ffmpeg.org/wiki/CompilationGuide/MinGW#Option2:MSYS2
  2. https://gist.github.com/crossle/43e356468d160902f03ffd25d6a045ba

Feel free to file an issue here if you encounter any problem.