ffmpeg_rs/codec/encoder/
mod.rs1pub mod encoder;
2pub use self::encoder::Encoder;
3
4pub mod video;
5pub use self::video::Encoder as Video;
6
7pub mod audio;
8pub use self::audio::Encoder as Audio;
9
10pub mod subtitle;
11pub use self::subtitle::Encoder as Subtitle;
12
13pub mod motion_estimation;
14pub use self::motion_estimation::MotionEstimation;
15
16#[cfg(not(feature = "ffmpeg_5_0"))]
17pub mod prediction;
18#[cfg(not(feature = "ffmpeg_5_0"))]
19pub use self::prediction::Prediction;
20
21pub mod comparison;
22pub use self::comparison::Comparison;
23
24pub mod decision;
25pub use self::decision::Decision;
26
27use std::ffi::CString;
28
29use codec::Context;
30use codec::Id;
31use ffi::*;
32use Codec;
33
34pub fn new() -> Encoder {
35 Context::new().encoder()
36}
37
38pub fn find(id: Id) -> Option<Codec> {
39 unsafe {
40 let ptr = avcodec_find_encoder(id.into()) as *mut AVCodec;
41
42 if ptr.is_null() {
43 None
44 } else {
45 Some(Codec::wrap(ptr))
46 }
47 }
48}
49
50pub fn find_by_name(name: &str) -> Option<Codec> {
51 unsafe {
52 let name = CString::new(name).unwrap();
53 let ptr = avcodec_find_encoder_by_name(name.as_ptr()) as *mut AVCodec;
54
55 if ptr.is_null() {
56 None
57 } else {
58 Some(Codec::wrap(ptr))
59 }
60 }
61}