CCExtractor / rusty_ffmpeg

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

Issues in latest rusty_ffmpeg #93

Closed prateekmedia closed 1 year ago

prateekmedia commented 1 year ago

These error come when using link_system_ffmpeg feature

 --> /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(),
    |                 +                                            +++++++++++++++++++++

_Originally posted by @prateekmedia in https://github.com/CCExtractor/rusty_ffmpeg/issues/89#issuecomment-1477363226_

ldm0 commented 1 year ago

It's a FFmpeg 4 compatibility issue occurred after bindgen update, type of AVFrameSideData::size changed between FFmpeg 4 and 5. https://github.com/FFmpeg/FFmpeg/blob/release/4.0/libavutil/frame.h#L180 https://github.com/FFmpeg/FFmpeg/blob/release/5.0/libavutil/frame.h#L223

Let me fix it.

ldm0 commented 1 year ago

@prateekmedia Should be fixed by https://github.com/larksuite/rsmpeg/pull/111 Please try rsmpeg = { version = "0.14.1", features = ["link_system_ffmpeg"] }

prateekmedia commented 1 year ago

Thanks for the quick fix @ldm0