-
Notifications
You must be signed in to change notification settings - Fork 71
Transcoder Design
Very preliminary This is more of a high level description; specific architectural and code details to follow as the implementation is finalized.
Each stage has an associated context holding the relevant data.
- Demuxing
- Decoding
- Rescaling / Colorspace Conversion , Resampling
- Filtering
- Encoding
- Muxing
We assume one audio and/or one video stream per input, to be sent to the corresponding output. Audio-only or video-only streams should work. Behavior is undefined with multiple streams per container.
Demuxer : Extracts each stream out of a container. A container is the "outermost" element that holds video streams, audio streams, subtitles, timing information, metadata, etc. Examples of container formats: HLS, MPEG transport streams, WebM, MP4, Matroska, etc.
For Livepeer, we only need one demuxer per input.
Decoder : Responsible for decompressing each stream based on the appropriate codec. Decompression makes the media amenable to being processed (scaled, filtered, re-encoded, etc). Examples of codecs: AAC, Opus, H.264, VP9
For Livepeer, we usually only need one decoder per input.
Rescaling : Whereby a frame of video is resized.
Colorspace and Pixel Format Conversion : A video decoder outputs raw pixels in one of many possible layouts and color spaces. For example: RGB vs BGRA. Planar vs interleaved. Various levels of chroma subsampling.
Sometimes an encoder only supports input formats that are unavailable from the decoder, so we need to convert. Usually FFmpeg (libswscale) has fast paths that optimize common combinations for rescaling and pixfmt conversion.
Resampling The audio equivalent to resizing; such as taking a stream from a 48 kHz sampling rate to 44.1 kHz.
For Livepeer, we generally need one set of swscale (video) and avresample (audio) contexts per output.
Filtering Certain operations, for example smooth framerate reduction, are best achieved through libavfilter.
Encoding Compresses the raw media data using the specified codec.
Muxing Combines everything into the container for output.
For Livepeer, each output is associated with one muxer.