AV module
av
Audio/video encoding, decoding, device capture, and media formats.
Namespaces
| Name | Description |
|---|---|
v4l2 | Linux V4L2 device enumeration helpers. |
coreaudio | Apple CoreAudio device enumeration helpers. |
legacy | Legacy timing helpers kept for compatibility with older media pipelines. |
avfoundation | Apple AVFoundation device enumeration helpers. |
mediafoundation | Windows Media Foundation device enumeration helpers. |
wasapi | Windows WASAPI device enumeration helpers. |
Classes
| Name | Description |
|---|---|
LinuxDeviceWatcher | Monitors device add/remove events via libudev. |
ICapture | Abstract interface for audio and video capture devices. |
IEncoder | This is the abstract class for all encoders. |
AppleDeviceWatcher | Monitors device add/remove events via AVFoundation notifications and CoreAudio property listeners. |
FPSCounter | FPS counter based on the simple moving average (SMA) algorithm. |
FPSLimiter | PacketStream processor that caps packet throughput to a maximum FPS. |
AudioCapture | Cross-platform audio capture device backed by FFmpeg input devices. |
MediaCapture | Unified capture and decode source for files and live media devices. |
VideoCapture | Cross-platform video device capturer backed by FFmpeg avdevice. |
DeviceWatcher | Base class for platform-specific device change monitors. |
DeviceManager | Enumerates and manages system audio and video devices. |
FormatRegistry | Singleton registry of available media container formats for encoding and decoding. |
WindowsDeviceWatcher | Monitors device add/remove events via IMMNotificationClient (audio) and RegisterDeviceNotification (video). |
MultiplexEncoder | Multiplexing encoder that writes synchronized audio and video streams. |
AudioPacketEncoder | PacketProcessor that encodes raw audio samples (PlanarAudioPacket or AudioPacket) into compressed packets via AudioEncoder. |
VideoPacketEncoder | PacketProcessor that encodes raw video frames (PlanarVideoPacket or VideoPacket) into compressed packets via VideoEncoder. |
RealtimePacketQueue | Queue that emits media packets in presentation-timestamp order relative to a realtime clock. |
MultiplexPacketEncoder | Encodes and multiplexes a realtime video stream form audio / video capture sources. FFmpeg is used for encoding. |
Codec | Codec for encoding/decoding media. |
AudioCodec | Audio codec parameters including channels, sample rate, and sample format. |
VideoCodec | Video codec parameters including resolution, frame rate, and pixel format. |
Deleter | RAII helpers for owning FFmpeg allocation types. |
Deleterp | Deleter adaptor for functions like av_freep that take a pointer to a pointer. |
Format | Defines a media container format which is available through the FormatRegistry for encoding or decoding. |
EncoderState | State machine states for the encoder pipeline. |
EncoderOptions | Configuration options for audio and video encoders. |
AudioBuffer | FIFO buffer for queuing audio samples between encoding stages. |
AudioContext | Base context for audio encoding and decoding via FFmpeg. |
AudioDecoder | Decodes compressed audio packets into raw sample frames. |
AudioEncoder | Encodes raw audio samples into a compressed format. |
VideoContext | Base video context from which all video encoders and decoders derive. |
VideoDecoder | Decodes compressed video packets into raw frames. |
VideoEncoder | Encodes raw video frames into a compressed format. |
Device | Represents a system audio, video or render device. |
AudioResampler | Converts audio samples between different formats, sample rates, and channel layouts. |
VideoConverter | Converts video frames between pixel formats and resolutions. |
MediaPacket | Timestamped media packet carrying raw audio or video data. |
VideoPacket | Video packet for interleaved formats. |
PlanarVideoPacket | Video packet for planar formats. |
AudioPacket | Audio packet for interleaved formats. |
PlanarAudioPacket | Audio packet for planar formats. |
Macros
| Name | Description |
|---|---|
MAX_AUDIO_PACKET_SIZE | 1 second of 48khz 32bit audio |
MAX_ENCODE_DURATION | 3 hours |
MAX_AUDIO_PACKET_SIZE
MAX_AUDIO_PACKET_SIZE()1 second of 48khz 32bit audio
MAX_ENCODE_DURATION
MAX_ENCODE_DURATION()3 hours
Enumerations
| Name | Description |
|---|---|
MediaCapabilities | Bitmask of media capabilities detected on this system. |
MediaCapabilities
enum MediaCapabilitiesBitmask of media capabilities detected on this system.
| Value | Description |
|---|---|
AUDIO_RECV | Audio capture or decode is available. |
AUDIO_SEND | Audio playback or encode is available. |
VIDEO_RECV | Video capture or decode is available. |
VIDEO_SEND | Video render or encode is available. |
Typedefs
| Return | Name | Description |
|---|---|---|
std::list< Codec > | CodecList | List of codec value objects. |
std::list< Codec * > | CodecPList | List of codec pointers. |
std::unique_ptr< AVFrame, Deleterp< AVFrame, void, av_frame_free > > | AVFrameHolder | Owning AVFrame pointer released with av_frame_free(). |
std::unique_ptr< AVFormatContext, Deleter< AVFormatContext, void, avformat_free_context > > | AVFormatContextHolder | Owning AVFormatContext pointer released with avformat_free_context(). |
std::unique_ptr< AVCodecContext, Deleterp< AVCodecContext, void, avcodec_free_context > > | AVCodecContextHolder | Owning AVCodecContext pointer released with avcodec_free_context(). |
std::unique_ptr< AVDictionary *, Deleter< AVDictionary *, void, av_dict_free > > | AVDictionaryCleanup | Cleanup wrapper for AVDictionary* values freed with av_dict_free(). |
std::unique_ptr< AVPacket, Deleterp< AVPacket, void, av_packet_free > > | AVPacketHolder | Owning AVPacket pointer released with av_packet_free(). |
std::vector< Format > | FormatList | List of container format value objects. |
std::vector< Format * > | FormatPList | List of container format pointers. |
IEncoder | IPacketEncoder | Legacy alias for IEncoder kept for 0.8.x compatibility. |
CodecList
std::list< Codec > CodecList()List of codec value objects.
CodecPList
std::list< Codec * > CodecPList()List of codec pointers.
AVFrameHolder
std::unique_ptr< AVFrame, Deleterp< AVFrame, void, av_frame_free > > AVFrameHolder()Owning AVFrame pointer released with av_frame_free().
AVFormatContextHolder
std::unique_ptr< AVFormatContext, Deleter< AVFormatContext, void, avformat_free_context > > AVFormatContextHolder()Owning AVFormatContext pointer released with avformat_free_context().
AVCodecContextHolder
std::unique_ptr< AVCodecContext, Deleterp< AVCodecContext, void, avcodec_free_context > > AVCodecContextHolder()Owning AVCodecContext pointer released with avcodec_free_context().
AVDictionaryCleanup
std::unique_ptr< AVDictionary *, Deleter< AVDictionary *, void, av_dict_free > > AVDictionaryCleanup()Cleanup wrapper for AVDictionary* values freed with av_dict_free().
AVPacketHolder
std::unique_ptr< AVPacket, Deleterp< AVPacket, void, av_packet_free > > AVPacketHolder()Owning AVPacket pointer released with av_packet_free().
FormatList
std::vector< Format > FormatList()List of container format value objects.
FormatPList
std::vector< Format * > FormatPList()List of container format pointers.
IPacketEncoder
IEncoder IPacketEncoder()Legacy alias for IEncoder kept for 0.8.x compatibility.
Functions
| Return | Name | Description |
|---|---|---|
int64_t | fpsToInterval inline | Convert a frame rate to a nanosecond frame interval. |
int | intervalToFps inline | Convert a nanosecond frame interval to a frame rate. |
float | intervalToFpsFloat inline | Convert a nanosecond frame interval to a floating-point frame rate. |
void | initializeFFmpeg | Initialize the FFmpeg library. |
void | uninitializeFFmpeg | Uninitializes the FFmpeg library. |
std::string | averror | Get an error string for the given error code. |
void | printInputFormats | Print all available FFmpeg demuxer (input) format names to the given stream. |
void | printOutputFormats | Print all available FFmpeg muxer (output) format names to the given stream. |
void | printEncoders | Print all available FFmpeg encoder names to the given stream. |
AVPacketHolder | makeOwnedPacket | Allocate an owning AVPacket with FFmpeg-required padding and timestamp metadata. The packet payload is copied into FFmpeg-managed storage, which is required by decoders such as H.264 that may overread AV_INPUT_BUFFER_PADDING_SIZE bytes. |
void | initAudioCodecFromContext | Populate an AudioCodec from an open AVCodecContext. |
AVSampleFormat | selectSampleFormat | Select the best supported sample format for a codec given the requested parameters. Returns the requested format if supported, otherwise the first format with the same planarity. |
bool | isSampleFormatSupported | Check whether a specific sample format is in the codec's supported list. |
bool | formatIsPlanar | Return true if the named sample format is planar (e.g. "fltp", "s16p"). |
bool | formatIsPlanar | Return true if the given AVSampleFormat is planar. |
AVFrame * | createVideoFrame | Allocate a new AVFrame with the given pixel format and dimensions. Uses av_frame_get_buffer for reference-counted allocation with 16-byte alignment. |
AVFrame * | cloneVideoFrame | Perform a deep copy of an AVFrame including its buffer data and properties. |
void | initVideoCodecFromContext | Populate a VideoCodec from an open AVStream and AVCodecContext. |
AVPixelFormat | selectPixelFormat | Select the best supported pixel format for a codec given the requested parameters. Returns the requested format if supported, otherwise the first format with the same plane count. |
fpsToInterval
inline
inline int64_t fpsToInterval(int fps)Convert a frame rate to a nanosecond frame interval.
Parameters
fpsThe frame rate in frames per second.
Returns
The interval in nanoseconds between frames, or the minimum interval if fps is zero.
intervalToFps
inline
inline int intervalToFps(int64_t interval)Convert a nanosecond frame interval to a frame rate.
Parameters
intervalThe nanosecond interval between frames.
Returns
The frame rate in frames per second, or zero if interval is zero.
intervalToFpsFloat
inline
inline float intervalToFpsFloat(int64_t interval)Convert a nanosecond frame interval to a floating-point frame rate.
Parameters
intervalThe nanosecond interval between frames.
Returns
The frame rate in frames per second as a float, or 0.0f if interval is zero.
initializeFFmpeg
void initializeFFmpeg()Initialize the FFmpeg library.
uninitializeFFmpeg
void uninitializeFFmpeg()Uninitializes the FFmpeg library.
averror
std::string averror(const int error)Get an error string for the given error code.
printInputFormats
void printInputFormats(std::ostream & ost, const char * delim)Print all available FFmpeg demuxer (input) format names to the given stream.
Parameters
ostThe output stream to write to.delimDelimiter inserted between each name.
printOutputFormats
void printOutputFormats(std::ostream & ost, const char * delim)Print all available FFmpeg muxer (output) format names to the given stream.
Parameters
ostThe output stream to write to.delimDelimiter inserted between each name.
printEncoders
void printEncoders(std::ostream & ost, const char * delim)Print all available FFmpeg encoder names to the given stream.
Parameters
ostThe output stream to write to.delimDelimiter inserted between each name.
makeOwnedPacket
AVPacketHolder makeOwnedPacket(const MediaPacket & packet, int streamIndex, AVRational timeBase)Allocate an owning AVPacket with FFmpeg-required padding and timestamp metadata. The packet payload is copied into FFmpeg-managed storage, which is required by decoders such as H.264 that may overread AV_INPUT_BUFFER_PADDING_SIZE bytes.
initAudioCodecFromContext
void initAudioCodecFromContext(const AVCodecContext * ctx, AudioCodec & params)Populate an AudioCodec from an open AVCodecContext.
Parameters
ctxThe FFmpeg codec context to read from.paramsThe AudioCodec struct to fill with codec, channel, sample rate, and format info.
selectSampleFormat
AVSampleFormat selectSampleFormat(const AVCodec * codec, av::AudioCodec & params)Select the best supported sample format for a codec given the requested parameters. Returns the requested format if supported, otherwise the first format with the same planarity.
Parameters
codecThe FFmpeg codec whose supported formats are queried.paramsThe audio codec parameters specifying the desired sample format.
Returns
The chosen AVSampleFormat, or AV_SAMPLE_FMT_NONE if none is compatible.
isSampleFormatSupported
bool isSampleFormatSupported(const AVCodec * codec, enum AVSampleFormat sampleFormat)Check whether a specific sample format is in the codec's supported list.
Parameters
codecThe FFmpeg codec to query.sampleFormatThe AVSampleFormat to look up.
Returns
True if the format is supported.
formatIsPlanar
bool formatIsPlanar(const std::string & pixfmt)Return true if the named sample format is planar (e.g. "fltp", "s16p").
Parameters
pixfmtThe sample format name string.
formatIsPlanar
bool formatIsPlanar(AVSampleFormat format)Return true if the given AVSampleFormat is planar.
Parameters
formatThe AVSampleFormat to check.
createVideoFrame
AVFrame * createVideoFrame(AVPixelFormat pixelFmt, int width, int height)Allocate a new AVFrame with the given pixel format and dimensions. Uses av_frame_get_buffer for reference-counted allocation with 16-byte alignment.
Parameters
pixelFmtThe pixel format for the frame.widthThe frame width in pixels.heightThe frame height in pixels.
Returns
A newly allocated AVFrame, or nullptr on failure.
cloneVideoFrame
AVFrame * cloneVideoFrame(AVFrame * source)Perform a deep copy of an AVFrame including its buffer data and properties.
Parameters
sourceThe source frame to copy.
Returns
A newly allocated AVFrame with copied data. Caller owns the result.
initVideoCodecFromContext
void initVideoCodecFromContext(const AVStream * stream, const AVCodecContext * ctx, VideoCodec & params)Populate a VideoCodec from an open AVStream and AVCodecContext.
Parameters
streamThe AVStream for frame rate information (may be null).ctxThe FFmpeg codec context to read from.paramsThe VideoCodec struct to fill with codec, dimension, and format info.
selectPixelFormat
AVPixelFormat selectPixelFormat(const AVCodec * codec, VideoCodec & params)Select the best supported pixel format for a codec given the requested parameters. Returns the requested format if supported, otherwise the first format with the same plane count.
Parameters
codecThe FFmpeg codec whose supported formats are queried.paramsThe video codec parameters specifying the desired pixel format.
Returns
The chosen AVPixelFormat.
