Giter Club home page Giter Club logo

rust-ffmpeg-sys's Introduction

ffmpeg-sys-next on crates.io build

This is a fork of the abandoned ffmpeg-sys crate. You can find this crate as ffmpeg-sys-next on crates.io.

This crate contains low level bindings to FFmpeg. You're probably interested in the high level bindings instead: ffmpeg-next.

A word on versioning: major and minor versions track major and minor versions of FFmpeg, e.g. 4.2.x of this crate has been updated to support the 4.2.x series of FFmpeg. Patch level is reserved for bug fixes of this crate and does not track FFmpeg patch versions.

Feature flags

In addition to feature flags declared in Cargo.toml, this crate performs various compile-time version and feature detections and exposes the results in additional flags. These flags are briefly documented below; run cargo build -vv to view more details.

  • ffmpeg_<x>_<y> flags (new in v4.3.2), e.g. ffmpeg_4_4, indicating the FFmpeg installation being compiled against is at least version <x>.<y>. Currently available:

    • ffmpeg_3_0
    • ffmpeg_3_1
    • ffmpeg_3_2
    • ffmpeg_3_3
    • ffmpeg_3_1
    • ffmpeg_4_0
    • ffmpeg_4_1
    • ffmpeg_4_2
    • ffmpeg_4_3
    • ffmpeg_4_4
  • avcodec_version_greater_than_<x>_<y> (new in v4.3.2), e.g., avcodec_version_greater_than_58_90. The name should be self-explanatory.

  • ff_api_<feature>, e.g. ff_api_vaapi, corresponding to whether their respective uppercase deprecation guards evaluate to true.

  • ff_api_<feature>_is_defined, e.g. ff_api_vappi_is_defined, similar to above except these are enabled as long as the corresponding deprecation guards are defined.

rust-ffmpeg-sys's People

Contributors

0xd34d10cc avatar adrianeddy avatar ajsyp avatar andidog avatar animeavi avatar attackgoat avatar bacek avatar ciuncan avatar ebarnard avatar ereichert avatar fengalin avatar freezylemon avatar geovex avatar hatzel avatar inrustwetrust avatar kornelski avatar kryptan avatar lummax avatar mbrubeck avatar meh avatar panicbit avatar pkubaj avatar polochon-street avatar retrry avatar shssoichiro avatar stephaneyfx avatar wictory avatar zmwangx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

rust-ffmpeg-sys's Issues

Trouble building on target `i686-pc-windows-msvc`

On trying to setup with windows, the following error is observed

