diff --git a/src/codec/decoder/decoder.rs b/src/codec/decoder/decoder.rs index 6990ab71..4ae8a820 100644 --- a/src/codec/decoder/decoder.rs +++ b/src/codec/decoder/decoder.rs @@ -31,6 +31,20 @@ impl Decoder { } } + pub fn open_with(mut self, options: Dictionary) -> Result { + unsafe { + let mut opts = options.disown(); + let res = avcodec_open2(self.as_mut_ptr(), ptr::null(), &mut opts); + + Dictionary::own(opts); + + match res { + 0 => Ok(Opened(self)), + e => Err(Error::from(e)), + } + } + } + pub fn open_as_with( mut self, codec: D, diff --git a/src/codec/encoder/subtitle.rs b/src/codec/encoder/subtitle.rs index 0bbb346c..05f5d001 100644 --- a/src/codec/encoder/subtitle.rs +++ b/src/codec/encoder/subtitle.rs @@ -33,6 +33,20 @@ impl Subtitle { } } + pub fn open_with(mut self, options: Dictionary) -> Result { + unsafe { + let mut opts = options.disown(); + let res = avcodec_open2(self.as_mut_ptr(), ptr::null(), &mut opts); + + Dictionary::own(opts); + + match res { + 0 => Ok(Encoder(self)), + e => Err(Error::from(e)), + } + } + } + pub fn open_as_with( mut self, codec: E,