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