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

feat: Hardware accelleration build options #94

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 10 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ build-lib-x265 = ["build"]
build-lib-avs = ["build"]
build-lib-xvid = ["build"]

build-hardcoded-tables = ["build"]

# hardware accelleration
build-nvidia-hwacc = ["build"]
build-videotoolbox = ["build"]
build-audiotoolbox = ["build"]
buid-vaapi = ["build"]
build-opencl = ["build"]
build-vulkan = ["build"]

# protocols
build-lib-smbclient = ["build"]
build-lib-ssh = ["build"]
Expand Down
49 changes: 49 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,23 @@ fn build() -> io::Result<()> {
configure.arg(format!("--target_os={}", get_ffmpet_target_os()));
}

// for ios specific hardware acceleration ffmpeg needs to find the frameworks
// and link against them using -framework
if env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("ios") {
let output = Command::new("xcrun")
.args(["--sdk", "iphoneos", "--show-sdk-path"])
.output()
.expect("failed to run xcrun")
.stdout;

configure.arg(format!(
"--sysroot={}",
str::from_utf8(&output)
.expect("Failed to parse xcrun output")
.trim()
));
}

// control debug build
if env::var("DEBUG").is_ok() {
configure.arg("--enable-debug");
Expand Down Expand Up @@ -348,6 +365,36 @@ fn build() -> io::Result<()> {
enable!(configure, "BUILD_LIB_AVS", "libavs");
enable!(configure, "BUILD_LIB_XVID", "libxvid");

// hardware accelleration
enable!(configure, "BUILD_VAAPI", "vaapi");
enable!(configure, "BUILD_VULKAN", "vdpau");
enable!(configure, "BUILD_OPENCL", "vaapi");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These look like typos

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah thanks, I should’ve made it as a draft cause I’m still experimenting with options


if env::var("CARGO_FEATURE_BUILD_VIDEOTOOLBOX").is_ok() {
configure.arg("--enable-videotoolbox");

if target != host && env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("ios") {
configure.arg("--extra-cflags=-mios-version-min=11.0");
}

if target != host && env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("macos") {
configure.arg("--extra-cflags=-mmacosx-version-min=10.11");
}
}

if env::var("CARGO_FEATURE_BUILD_AUDIOTOOLBOX").is_ok() {
configure.arg("--enable-audiotoolbox");
configure.arg("--extra-cflags=-mios-version-min=11.0");
}

if env::var("CARGO_FEATURE_BUILD_NVIDIA_HWACC").is_ok() {
configure.arg("--enable-cuda-nvcc");
configure.arg("--enable-cuvid");
configure.arg("--enable-nvenc");
configure.arg("--enable-nvdec");
configure.arg("--enable-libnpp");
}

// other external libraries
enable!(configure, "BUILD_LIB_DRM", "libdrm");
enable!(configure, "BUILD_NVENC", "nvenc");
Expand All @@ -359,6 +406,8 @@ fn build() -> io::Result<()> {
// configure misc build options
enable!(configure, "BUILD_PIC", "pic");

println!("{configure:#?}");

// run ./configure
let output = configure
.output()
Expand Down
Loading