playa_ffmpeg/codec/
mod.rs

1//! Audio, video, and subtitle codec support.
2//!
3//! This module provides encoding and decoding capabilities for various media codecs.
4//! It wraps FFmpeg's `libavcodec` library with safe Rust interfaces.
5//!
6//! # Main Components
7//!
8//! - [`decoder`] - Decode compressed media to raw frames
9//! - [`encoder`] - Encode raw frames to compressed media
10//! - [`Context`] - Codec context managing encoder/decoder state
11//! - [`packet::Packet`] - Compressed data packet (encoded media)
12//! - [`Parameters`] - Codec parameters (resolution, bitrate, sample rate, etc.)
13//! - [`Audio`] / [`Video`] - Type-specific codec information
14//!
15//! # Usage
16//!
17//! Decoders are typically created from an input stream's codec parameters,
18//! while encoders are configured with desired output parameters before use.
19//!
20//! # Submodules
21//!
22//! - `packet` - Compressed media packets
23//! - `subtitle` - Subtitle codec support
24//! - `capabilities` - Codec capability flags
25//! - `threading` - Multi-threaded encoding/decoding
26//! - `profile` - Codec profiles (baseline, main, high, etc.)
27//! - `compliance` - Standard compliance levels
28
29pub mod flag;
30pub use self::flag::Flags;
31
32pub mod id;
33pub use self::id::Id;
34
35pub mod packet;
36
37pub mod subtitle;
38
39#[cfg(not(feature = "ffmpeg_5_0"))]
40pub mod picture;
41
42pub mod discard;
43
44pub mod context;
45pub use self::context::Context;
46
47pub mod capabilities;
48pub use self::capabilities::Capabilities;
49
50pub mod codec;
51
52pub mod parameters;
53pub use self::parameters::Parameters;
54
55pub mod video;
56pub use self::video::Video;
57
58pub mod audio;
59pub use self::audio::Audio;
60
61pub mod audio_service;
62pub mod field_order;
63
64pub mod compliance;
65pub use self::compliance::Compliance;
66
67pub mod debug;
68pub use self::debug::Debug;
69
70pub mod profile;
71pub use self::profile::Profile;
72
73pub mod threading;
74
75pub mod decoder;
76pub mod encoder;
77pub mod traits;
78
79use std::{ffi::CStr, str::from_utf8_unchecked};
80
81use crate::ffi::*;
82
83/// Returns the libavcodec version number.
84///
85/// The version is encoded as `(major << 16) | (minor << 8) | micro`.
86/// Use this to check FFmpeg's codec library version at runtime.
87pub fn version() -> u32 {
88    unsafe { avcodec_version() }
89}
90
91/// Returns the libavcodec build configuration string.
92///
93/// This shows the compile-time configuration options used when building FFmpeg,
94/// including enabled codecs, features, and compile flags.
95pub fn configuration() -> &'static str {
96    unsafe { from_utf8_unchecked(CStr::from_ptr(avcodec_configuration()).to_bytes()) }
97}
98
99/// Returns the libavcodec license string.
100///
101/// Typically "LGPL version 2.1 or later" unless FFmpeg was built with GPL-only
102/// components, in which case it returns "GPL version 2 or later".
103pub fn license() -> &'static str {
104    unsafe { from_utf8_unchecked(CStr::from_ptr(avcodec_license()).to_bytes()) }
105}