EXEC : error : failed to run custom build command forffmpeg-sys-next v5.0.1`

The actual error is

thread 'main' panicked at called Option::unwrap() on a None value, C:\..\ffmpeg-sys-next-5.0.1\build.rs:210:46

The error originated when the compilation was done with the build feature

I observed this error as part of a continuous integration build fail on windows.

url: https://github.com/CCExtractor/ccextractor/runs/7147475795?check_suite_focus=true

wasm-pack build Err

HI,guys,i try to use this crate with wasm-pack,when i run wasm-pack build,i got err like below:


--- stdout
cargo:rerun-if-env-changed=LIBAVUTIL_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_wasm32-unknown-unknown
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_wasm32_unknown_unknown
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
cargo:rerun-if-env-changed=PKG_CONFIG_wasm32-unknown-unknown
cargo:rerun-if-env-changed=PKG_CONFIG_wasm32_unknown_unknown
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_wasm32-unknown-unknown
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_wasm32_unknown_unknown
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

--- stderr
thread 'main' panicked at 'called Result::unwrap() on an Err value: CrossCompilation', /Users/niugm/.cargo/registry/src/github.com-1ecc6299db9ec823/ffmpeg-sys-next-4.3.5/build.rs:700:14
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
Error: Compiling your crate to WebAssembly failed
Caused by: failed to execute cargo build: exited with exit code: 101
full command: "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown"

Issue related to building in RISC-V

I've encountered an error in building the ffmpeg-next crate. When running the build function, the env::var("CARGO_CFG_TARGET_ARCH").unwrap() function at line 214 in build.rs file return riscv64gc-unknown-linux-gnu which is a wrong RISC-V arch name. It should return riscv64-unknown-linux-gnu.

I try to fix this issue like below. But I found that I have to change multiple dependencies to build the final program. It will be easier to fix this bug in upstream.

--- B/build.rs	2021-12-11 15:28:22.479878768 +0800
+++ A/build.rs	2021-12-11 15:28:17.586545306 +0800
@@ -211,9 +211,13 @@
         let prefix = compiler[0..suffix_pos].trim_end_matches("-wr"); // "wr-c++" compiler
 
         configure.arg(format!("--cross-prefix={}-", prefix));
+        let arch_arg = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
         configure.arg(format!(
-            "--arch={}",
-            env::var("CARGO_CFG_TARGET_ARCH").unwrap()
+            "--arch={}", if arch_arg == "riscv64gc-unknown-linux-gnu" {
+                String::from("riscv64-unknown-linux-gnu")
+            } else {
+                arch_arg
+            }
         ));
         configure.arg(format!(
             "--target_os={}",

ffmpeg-sys-next depends version of bindgen

I want to use ffmpeg-next,but its dependencies version conflict. Because the version which of ffmpeg-sys-next depends bindgen is 0.54.0 it load clang-sys mode version is too Low. Do you have any good suggestions?

build error:
error: failed to select a version for clang-sys. ... required by package bindgen v0.54.0... which is depended on byffmpeg-sys-next v4.4.0... which is depended on byffmpeg-next v4.4.0... which is depended on byffmpeg v0.1.0 ... which is depended on bydaas v1.1.8 versions that meet the requirements^0.29` are: 0.29.3, 0.29.2, 0.29.1, 0.29.0

the package clang-sys links to the native library clang, but it conflicts with a previous package which links to clang as well:
package clang-sys v1.0.0
... which is depended on by bindgen v0.59.0
... which is depended on by magnum-opus v0.3.4-2
... which is depended on by daas v1.1.8

