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

Added vcpkg build guide in the readme #120

Merged
merged 3 commits into from
Sep 7, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,60 @@ These scripts build latest stable FFmpeg by default. You can build specific FFmp
zsh utils/mac_ffmpeg.rs release/5.0
```

### Compiling FFmpeg through cargo-vcpkg

Using [vcpkg](https://github.com/microsoft/vcpkg) to manage ffmpeg dependencies may be easier as all the configuration is included in your `Cargo.toml`.
This is especially handy for users who download your project as they can build all necessary dependencies by running a single command.
Care that by using this method building ffmpeg may take a lot of time, although after the first time the generated libraries files may be cached.
aegroto marked this conversation as resolved.
Show resolved Hide resolved

To begin, install the [cargo-vcpkg](https://github.com/mcgoo/cargo-vcpkg) tool:

```bash
cargo install cargo-vcpkg
```

Add vcpkg dependencies:

```rust
[package.metadata.vcpkg]
dependencies = ["ffmpeg"]
git = "https://github.com/microsoft/vcpkg"
rev = "4a600e9" // Although it is possible to link to the master branch of vcpkg, it may be better to fix a specific revision in order to avoid unwanted breaking changes.
```


You may want to specify a subset of features based on the modules of FFmpeg you need. For instance, if your code makes use of x264 and VPX codecs the dependency should look like:

```rust
dependencies = ["ffmpeg[x264,vpx]"]
```

In some cases you may need to specify the triplet and/or additional dependencies. For instance, on Windows the above section would look similar to the following:

```rust
[package.metadata.vcpkg]
dependencies = ["ffmpeg[x264,vpx]:x64-windows-static-md"]
git = "https://github.com/microsoft/vcpkg"
rev = "4a600e9"
```

The features may vary depending on your application, in our case to build the demo we need x264.

Setup the environment:

```bash
export FFMPEG_PKG_CONFIG_PATH=${PWD}/target/vcpkg/packages/ffmpeg_x64-linux/lib/pkgconfig
```

Run the vcpkg build:
```bash
cargo vcpkg --verbose build
```
The `--verbose` option is not mandatory but may help to recognize any error in case the build fails.

After those steps you are able to build and run your project. A full working example with the demo code presented in the next section is available at https://github.com/aegroto/rsmpeg-vcpkg-demo.


### Rsmpeg demo

Ensure that you have compiled the FFmpeg.
Expand Down
Loading