CCExtractor / rusty_ffmpeg

FFI bindings for FFmpeg inner libraries.
https://crates.io/crates/rusty_ffmpeg
MIT License
164 stars 26 forks source link

Automatic Detect ffmpeg Path #89

Closed prateekmedia closed 1 year ago

prateekmedia commented 1 year ago

See in ubuntu or fedora they have a common path for ffmpeg, so can rusty_ffmpeg do the same by default i.e. if env variable is not set then check in a set of directories, else return error.

Reference: CCExtractor now uses this, but most of the users won't set environment variable and some will except it to detect it automatically just like ffmpeg_sys_next https://github.com/CCExtractor/ccextractor/issues/1412

cc @ldm0

ldm0 commented 1 year ago

Originally there was a linking fallback. It's disabled due to possibility of using version-incompatible FFmpeg. Will bring it back gated with a feature.

ldm0 commented 1 year ago

Will make a release after https://github.com/CCExtractor/rusty_ffmpeg/pull/86 gets merged

ldm0 commented 1 year ago

@prateekmedia You can use rsmpeg = { version = "0.14", features = ["link_system_ffmpeg"] } now.

prateekmedia commented 1 year ago

Also ffmpeg5 feature is needed I think @ldm0?

ldm0 commented 1 year ago

Also ffmpeg5 feature is needed I think @ldm0?

If you drop support for FFmpeg 4, it's needed.

prateekmedia commented 1 year ago

@ldm0 can you look at this error, it is coming after removing env variables:

error[E0425]: cannot find value `AVPixelFormat_AV_PIX_FMT_X2BGR10LE` in this scope
   --> /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/rusty_ffmpeg-0.13.0+ffmpeg.6.0/src/avutil/pixfmt.rs:104:86
    |
11  |         pub const $def: AVPixelFormat = $le;
    |         ------------------------------------ similarly named constant `AVPixelFormat_AV_PIX_FMT_X2BGR10` defined here

Full log here: https://github.com/CCExtractor/ccextractor/actions/runs/4476277260/jobs/7866479823

ldm0 commented 1 year ago

@ldm0 can you look at this error, it is coming after removing env variables:

error[E0425]: cannot find value `AVPixelFormat_AV_PIX_FMT_X2BGR10LE` in this scope
   --> /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/rusty_ffmpeg-0.13.0+ffmpeg.6.0/src/avutil/pixfmt.rs:104:86
    |
11  |         pub const $def: AVPixelFormat = $le;
    |         ------------------------------------ similarly named constant `AVPixelFormat_AV_PIX_FMT_X2BGR10` defined here

Full log here: https://github.com/CCExtractor/ccextractor/actions/runs/4476277260/jobs/7866479823

@prateekmedia AV_PIX_FMT_X2BGR10 was added in FFmpeg 5.0 and gated under ffmpeg5 feature, the ffmpeg inner libs installed by apt in CI should belongs to FFmpeg 4.*.

You can try removing ffmpeg5 feature.

prateekmedia commented 1 year ago

These still come without ffmpeg5 flag

 --> /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/rsmpeg-0.14.0+ffmpeg.6.0/src/avutil/frame.rs:232:29
    |
232 |                 self.size / size_of::<ffi::AVMotionVector>(),
    |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `usize`

error[E0277]: cannot divide `i32` by `usize`
   --> /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/rsmpeg-0.14.0+ffmpeg.6.0/src/avutil/frame.rs:232:27
    |
232 |                 self.size / size_of::<ffi::AVMotionVector>(),
    |                           ^ no implementation for `i32 / usize`
    |
    = help: the trait `Div<usize>` is not implemented for `i32`
    = help: the following other types implement trait `Div<Rhs>`:
              <&'a i32 as Div<i32>>
              <&i32 as Div<&i32>>
              <i32 as Div<&i32>>
              <i32 as Div>

error[E0308]: mismatched types
   --> /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/rsmpeg-0.14.0+ffmpeg.6.0/src/avutil/frame.rs:232:17
    |
230 |             slice::from_raw_parts(
    |             --------------------- arguments to this function are incorrect
231 |                 self.data as *const _ as *const ffi::AVMotionVector,
232 |                 self.size / size_of::<ffi::AVMotionVector>(),
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `i32`
    |
note: function defined here
   --> /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/slice/raw.rs:92:21
help: you can convert an `i32` to a `usize` and panic if the converted value doesn't fit
    |
232 |                 (self.size / size_of::<ffi::AVMotionVector>()).try_into().unwrap(),
    |                 +                                            +++++++++++++++++++++
ldm0 commented 1 year ago

Yeah, that's a seperate issue. let me check this out.

ldm0 commented 1 year ago

@prateekmedia Try rsmpeg = { version = "0.14.1", features = ["link_system_ffmpeg"] }