failed to select a version for clang-sys which could resolve this conflict`

Code won't compile on Raspberry Pi 4 system ffmpeg

The error is connected with:

error[E0425]: cannot find value `AV_PIX_FMT_RPI` in this scope
    --> /root/.cargo/registry/src/github.com-1285ae84e5963aae/ffmpeg-next-5.1.1/src/util/format/pixel.rs:1114:27
     |
1114 |             Pixel::RPI => AV_PIX_FMT_RPI,
     |                           ^^^^^^^^^^^^^^ help: a unit variant with a similar name exists: `AV_PIX_FMT_0RGB`

The only place in internet where AV_PIX_FMT_RPI is mentioned is here: https://github.com/shantigilbert/Embylogic/blob/master/packages/multimedia/ffmpeg/patches/rpi4-hevc/ffmpeg-001-pfcd_hevc_optimisations.patch

May be it is not a vanilla ffmpeg?

Static link on windows still depends on DLLs

I created simple project which uses ffmpeg-next and compiled it on windows with static feature
no special environment - using msvc and normal rust installation on Windows 11.
It successufly compile and link it staticlly, but eventually when I run the program it still throw error if the DLLs are not in the same directory

image

The simple repo here thewh1teagle/ffmpeg-next-msvc-static

Consider creating bindings with rustified_non_exhaustive_enum

Consider using rustified_non_exhaustive_enum instead of the currently used

.rustified_enum("*")

The Rust docs have a good explanation of what this does, but the most important part is:

// Cannot match on a non-exhaustive enum without including a wildcard arm.
match error {
  Error::Message(ref s) => { },
  Error::Other => { },
  // would compile with: `_ => {},`
}

This would mean all dependent code (including ffmpeg-next) would be required to use a wildcard arm when matching against an enum create from the FFmpeg header files.

Motivation for this:
Currently, building ffmpeg-next can fail if you compile and install FFmpeg from git. The upstream header files might be updated with new enum values which will cause issues because ffmpeg-next uses pattern matching on multiple enums, and as soon as ffmpeg-next-sys creates the bindings with new enum values, these match statements will not be exhaustive anymore and fail to compile:
https://cdn.discordapp.com/attachments/697086935763779666/1028476266220888144/unknown.png (image shamelessly stolen from a discord server where this issue happened)

This is a big problem especially on Arch-based (and other) distros which make building and installing directly from git repositories simple.

Cannot get enum variant from name

Hi!

I'm trying to use following helper functions to retrieve enum values from strings, but they return the enum discriminants instead:

pub fn av_color_range_from_name(name: *const libc::c_char) -> libc::c_int; // should return the AVColorRange
pub fn av_color_primaries_from_name(name: *const libc::c_char) -> libc::c_int; // should return the AVColorPrimaries
pub fn av_color_transfer_from_name(name: *const libc::c_char) -> libc::c_int; // should return the AVColorTransferCharacteristic
pub fn av_color_space_from_name(name: *const libc::c_char) -> libc::c_int; // should return the AVColorSpace
pub fn av_chroma_location_from_name(name: *const libc::c_char) -> libc::c_int; // should return the AVChromaLocation
pub fn av_stereo3d_from_name(name: *const libc::c_char) -> libc::c_int; // should return the AVStereo3DType
// maybe more...

Moreover, there is no simple way to retrieve the enum variant from the discriminant in Rust.

Would it be possible to fix these functions?

Thanks!

Building fails on MSYS2

I've tried compiling this library on Windows, then WSL, then back to Windows with MSYS2,

  • I generated some .pc files with vcpkg and pointed them with $PKG_CONFIG_PATH

  • For good measure I also got a shared build of ffmpeg 4.4 and pointed with $FFMPEG_DIR

As I troubleshooted this error came around, it looks very odd for some clang library to not find that header, even after I added the directory where mm_malloc.h is to PATH

--- stderr
D:/Scoop/apps/msys2/2023-10-26/mingw64/include/malloc.h:84:10: fatal error: 'mm_malloc.h' file not found
D:/Scoop/apps/msys2/2023-10-26/mingw64/include/malloc.h:84:10: fatal error: 'mm_malloc.h' file not found, err: true
thread 'main' panicked at C:\Users\Dek\.cargo\registry\src\index.crates.io-6f17d22bba15001f\ffmpeg-sys-next-4.4.0\build.rs:1265:10:
Unable to generate bindings: ()
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I'd appreciate if you could suggest other installation steps I should take or if there are any libraries that could replace this library for this usecase, thank you

FreeBSD Compilation errored by pkg-config

# cargo test
   Compiling ring v0.16.20
   Compiling rustls v0.20.6
   Compiling zstd-safe v4.1.6+zstd.1.5.2
   Compiling zstd-sys v1.6.3+zstd.1.5.2
   Compiling blake3 v1.3.1
   Compiling ffmpeg-sys-next v5.0.1
error: failed to run custom build command for `ffmpeg-sys-next v5.0.1`

Caused by:
  process didn't exit successfully: `/usr/local/ruforo/target/debug/build/ffmpeg-sys-next-b8cd01aafd053925/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=LIBAVUTIL_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-freebsd
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_freebsd
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-freebsd
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_freebsd
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-freebsd
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_freebsd
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-freebsd
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_freebsd
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

  --- stderr
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Could not run `"pkg-config" "--libs" "--cflags" "libavutil"`
  The pkg-config command could not be found.

  Most likely, you need to install a pkg-config package for your OS.
  Try `apt install pkg-config`, or `yum install pkg-config`,
  or `pkg install pkg-config` depending on your distribution.

  If you've already installed it, ensure the pkg-config command is one of the
  directories in the PATH environment variable.

  If you did not expect this build to link to a pre-installed system library,
  then check documentation of the ffmpeg-sys-next crate for an option to
  build the library from source, or disable features or dependencies
  that require pkg-config.', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/ffmpeg-sys-next-5.0.1/build.rs:711:14
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

The issue is that pkg-config has not existed in BSD for supposedly 10 years. The work around is here:
https://forums.freebsd.org/threads/port-pkg-config-deleted-no-alternative.65273/

I'm not sure if this can be dealt with by the crate, but it would be nice if it could.

dynamic link ffmpeg .lib error

