Skip to content

Commit

Permalink
xtask: add pkg-config support to nvidia build-ffmpeg-linux subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
ckiee committed Jan 11, 2022
1 parent 5a33290 commit 523eebf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions alvr/xtask/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ alvr_filesystem = { path = "../filesystem" }
fs_extra = "1"
pico-args = "0.4"
walkdir = "2"
pkg-config = "0.3.9"
20 changes: 17 additions & 3 deletions alvr/xtask/src/dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub fn build_ffmpeg_linux(nvenc_flag: bool) -> std::path::PathBuf {
"--disable-network",
"--enable-lto",
format!(
"--disable-everything {} {} {} {} {} {}",
"--disable-everything {} {} {} {} {}",
/*
Describing Nvidia specific options --nvccflags:
nvcc from CUDA toolkit version 11.0 or higher does not support compiling for 'compute_30' (default in ffmpeg)
Expand All @@ -106,11 +106,25 @@ pub fn build_ffmpeg_linux(nvenc_flag: bool) -> std::path::PathBuf {
Nvidia docs:
https://docs.nvidia.com/video-technologies/video-codec-sdk/ffmpeg-with-nvidia-gpu/#commonly-faced-issues-and-tips-to-resolve-them
*/
(if nvenc_flag {"--enable-encoder=h264_nvenc --enable-encoder=hevc_nvenc --enable-nonfree --enable-cuda-nvcc --enable-libnpp --nvccflags=\"-gencode arch=compute_52,code=sm_52 -O2\" --extra-cflags=-I/usr/local/cuda/include/ --extra-ldflags=-L/usr/local/cuda/lib64/"} else {""}),
(if nvenc_flag {
let cuda = pkg_config::Config::new().probe("cuda").unwrap();
let include_flags = cuda.include_paths
.iter()
.map(|path| format!("-I{:?}", path))
.reduce(|a, b| { format!("{}{}", a, b) })
.expect("pkg-config cuda entry to have include-paths");
let link_flags = cuda.link_paths
.iter()
.map(|path| format!("-L{:?}", path))
.reduce(|a, b| { format!("{}{}", a, b) })
.expect("pkg-config cuda entry to have link-paths");

format!("--enable-encoder=h264_nvenc --enable-encoder=hevc_nvenc --enable-nonfree --enable-cuda-nvcc --enable-libnpp --nvccflags=\"-gencode arch=compute_52,code=sm_52 -O2\" --extra-cflags=\"{}\" --extra-ldflags=\"{}\" --enable-hwaccel=h264_nvenc --enable-hwaccel=hevc_nvenc",
include_flags, link_flags)
} else {"".to_string()}),
"--enable-encoder=h264_vaapi --enable-encoder=hevc_vaapi",
"--enable-encoder=libx264 --enable-encoder=libx264rgb --enable-encoder=libx265",
"--enable-hwaccel=h264_vaapi --enable-hwaccel=hevc_vaapi",
(if nvenc_flag {"--enable-hwaccel=h264_nvenc --enable-hwaccel=hevc_nvenc"} else {""}),
"--enable-filter=scale --enable-filter=scale_vaapi",
),
"--enable-libx264 --enable-libx265 --enable-vulkan",
Expand Down

0 comments on commit 523eebf

Please sign in to comment.