ffmpeg/codec/encoder/
mod.rs

1pub 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
16pub mod prediction;
17pub use self::prediction::Prediction;
18
19pub mod comparison;
20pub use self::comparison::Comparison;
21
22pub mod decision;
23pub use self::decision::Decision;
24
25use std::ffi::CString;
26
27use codec::Context;
28use codec::Id;
29use ffi::*;
30use Codec;
31
32pub fn new() -> Encoder {
33    Context::new().encoder()
34}
35
36pub fn find(id: Id) -> Option<Codec> {
37    unsafe {
38        let ptr = avcodec_find_encoder(id.into());
39
40        if ptr.is_null() {
41            None
42        } else {
43            Some(Codec::wrap(ptr))
44        }
45    }
46}
47
48pub fn find_by_name(name: &str) -> Option<Codec> {
49    unsafe {
50        let name = CString::new(name).unwrap();
51        let ptr = avcodec_find_encoder_by_name(name.as_ptr());
52
53        if ptr.is_null() {
54            None
55        } else {
56            Some(Codec::wrap(ptr))
57        }
58    }
59}