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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
//! # ez-ffmpeg
//!
//! **ez-ffmpeg** provides a safe and ergonomic Rust interface for [FFmpeg](https://ffmpeg.org)
//! integration. By abstracting away much of the raw C API complexity,
//! It abstracts the complexity of the raw C API, allowing you to configure media pipelines,
//! perform transcoding and filtering, and inspect streams with ease.
//!
//! ## Crate Layout
//!
//! - **`core`**: The foundational module that contains the main building blocks for configuring
//! and running FFmpeg pipelines. This includes:
//! - `Input` / `Output`: Descriptors for where media data comes from and goes to (files, URLs,
//! custom I/O callbacks, etc.).
//! - `FilterComplex` and [`FrameFilter`](filter::frame_filter::FrameFilter): Mechanisms for applying FFmpeg filter graphs or
//! custom transformations.
//! - `container_info`: Utilities to extract information about the container, such as duration and format details.
//! - `stream_info`: Utilities to query media metadata (duration, codecs, etc.).
//! - `hwaccel`: Helpers for enumerating and configuring hardware-accelerated video codecs
//! (CUDA, VAAPI, VideoToolbox, etc.).
//! - `codec`: Tools to list and inspect available encoders/decoders.
//! - `device`: Utilities to discover system cameras, microphones, and other input devices.
//! - `filter`: Query FFmpeg's built-in filters and infrastructure for building custom frame-processing filters.
//! - `context`: Houses [`FfmpegContext`] for assembling an FFmpeg job.
//! - `scheduler`: Provides [`FfmpegScheduler`] which manages the lifecycle of that job.
//!
//! - **`opengl`** (feature `"opengl"`): Offers GPU-accelerated OpenGL filters, letting you
//! provide a fragment shader and apply effects to video frames in a high-performance way
//! without manually managing the GL context.
//!
//! - **`rtmp`** (feature `"rtmp"`): Embedded RTMP server `EmbedRtmpServer` built for production streaming,
//! using native epoll/kqueue/WSAPoll via libc FFI (edge-triggered on Linux/macOS, level-triggered on Windows),
//! zero-copy GOP fanout with `Arc<[FrameData]>`, and tiered backpressure (1/2/4MB) on a 2-thread model;
//! 10,000+ conns on Linux/macOS (8,000 on Windows) with in-process ingest (no TCP between FFmpeg and server).
//!
//! - **`flv`** (feature `"flv"`): Provides data structures and helpers for handling FLV
//! containers, useful if you’re working with RTMP or other FLV-based workflows.
//!
//! ## Basic Usage
//!
//! For a simple pipeline, you typically do the following:
//!
//! 1. Build a [`FfmpegContext`] by specifying at least one [input](Input)
//! and one [output](Output). Optionally, add filter descriptions
//! (`filter_desc`) or attach [`FrameFilter`](filter::frame_filter::FrameFilter) pipelines at either the input (post-decode)
//! or the output (pre-encode) stage.
//! 2. Create an [`FfmpegScheduler`] from that context, then call `start()` and `wait()` (or `.await`
//! if you enable the `"async"` feature) to run the job.
//!
//! ```rust,ignore
//! use ez_ffmpeg::FfmpegContext;
//! use ez_ffmpeg::FfmpegScheduler;
//!
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // 1. Build the FFmpeg context
//! let context = FfmpegContext::builder()
//! .input("input.mp4")
//! .filter_desc("hue=s=0") // Example filter: desaturate
//! .output("output.mov")
//! .build()?;
//!
//! // 2. Run it via FfmpegScheduler (sync mode)
//! let result = FfmpegScheduler::new(context)
//! .start()?
//! .wait();
//! result?; // If any error occurred, propagate it
//! Ok(())
//! }
//! ```
//!
//! ## Feature Flags
//!
//! **`ez-ffmpeg`** uses Cargo features to provide optional functionality. By default, no optional
//! features are enabled, allowing you to keep dependencies minimal. You can enable features as needed
//! in your `Cargo.toml`:
//!
//! ```toml
//! [dependencies.ez-ffmpeg]
//! version = "*"
//! features = ["opengl", "rtmp", "flv", "async"]
//! ```
//!
//! ### Core Features
//!
//! - **`opengl`**: Enables OpenGL-based filters for GPU-accelerated processing.
//! - **`rtmp`**: Embedded RTMP server tuned for scale (10,000+ conns on Linux/macOS, 8,000 on Windows),
//! native epoll/kqueue/WSAPoll IO (edge-triggered on Linux/macOS), zero-copy GOP, and in-process ingest
//! that avoids TCP between FFmpeg and server.
//! - **`flv`**: Adds FLV container parsing and handling.
//! - **`async`**: Makes the [`FfmpegScheduler`] wait method asynchronous (you can `.await` it).
//! - **`static`**: Uses static linking for FFmpeg libraries (via `ffmpeg-next/static`).
//!
//! ## License Notice
//!
//! ez-ffmpeg is distributed under the WTFPL (Do What The F*ck You Want To Public License).
//! You are free to use, modify, and distribute this software.
//!
//! **Note:** FFmpeg itself is subject to its own licensing terms. When enabling features that incorporate FFmpeg components,
//! please ensure that your usage complies with FFmpeg's license.
pub use FfmpegContext;
pub use Input;
pub use Output;
pub use FfmpegScheduler;
pub use container_info;
pub use stream_info;
pub use packet_scanner;
pub use device;
pub use hwaccel;
pub use codec;
pub use filter;
pub use AVRational;
pub use AVMediaType;
pub use Frame;
use declare_surfman;
declare_surfman!;