larksuite / rsmpeg

A Rust crate that exposes FFmpeg's power as much as possible.
https://docs.rs/rsmpeg/latest/rsmpeg/
MIT License
678 stars 41 forks source link

Reconfigure AVCodecContext #71

Closed aegroto closed 2 years ago

aegroto commented 2 years ago

Is there any way to reconfigure a context after it has been initialized and used? I can see there is a function for that, at least on x264 https://ffmpeg.org/doxygen/4.0/libx264_8c_source.html#l00171 but I think that both the library and the FFI are not exposing it.

ldm0 commented 2 years ago

I can see there is a function for that

But this is a static function, which is not exposed. Rsmpeg only wraps public functions in header files.

The reconfig_encoder in libx264 only resets the priv_data member, if you do want to do the same thing, use unsafe Rust to access the priv_data member of AVCodecContext should be ok.

aegroto commented 2 years ago

Thanks. In the end I figured out that recreating the context each time is not a huge cost and it seems working, even if it's a bit harsh.