playa_ffmpeg/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 crate::{
30 Codec,
31 codec::{Context, Id},
32 ffi::*,
33};
34
35pub fn new() -> Encoder {
36 Context::new().encoder()
37}
38
39pub fn find(id: Id) -> Option<Codec> {
40 unsafe {
41 #[allow(clippy::unnecessary_cast)]
43 let ptr = avcodec_find_encoder(id.into()) as *mut AVCodec;
44
45 if ptr.is_null() { None } else { Some(Codec::wrap(ptr)) }
46 }
47}
48
49pub fn find_by_name(name: &str) -> Option<Codec> {
50 unsafe {
51 let name = CString::new(name).unwrap();
52 #[allow(clippy::unnecessary_cast)]
53 let ptr = avcodec_find_encoder_by_name(name.as_ptr()) as *mut AVCodec;
54
55 if ptr.is_null() { None } else { Some(Codec::wrap(ptr)) }
56 }
57}