I want to build this crate through dynamic link ffmpeg lib. but its error and no detailed error message. I set FFMPEG_DIR Path and make
statik false. What should I do?

error: could not find system library 'libavutil' required by the 'ffmpeg-sys-next' crate

in this project Neothesia, it uses ffmpeg-sys-next v6.0.1 in MacBook. when i build this project in Windows 10 Msy2, i check that i had ffmpeg installed:

$ uname -a
MINGW64_NT-10.0-19045 LAPTOP-68ARNRIN 3.4.8.x86_64 2023-08-18 23:11 UTC x86_64 Msys
$ ffmpeg -version
ffmpeg version 5.1.2-essentials_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 12.1.0 (Rev2, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2
--enable-gmp --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265
--enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable
-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libgme --e
nable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --ena
ble-libspeex --enable-libvorbis --enable-librubberband
libavutil      57. 28.100 / 57. 28.100
libavcodec     59. 37.100 / 59. 37.100
libavformat    59. 27.100 / 59. 27.100
libavdevice    59.  7.100 / 59.  7.100
libavfilter     8. 44.100 /  8. 44.100
libswscale      6.  7.100 /  6.  7.100
libswresample   4.  7.100 /  4.  7.100
libpostproc    56.  6.100 / 56.  6.100

but when i cargo build it comes this error:

error: failed to run custom build command for `ffmpeg-sys-next v6.0.1`

Caused by:
  process didn't exit successfully: `D:\msys64\home\GitNeothesiaMsys2\target\release\build\ffmpeg-sys-next-c2b1a5f8f6e8bbe1\build-script-build` (exit code: 101)
  --- stdout
  cargo:rerun-if-env-changed=LIBAVUTIL_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-pc-windows-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_pc_windows_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-pc-windows-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_pc_windows_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-pc-windows-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_pc_windows_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-pc-windows-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_pc_windows_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

  --- stderr
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: `"pkg-config" "--libs" "--cflags" "libavutil"` did not exit successfully: exit code: 1
  error: could not find system library 'libavutil' required by the 'ffmpeg-sys-next' crate

  --- stderr
  Package libavutil was not found in the pkg-config search path.
  Perhaps you should add the directory containing `libavutil.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'libavutil' found

how can i install ffmpeg-sys-next v6.0.1 accurately?

CARGO_FEATURE_BUILD is not work

CARGO_FEATURE_BUILD is not work, and report error by follow:

/mnt/data/wangyi/playground/target/debug/build/ffmpeg-sys-next-bb692d632fc7662f/out/dist/lib/libavfilter.a(asrc_sinc.o): In function config_output': /mnt/data/wangyi/playground/target/debug/build/ffmpeg-sys-next-bb692d632fc7662f/out/ffmpeg-4.4/libavfilter/asrc_sinc.c:399: undefined reference to av_rdft_end'
/mnt/data/wangyi/playground/target/debug/build/ffmpeg-sys-next-bb692d632fc7662f/out/ffmpeg-4.4/libavfilter/asrc_sinc.c:400: undefined reference to av_rdft_end' /mnt/data/wangyi/playground/target/debug/build/ffmpeg-sys-next-bb692d632fc7662f/out/dist/lib/libavfilter.a(asrc_sinc.o): In function fir_to_phase':
/mnt/data/wangyi/playground/target/debug/build/ffmpeg-sys-next-bb692d632fc7662f/out/ffmpeg-4.4/libavfilter/asrc_sinc.c:238: undefined reference to av_rdft_end' /mnt/data/wangyi/playground/target/debug/build/ffmpeg-sys-next-bb692d632fc7662f/out/ffmpeg-4.4/libavfilter/asrc_sinc.c:239: undefined reference to av_rdft_end'
/mnt/data/wangyi/playground/target/debug/build/ffmpeg-sys-next-bb692d632fc7662f/out/ffmpeg-4.4/libavfilter/asrc_sinc.c:241: undefined reference to `av_rdft_init'
...

can't find a const val AV_CODEC_CAP_ENCODER_RECON_FRAME

here is my code:
`use bitflags::bitflags;
use crate::ffi::*;
use libc::c_uint;

bitflags! {
pub struct Capabilities: c_uint {
const DRAW_HORIZ_BAND = AV_CODEC_CAP_DRAW_HORIZ_BAND;
const DR1 = AV_CODEC_CAP_DR1;
const DELAY = AV_CODEC_CAP_DELAY;
const SMALL_LAST_FRAME = AV_CODEC_CAP_SMALL_LAST_FRAME;
const SUBFRAMES = AV_CODEC_CAP_SUBFRAMES;
const EXPERIMENTAL = AV_CODEC_CAP_EXPERIMENTAL;
const CHANNEL_CONF = AV_CODEC_CAP_CHANNEL_CONF;
const FRAME_THREADS = AV_CODEC_CAP_FRAME_THREADS;
const SLICE_THREADS = AV_CODEC_CAP_SLICE_THREADS;
const PARAM_CHANGE = AV_CODEC_CAP_PARAM_CHANGE;
const OTHER_THREADS = AV_CODEC_CAP_OTHER_THREADS;
const VARIABLE_FRAME_SIZE = AV_CODEC_CAP_VARIABLE_FRAME_SIZE;
const AVOID_PROBING = AV_CODEC_CAP_AVOID_PROBING;
const HARDWARE = AV_CODEC_CAP_HARDWARE;
const HYBRID = AV_CODEC_CAP_HYBRID;
const ENCODER_REORDERED_OPAQUE = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE;
const ENCODER_FLUSH = AV_CODEC_CAP_ENCODER_FLUSH;
const ENCODER_RECON_FRAME = AV_CODEC_CAP_ENCODER_RECON_FRAME;
}
}`
the 'AV_CODEC_CAP_ENCODER_RECON_FRAME' couldn't been found, is there something wrong in my project or env?
my sys is windows10 and ffmepg libraries's version is 5.1.2 installed by vcpkg

can not find the h264 encoder by avcodec_find_encoder

  • main.rs
fn main() {
  unsafe {
    let ptr = ffmpeg_sys_next::avcodec_find_encoder(
      ffmpeg_sys_next::AVCodecID::AV_CODEC_ID_H264
    );
    assert!(!ptr.is_null())
  }
}
  • Carog.toml
[package]
name = "setting_test"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ffmpeg-sys-next = { path = "../", features = [ // this example writing inside the ffmpeg-sys-next repo
  "build",
  "build-license-gpl",
  "build-license-nonfree",
  "build-lib-x264"
] }

console out:

Caused by:
  process didn't exit successfully: `/Users/kyros/MyProject/libs/rust-ffmpeg-sys/target/debug/build/ffmpeg-sys-next-ee8dfd2e99237b2f/build-script-build` (exit status: 101)
  --- stdout
  cargo:rustc-link-search=native=/Users/kyros/MyProject/libs/rust-ffmpeg-sys/target/debug/build/ffmpeg-sys-next-d76d0e8e39f17cc2/out/dist/lib
  cargo:rustc-link-lib=static=avcodec
  cargo:rustc-link-lib=static=avdevice
  cargo:rustc-link-lib=static=avfilter
  cargo:rustc-link-lib=static=avformat
  cargo:rustc-link-lib=static=avutil
  cargo:rustc-link-lib=static=swresample
  cargo:rustc-link-lib=static=swscale
  configure: ERROR: x264 not found using pkg-config

  If you think configure made a mistake, make sure you are using the latest
  version from Git.  If the latest version fails, report the problem to the
  [email protected] mailing list or IRC #ffmpeg on irc.libera.chat.
  Include the log file "ffbuild/config.log" produced by configure as this will help
  solve the problem.


  --- stderr
  Cloning into 'ffmpeg-6.1'...
  thread 'main' panicked at build.rs:657:21:
  called `Result::unwrap()` on an `Err` value: Custom { kind: Other, error: "configure failed " }
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

rust version:

rustup 1.26.0 (5af9b9484 2023-04-05)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.75.0 (82e1608df 2023-12-21)`

platform:

  • macos 14.3.1 23D60 arm64

Can’t cross-compile from aarch64-unknowm-linux-gnu target.

I’m using ubuntu 22.04 LTS as a host.

Here’s the command I use.

env PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu/ PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig/ CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=/usr/bin/aarch64-linux-gnu-gcc cargo check

It fails when compiling check.c. I’ve debugged enough to see that you’ve harcoded using host as target and as a result it doesn’t see arm versions of ffmpeg libraries installed for cross compilation like so apt install libav-util:arm64.

Do you support cross-compilation?

And why is your build script so complex? sys crate supposed to just create bindings. You’re trying to compile ffmpeg for some reason… Can you elaborate on that?

Support ffmpeg 5.0.0

ffmpeg 5 has been released and I think this crate should support it. In Arch Linux, we're currently performing the ffmpeg 5 rebuild and we're getting blocked by Rust packages that need this crate.

Would be great if this crate could add support for that new ffmpeg release as otherwise we'd have to provide a compatibility build of ffmpeg.

Static linking with vcpkg does not work in Windows unless you link to some extra libraries in build.rs

Hi, I was not able to get static linking working on windows via vcpkg unless I modified the build.rs to link to some extra libraries to fix some linker errors. I had this issue by using ffmpeg-next 4.4 with just the static feature enabled.

I had to link against these libraries (which worked for me by just adding println!("cargo:rustc-link-lib=...") in the build.rs):

  • crypt32
  • Setupapi
  • winmm
  • Imm32
  • Version
  • mfplat
  • strmiids
  • mfuuid
  • Vfw32

Building as Cargo Dependency Failed

Hey, I'm trying to add ffmpeg-next 4.3.3 to a dependency of one of my projects. I have the ffmpeg system library installed:

$ ffmpeg
ffmpeg version N-98588-gcbb6ba2 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
  configuration: 
  libavutil      56. 57.100 / 56. 57.100
  libavcodec     58. 97.102 / 58. 97.102
  libavformat    58. 49.100 / 58. 49.100
  libavdevice    58. 11.101 / 58. 11.101
  libavfilter     7. 87.100 /  7. 87.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

However, when I try building my project with cargo, I get the error:

$ cargo run --release
   Compiling ffmpeg-sys-next v4.3.0
error: failed to run custom build command for `ffmpeg-sys-next v4.3.0`

Caused by:
  process didn't exit successfully: `/home/etomicbomb/RustProjects/orbit/target/release/build/ffmpeg-sys-next-f3940722af8a23ee/build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=LIBAVUTIL_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu

********* tons of lines of 'cargo:' stuff omitted **********

cargo:rustc-cfg=feature="avcodec_version_greater_than_58_76"
cargo:rustc-cfg=feature="avcodec_version_greater_than_58_77"
cargo:rustc-cfg=feature="avcodec_version_greater_than_58_78"
cargo:rustc-cfg=feature="avcodec_version_greater_than_58_79"

--- stderr
check.c:311:0: warning: "FF_API_XVMC_is_defined" redefined
             #define FF_API_XVMC_is_defined 1
 
check.c:84:0: note: this is the location of the previous definition
             #define FF_API_XVMC_is_defined 0
 
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found, err: true
thread 'main' panicked at 'Unable to generate bindings: ()', /home/etomicbomb/.cargo/registry/src/github.com-1ecc6299db9ec823/ffmpeg-sys-next-4.3.0/build.rs:1022:20
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I'm not sure what's going on. I saw a similar issue that had the error check.c:311:0: warning: "FF_API_XVMC_is_defined" redefined #define FF_API_XVMC_is_defined 1
but I'm not cross compiling.

Thanks so much

Can not cross compile for Windows under Linux

When attempting to cross compile this crate for Windows under Linux using the build feature, the configure script reports:

  configure: Unknown OS 'windows'.

  If you think configure made a mistake, make sure you are using the latest
  version from Git.  If the latest version fails, report the problem to the
  [email protected] mailing list or IRC #ffmpeg on irc.libera.chat.
  Include the log file "ffbuild/config.log" produced by configure as this will help
  solve the problem.

I believe this happens because the build script sets the configure argument target_os to the value of CARGO_CFG_TARGET_OS, which Cargo sets as windows, a value the configure does not expect.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.