ffmpeg
builds a transcoding pipeline out of the components listed below. The program’s operation then consists of input data chunks flowing from the sources down the pipes towards the sinks, while being transformed by the components they encounter along the way.
The following kinds of components are available:
- Demuxers (short for "demultiplexers") read an input source in order to extract
- global properties such as metadata or chapters;
- list of input elementary streams and their properties
One demuxer instance is created for each -i option, and sends encoded packets to decoders or muxers.
In other literature, demuxers are sometimes called splitters, because their main function is splitting a file into elementary streams (though some files only contain one elementary stream).
A schematic representation of a demuxer looks like this:
┌──────────┬───────────────────────┐ │ demuxer │ │ packets for stream 0 ╞══════════╡ elementary stream 0 ├──────────────────────⮞ │ │ │ │ global ├───────────────────────┤ │properties│ │ packets for stream 1 │ and │ elementary stream 1 ├──────────────────────⮞ │ metadata │ │ │ ├───────────────────────┤ │ │ │ │ │ ........... │ │ │ │ │ ├───────────────────────┤ │ │ │ packets for stream N │ │ elementary stream N ├──────────────────────⮞ │ │ │ └──────────┴───────────────────────┘ ⯅ │ │ read from file, network stream, │ grabbing device, etc. │
- Decoders receive encoded (compressed) packets for an audio, video, or subtitle elementary stream, and decode them into raw frames (arrays of pixels for video, PCM for audio). A decoder is typically associated with (and receives its input from) an elementary stream in a demuxer, but sometimes may also exist on its own (see Loopback decoders).
A schematic representation of a decoder looks like this:
┌─────────┐ packets │ │ raw frames ─────────⮞│ decoder ├────────────⮞ │ │ └─────────┘
- Filtergraphs process and transform raw audio or video frames. A filtergraph consists of one or more individual filters linked into a graph. Filtergraphs come in two flavors - simple and complex, configured with the -filter and -filter_complex options, respectively.
A simple filtergraph is associated with an output elementary stream; it receives the input to be filtered from a decoder and sends filtered output to that output stream’s encoder.
A simple video filtergraph that performs deinterlacing (using the
yadif
deinterlacer) followed by resizing (using thescale
filter) can look like this:┌────────────────────────┐ │ simple filtergraph │ frames from ╞════════════════════════╡ frames for a decoder │ ┌───────┐ ┌───────┐ │ an encoder ────────────⮞├─⮞│ yadif ├─⮞│ scale ├─⮞│────────────⮞ │ └───────┘ └───────┘ │ └────────────────────────┘
A complex filtergraph is standalone and not associated with any specific stream. It may have multiple (or zero) inputs, potentially of different types (audio or video), each of which receiving data either from a decoder or another complex filtergraph’s output. It also has one or more outputs that feed either an encoder or another complex filtergraph’s input.
The following example diagram represents a complex filtergraph with 3 inputs and 2 outputs (all video):
┌─────────────────────────────────────────────────┐ │ complex filtergraph │ ╞═════════════════════════════════════════════════╡ frames ├───────┐ ┌─────────┐ ┌─────────┐ ┌────────┤ frames ─────────⮞│input 0├─⮞│ overlay ├─────⮞│ overlay ├─⮞│output 0├────────⮞ ├───────┘ │ │ │ │ └────────┤ frames ├───────┐╭⮞│ │ ╭⮞│ │ │ ─────────⮞│input 1├╯ └─────────┘ │ └─────────┘ │ ├───────┘ │ │ frames ├───────┐ ┌─────┐ ┌─────┬─╯ ┌────────┤ frames ─────────⮞│input 2├⮞│scale├⮞│split├───────────────⮞│output 1├────────⮞ ├───────┘ └─────┘ └─────┘ └────────┤ └─────────────────────────────────────────────────┘
Frames from second input are overlaid over those from the first. Frames from the third input are rescaled, then the duplicated into two identical streams. One of them is overlaid over the combined first two inputs, with the result exposed as the filtergraph’s first output. The other duplicate ends up being the filtergraph’s second output.
- Encoders receive raw audio, video, or subtitle frames and encode them into encoded packets. The encoding (compression) process is typically lossy - it degrades stream quality to make the output smaller; some encoders are lossless, but at the cost of much higher output size. A video or audio encoder receives its input from some filtergraph’s output, subtitle encoders receive input from a decoder (since subtitle filtering is not supported yet). Every encoder is associated with some muxer’s output elementary stream and sends its output to that muxer.
A schematic representation of an encoder looks like this:
┌─────────┐ raw frames │ │ packets ────────────⮞│ encoder ├─────────⮞ │ │ └─────────┘
- Muxers (short for "multiplexers") receive encoded packets for their elementary streams from encoders (the transcoding path) or directly from demuxers (the streamcopy path), interleave them (when there is more than one elementary stream), and write the resulting bytes into the output file (or pipe, network stream, etc.).
A schematic representation of a muxer looks like this:
┌──────────────────────┬───────────┐ packets for stream 0 │ │ muxer │ ──────────────────────⮞│ elementary stream 0 ╞═══════════╡ │ │ │ ├──────────────────────┤ global │ packets for stream 1 │ │properties │ ──────────────────────⮞│ elementary stream 1 │ and │ │ │ metadata │ ├──────────────────────┤ │ │ │ │ │ ........... │ │ │ │ │ ├──────────────────────┤ │ packets for stream N │ │ │ ──────────────────────⮞│ elementary stream N │ │ │ │ │ └──────────────────────┴─────┬─────┘ │ write to file, network stream, │ grabbing device, etc. │ │ ▼
标签:Detailed,ffmpeg,stream,frames,filtergraph,input,elementary,output,description From: https://www.cnblogs.com/sathcal/p/18537702