# AV module

<a id="avmodule"></a>

# AV module

Audio/video encoding, decoding, device capture, and media formats.

## Namespaces

| Name | Description |
|------|-------------|
| [`v4l2`](https://auscaster.com/icey/docs/api-reference/icy-av-v4l2.md#v4l2) | Linux V4L2 device enumeration helpers. |
| [`coreaudio`](https://auscaster.com/icey/docs/api-reference/icy-av-coreaudio.md#coreaudio) | Apple CoreAudio device enumeration helpers. |
| [`legacy`](https://auscaster.com/icey/docs/api-reference/icy-av-legacy.md#legacy) | Legacy timing helpers kept for compatibility with older media pipelines. |
| [`avfoundation`](https://auscaster.com/icey/docs/api-reference/icy-av-avfoundation.md#avfoundation) | Apple AVFoundation device enumeration helpers. |
| [`mediafoundation`](https://auscaster.com/icey/docs/api-reference/icy-av-mediafoundation.md#mediafoundation) | Windows Media Foundation device enumeration helpers. |
| [`wasapi`](https://auscaster.com/icey/docs/api-reference/icy-av-wasapi.md#wasapi) | Windows WASAPI device enumeration helpers. |

## Classes

| Name | Description |
|------|-------------|
| [`LinuxDeviceWatcher`](https://auscaster.com/icey/docs/api-reference/icy-av-LinuxDeviceWatcher.md#linuxdevicewatcher) | Monitors device add/remove events via libudev. |
| [`ICapture`](https://auscaster.com/icey/docs/api-reference/icy-av-ICapture.md#icapture) | Abstract interface for audio and video capture devices. |
| [`IEncoder`](https://auscaster.com/icey/docs/api-reference/icy-av-IEncoder.md#iencoder) | This is the abstract class for all encoders. |
| [`AppleDeviceWatcher`](https://auscaster.com/icey/docs/api-reference/icy-av-AppleDeviceWatcher.md#appledevicewatcher) | Monitors device add/remove events via AVFoundation notifications and CoreAudio property listeners. |
| [`FPSCounter`](https://auscaster.com/icey/docs/api-reference/icy-av-FPSCounter.md#fpscounter-2) | FPS counter based on the simple moving average (SMA) algorithm. |
| [`FPSLimiter`](https://auscaster.com/icey/docs/api-reference/icy-av-FPSLimiter.md#fpslimiter) | [PacketStream](https://auscaster.com/icey/docs/api-reference/icy-PacketStream.md#packetstream) processor that caps packet throughput to a maximum FPS. |
| [`AudioCapture`](https://auscaster.com/icey/docs/api-reference/icy-av-AudioCapture.md#audiocapture) | Cross-platform audio capture device backed by FFmpeg input devices. |
| [`MediaCapture`](https://auscaster.com/icey/docs/api-reference/icy-av-MediaCapture.md#mediacapture) | Unified capture and decode source for files and live media devices. |
| [`VideoCapture`](https://auscaster.com/icey/docs/api-reference/icy-av-VideoCapture.md#videocapture) | Cross-platform video device capturer backed by FFmpeg avdevice. |
| [`DeviceWatcher`](https://auscaster.com/icey/docs/api-reference/icy-av-DeviceWatcher.md#devicewatcher) | Base class for platform-specific device change monitors. |
| [`DeviceManager`](https://auscaster.com/icey/docs/api-reference/icy-av-DeviceManager.md#devicemanager) | Enumerates and manages system audio and video devices. |
| [`FormatRegistry`](https://auscaster.com/icey/docs/api-reference/icy-av-FormatRegistry.md#formatregistry) | [Singleton](https://auscaster.com/icey/docs/api-reference/icy-Singleton.md#singleton) registry of available media container formats for encoding and decoding. |
| [`WindowsDeviceWatcher`](https://auscaster.com/icey/docs/api-reference/icy-av-WindowsDeviceWatcher.md#windowsdevicewatcher) | Monitors device add/remove events via IMMNotificationClient (audio) and RegisterDeviceNotification (video). |
| [`MultiplexEncoder`](https://auscaster.com/icey/docs/api-reference/icy-av-MultiplexEncoder.md#multiplexencoder) | Multiplexing encoder that writes synchronized audio and video streams. |
| [`AudioPacketEncoder`](https://auscaster.com/icey/docs/api-reference/icy-av-AudioPacketEncoder.md#audiopacketencoder) | [PacketProcessor](https://auscaster.com/icey/docs/api-reference/icy-PacketProcessor.md#packetprocessor) that encodes raw audio samples ([PlanarAudioPacket](https://auscaster.com/icey/docs/api-reference/icy-av-PlanarAudioPacket.md#planaraudiopacket) or [AudioPacket](https://auscaster.com/icey/docs/api-reference/icy-av-AudioPacket.md#audiopacket)) into compressed packets via [AudioEncoder](https://auscaster.com/icey/docs/api-reference/icy-av-AudioEncoder.md#audioencoder). |
| [`VideoPacketEncoder`](https://auscaster.com/icey/docs/api-reference/icy-av-VideoPacketEncoder.md#videopacketencoder) | [PacketProcessor](https://auscaster.com/icey/docs/api-reference/icy-PacketProcessor.md#packetprocessor) that encodes raw video frames ([PlanarVideoPacket](https://auscaster.com/icey/docs/api-reference/icy-av-PlanarVideoPacket.md#planarvideopacket) or [VideoPacket](https://auscaster.com/icey/docs/api-reference/icy-av-VideoPacket.md#videopacket)) into compressed packets via [VideoEncoder](https://auscaster.com/icey/docs/api-reference/icy-av-VideoEncoder.md#videoencoder). |
| [`RealtimePacketQueue`](https://auscaster.com/icey/docs/api-reference/icy-av-RealtimePacketQueue.md#realtimepacketqueue) | [Queue](https://auscaster.com/icey/docs/api-reference/icy-Queue.md#queue-2) that emits media packets in presentation-timestamp order relative to a realtime clock. |
| [`MultiplexPacketEncoder`](https://auscaster.com/icey/docs/api-reference/icy-av-MultiplexPacketEncoder.md#multiplexpacketencoder) | Encodes and multiplexes a realtime video stream form audio / video capture sources. FFmpeg is used for encoding. |
| [`Codec`](https://auscaster.com/icey/docs/api-reference/icy-av-Codec.md#codec) | [Codec](https://auscaster.com/icey/docs/api-reference/icy-av-Codec.md#codec) for encoding/decoding media. |
| [`AudioCodec`](https://auscaster.com/icey/docs/api-reference/icy-av-AudioCodec.md#audiocodec) | Audio codec parameters including channels, sample rate, and sample format. |
| [`VideoCodec`](https://auscaster.com/icey/docs/api-reference/icy-av-VideoCodec.md#videocodec) | Video codec parameters including resolution, frame rate, and pixel format. |
| [`Deleter`](https://auscaster.com/icey/docs/api-reference/icy-av-Deleter.md#deleter-1) | RAII helpers for owning FFmpeg allocation types. |
| [`Deleterp`](https://auscaster.com/icey/docs/api-reference/icy-av-Deleterp.md#deleterp) | [Deleter](https://auscaster.com/icey/docs/api-reference/icy-av-Deleter.md#deleter-1) adaptor for functions like av_freep that take a pointer to a pointer. |
| [`Format`](https://auscaster.com/icey/docs/api-reference/icy-av-Format.md#format-5) | Defines a media container format which is available through the [FormatRegistry](https://auscaster.com/icey/docs/api-reference/icy-av-FormatRegistry.md#formatregistry) for encoding or decoding. |
| [`EncoderState`](https://auscaster.com/icey/docs/api-reference/icy-av-EncoderState.md#encoderstate) | [State](https://auscaster.com/icey/docs/api-reference/icy-State.md#state) machine states for the encoder pipeline. |
| [`EncoderOptions`](https://auscaster.com/icey/docs/api-reference/icy-av-EncoderOptions.md#encoderoptions) | [Configuration](https://auscaster.com/icey/docs/api-reference/icy-Configuration.md#configuration) options for audio and video encoders. |
| [`AudioBuffer`](https://auscaster.com/icey/docs/api-reference/icy-av-AudioBuffer.md#audiobuffer) | FIFO buffer for queuing audio samples between encoding stages. |
| [`AudioContext`](https://auscaster.com/icey/docs/api-reference/icy-av-AudioContext.md#audiocontext) | Base context for audio encoding and decoding via FFmpeg. |
| [`AudioDecoder`](https://auscaster.com/icey/docs/api-reference/icy-av-AudioDecoder.md#audiodecoder) | Decodes compressed audio packets into raw sample frames. |
| [`AudioEncoder`](https://auscaster.com/icey/docs/api-reference/icy-av-AudioEncoder.md#audioencoder) | Encodes raw audio samples into a compressed format. |
| [`VideoContext`](https://auscaster.com/icey/docs/api-reference/icy-av-VideoContext.md#videocontext) | Base video context from which all video encoders and decoders derive. |
| [`VideoDecoder`](https://auscaster.com/icey/docs/api-reference/icy-av-VideoDecoder.md#videodecoder) | Decodes compressed video packets into raw frames. |
| [`VideoEncoder`](https://auscaster.com/icey/docs/api-reference/icy-av-VideoEncoder.md#videoencoder) | Encodes raw video frames into a compressed format. |
| [`Device`](https://auscaster.com/icey/docs/api-reference/icy-av-Device.md#device) | Represents a system audio, video or render device. |
| [`AudioResampler`](https://auscaster.com/icey/docs/api-reference/icy-av-AudioResampler.md#audioresampler) | Converts audio samples between different formats, sample rates, and channel layouts. |
| [`VideoConverter`](https://auscaster.com/icey/docs/api-reference/icy-av-VideoConverter.md#videoconverter) | Converts video frames between pixel formats and resolutions. |
| [`MediaPacket`](https://auscaster.com/icey/docs/api-reference/icy-av-MediaPacket.md#mediapacket) | Timestamped media packet carrying raw audio or video data. |
| [`VideoPacket`](https://auscaster.com/icey/docs/api-reference/icy-av-VideoPacket.md#videopacket) | Video packet for interleaved formats. |
| [`PlanarVideoPacket`](https://auscaster.com/icey/docs/api-reference/icy-av-PlanarVideoPacket.md#planarvideopacket) | Video packet for planar formats. |
| [`AudioPacket`](https://auscaster.com/icey/docs/api-reference/icy-av-AudioPacket.md#audiopacket) | Audio packet for interleaved formats. |
| [`PlanarAudioPacket`](https://auscaster.com/icey/docs/api-reference/icy-av-PlanarAudioPacket.md#planaraudiopacket) | Audio packet for planar formats. |

## Macros

| Name | Description |
|------|-------------|
| [`MAX_VIDEO_PACKET_SIZE`](#max_video_packet_size)  |  |
| [`MAX_AUDIO_PACKET_SIZE`](#max_audio_packet_size)  | 1 second of 48khz 32bit audio |
| [`MAX_ENCODE_DURATION`](#max_encode_duration)  | 3 hours |
| [`INT64_C`](#int64_c)  |  |
| [`UINT64_C`](#uint64_c)  |  |
| [`AV_API`](#av_api)  |  |
| [`DEFAULT_AUDIO_SAMPLE_RATE`](#default_audio_sample_rate)  |  |
| [`DEFAULT_AUDIO_BIT_RATE`](#default_audio_bit_rate)  |  |
| [`DEFAULT_AUDIO_CHANNELS`](#default_audio_channels)  |  |
| [`DEFAULT_AUDIO_SAMPLE_FMT`](#default_audio_sample_fmt)  |  |
| [`DEFAULT_VIDEO_SAMPLE_RATE`](#default_video_sample_rate)  |  |
| [`DEFAULT_VIDEO_BIT_RATE`](#default_video_bit_rate)  |  |
| [`DEFAULT_VIDEO_PIXEL_FMT`](#default_video_pixel_fmt)  |  |

---

<a id="max_video_packet_size"></a>

### MAX_VIDEO_PACKET_SIZE

```cpp
#define MAX_VIDEO_PACKET_SIZE (3 * 1024 * 1024)
```

[Defined in src/av/include/icy/av/av.h:20](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/av.h#L20)

---

<a id="max_audio_packet_size"></a>

### MAX_AUDIO_PACKET_SIZE

```cpp
#define MAX_AUDIO_PACKET_SIZE (128 * 1500)
```

[Defined in src/av/include/icy/av/av.h:21](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/av.h#L21)

1 second of 48khz 32bit audio

---

<a id="max_encode_duration"></a>

### MAX_ENCODE_DURATION

```cpp
#define MAX_ENCODE_DURATION (3 * 60 * 60 * 1000)
```

[Defined in src/av/include/icy/av/av.h:22](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/av.h#L22)

3 hours

---

<a id="int64_c"></a>

### INT64_C

```cpp
#define INT64_C(c) (c##LL)
```

[Defined in src/av/include/icy/av/av.h:32](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/av.h#L32)

---

<a id="uint64_c"></a>

### UINT64_C

```cpp
#define UINT64_C(c) (c##ULL)
```

[Defined in src/av/include/icy/av/av.h:35](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/av.h#L35)

---

<a id="av_api"></a>

### AV_API

```cpp
#define AV_API ICY_IMPORT
```

[Defined in src/av/include/icy/av/av.h:43](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/av.h#L43)

---

<a id="default_audio_sample_rate"></a>

### DEFAULT_AUDIO_SAMPLE_RATE

```cpp
#define DEFAULT_AUDIO_SAMPLE_RATE 44100
```

[Defined in src/av/include/icy/av/codec.h:95](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/codec.h#L95)

---

<a id="default_audio_bit_rate"></a>

### DEFAULT_AUDIO_BIT_RATE

```cpp
#define DEFAULT_AUDIO_BIT_RATE 64000
```

[Defined in src/av/include/icy/av/codec.h:96](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/codec.h#L96)

---

<a id="default_audio_channels"></a>

### DEFAULT_AUDIO_CHANNELS

```cpp
#define DEFAULT_AUDIO_CHANNELS 2
```

[Defined in src/av/include/icy/av/codec.h:97](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/codec.h#L97)

---

<a id="default_audio_sample_fmt"></a>

### DEFAULT_AUDIO_SAMPLE_FMT

```cpp
#define DEFAULT_AUDIO_SAMPLE_FMT "s16"
```

[Defined in src/av/include/icy/av/codec.h:98](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/codec.h#L98)

---

<a id="default_video_sample_rate"></a>

### DEFAULT_VIDEO_SAMPLE_RATE

```cpp
#define DEFAULT_VIDEO_SAMPLE_RATE 384000
```

[Defined in src/av/include/icy/av/codec.h:163](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/codec.h#L163)

---

<a id="default_video_bit_rate"></a>

### DEFAULT_VIDEO_BIT_RATE

```cpp
#define DEFAULT_VIDEO_BIT_RATE 400000
```

[Defined in src/av/include/icy/av/codec.h:164](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/codec.h#L164)

---

<a id="default_video_pixel_fmt"></a>

### DEFAULT_VIDEO_PIXEL_FMT

```cpp
#define DEFAULT_VIDEO_PIXEL_FMT "yuv420p"
```

[Defined in src/av/include/icy/av/codec.h:165](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/codec.h#L165)

## Enumerations

| Name | Description |
|------|-------------|
| [`MediaCapabilities`](#mediacapabilities)  | Bitmask of media capabilities detected on this system. |

---

<a id="mediacapabilities"></a>

### MediaCapabilities

```cpp
enum MediaCapabilities
```

[Defined in src/av/include/icy/av/devicemanager.h:177](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/devicemanager.h#L177)

Bitmask 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`](https://auscaster.com/icey/docs/api-reference/icy-av-Codec.md#codec) > | [`CodecList`](#codeclist)  | List of codec value objects. |
| std::list< [`Codec`](https://auscaster.com/icey/docs/api-reference/icy-av-Codec.md#codec) * > | [`CodecPList`](#codecplist)  | List of codec pointers. |
| std::unique_ptr< AVFrame, [`Deleterp`](https://auscaster.com/icey/docs/api-reference/icy-av-Deleterp.md#deleterp)< AVFrame, void, av_frame_free > > | [`AVFrameHolder`](#avframeholder)  | Owning AVFrame pointer released with av_frame_free(). |
| std::unique_ptr< AVFormatContext, [`Deleter`](https://auscaster.com/icey/docs/api-reference/icy-av-Deleter.md#deleter-1)< AVFormatContext, void, avformat_free_context > > | [`AVFormatContextHolder`](#avformatcontextholder)  | Owning AVFormatContext pointer released with avformat_free_context(). |
| std::unique_ptr< AVCodecContext, [`Deleterp`](https://auscaster.com/icey/docs/api-reference/icy-av-Deleterp.md#deleterp)< AVCodecContext, void, avcodec_free_context > > | [`AVCodecContextHolder`](#avcodeccontextholder)  | Owning AVCodecContext pointer released with avcodec_free_context(). |
| std::unique_ptr< AVDictionary *, [`Deleter`](https://auscaster.com/icey/docs/api-reference/icy-av-Deleter.md#deleter-1)< AVDictionary *, void, av_dict_free > > | [`AVDictionaryCleanup`](#avdictionarycleanup)  | Cleanup wrapper for AVDictionary* values freed with av_dict_free(). |
| std::unique_ptr< AVPacket, [`Deleterp`](https://auscaster.com/icey/docs/api-reference/icy-av-Deleterp.md#deleterp)< AVPacket, void, av_packet_free > > | [`AVPacketHolder`](#avpacketholder)  | Owning AVPacket pointer released with av_packet_free(). |
| std::vector< [`Format`](https://auscaster.com/icey/docs/api-reference/icy-av-Format.md#format-5) > | [`FormatList`](#formatlist)  | List of container format value objects. |
| std::vector< [`Format`](https://auscaster.com/icey/docs/api-reference/icy-av-Format.md#format-5) * > | [`FormatPList`](#formatplist)  | List of container format pointers. |
| [`IEncoder`](https://auscaster.com/icey/docs/api-reference/icy-av-IEncoder.md#iencoder) | [`IPacketEncoder`](#ipacketencoder)  | Legacy alias for [IEncoder](https://auscaster.com/icey/docs/api-reference/icy-av-IEncoder.md#iencoder) kept for 0.8.x compatibility. |

---

<a id="codeclist"></a>

### CodecList

```cpp
using CodecList = std::list< Codec >
```

Type: std::list< [`Codec`](https://auscaster.com/icey/docs/api-reference/icy-av-Codec.md#codec) >

[Defined in src/av/include/icy/av/codec.h:231](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/codec.h#L231)

List of codec value objects.

---

<a id="codecplist"></a>

### CodecPList

```cpp
using CodecPList = std::list< Codec * >
```

Type: std::list< [`Codec`](https://auscaster.com/icey/docs/api-reference/icy-av-Codec.md#codec) * >

[Defined in src/av/include/icy/av/codec.h:232](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/codec.h#L232)

List of codec pointers.

---

<a id="avframeholder"></a>

### AVFrameHolder

```cpp
using AVFrameHolder = std::unique_ptr< AVFrame, Deleterp< AVFrame, void, av_frame_free > >
```

Type: std::unique_ptr< AVFrame, [`Deleterp`](https://auscaster.com/icey/docs/api-reference/icy-av-Deleterp.md#deleterp)< AVFrame, void, av_frame_free > >

[Defined in src/av/include/icy/av/ffmpeg.h:90](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/ffmpeg.h#L90)

Owning AVFrame pointer released with av_frame_free().

---

<a id="avformatcontextholder"></a>

### AVFormatContextHolder

```cpp
using AVFormatContextHolder = std::unique_ptr< AVFormatContext, Deleter< AVFormatContext, void, avformat_free_context > >
```

Type: std::unique_ptr< AVFormatContext, [`Deleter`](https://auscaster.com/icey/docs/api-reference/icy-av-Deleter.md#deleter-1)< AVFormatContext, void, avformat_free_context > >

[Defined in src/av/include/icy/av/ffmpeg.h:94](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/ffmpeg.h#L94)

Owning AVFormatContext pointer released with avformat_free_context().

---

<a id="avcodeccontextholder"></a>

### AVCodecContextHolder

```cpp
using AVCodecContextHolder = std::unique_ptr< AVCodecContext, Deleterp< AVCodecContext, void, avcodec_free_context > >
```

Type: std::unique_ptr< AVCodecContext, [`Deleterp`](https://auscaster.com/icey/docs/api-reference/icy-av-Deleterp.md#deleterp)< AVCodecContext, void, avcodec_free_context > >

[Defined in src/av/include/icy/av/ffmpeg.h:98](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/ffmpeg.h#L98)

Owning AVCodecContext pointer released with avcodec_free_context().

---

<a id="avdictionarycleanup"></a>

### AVDictionaryCleanup

```cpp
using AVDictionaryCleanup = std::unique_ptr< AVDictionary *, Deleter< AVDictionary *, void, av_dict_free > >
```

Type: std::unique_ptr< AVDictionary *, [`Deleter`](https://auscaster.com/icey/docs/api-reference/icy-av-Deleter.md#deleter-1)< AVDictionary *, void, av_dict_free > >

[Defined in src/av/include/icy/av/ffmpeg.h:102](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/ffmpeg.h#L102)

Cleanup wrapper for AVDictionary* values freed with av_dict_free().

---

<a id="avpacketholder"></a>

### AVPacketHolder

```cpp
using AVPacketHolder = std::unique_ptr< AVPacket, Deleterp< AVPacket, void, av_packet_free > >
```

Type: std::unique_ptr< AVPacket, [`Deleterp`](https://auscaster.com/icey/docs/api-reference/icy-av-Deleterp.md#deleterp)< AVPacket, void, av_packet_free > >

[Defined in src/av/include/icy/av/ffmpeg.h:106](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/ffmpeg.h#L106)

Owning AVPacket pointer released with av_packet_free().

---

<a id="formatlist"></a>

### FormatList

```cpp
using FormatList = std::vector< Format >
```

Type: std::vector< [`Format`](https://auscaster.com/icey/docs/api-reference/icy-av-Format.md#format-5) >

[Defined in src/av/include/icy/av/format.h:113](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/format.h#L113)

List of container format value objects.

---

<a id="formatplist"></a>

### FormatPList

```cpp
using FormatPList = std::vector< Format * >
```

Type: std::vector< [`Format`](https://auscaster.com/icey/docs/api-reference/icy-av-Format.md#format-5) * >

[Defined in src/av/include/icy/av/format.h:114](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/format.h#L114)

List of container format pointers.

---

<a id="ipacketencoder"></a>

### IPacketEncoder

```cpp
using IPacketEncoder = IEncoder
```

Type: [`IEncoder`](https://auscaster.com/icey/docs/api-reference/icy-av-IEncoder.md#iencoder)

[Defined in src/av/include/icy/av/iencoder.h:144](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/iencoder.h#L144)

Legacy alias for [IEncoder](https://auscaster.com/icey/docs/api-reference/icy-av-IEncoder.md#iencoder) kept for 0.8.x compatibility.

## Functions

| Return | Name | Description |
|--------|------|-------------|
| `int64_t` | [`fpsToInterval`](#fpstointerval) `inline` | Convert a frame rate to a nanosecond frame interval. |
| `int` | [`intervalToFps`](#intervaltofps) `inline` | Convert a nanosecond frame interval to a frame rate. |
| `float` | [`intervalToFpsFloat`](#intervaltofpsfloat) `inline` | Convert a nanosecond frame interval to a floating-point frame rate. |
| `void` | [`initializeFFmpeg`](#initializeffmpeg)  | Initialize the FFmpeg library. |
| `void` | [`uninitializeFFmpeg`](#uninitializeffmpeg)  | Uninitializes the FFmpeg library. |
| `std::string` | [`averror`](#averror)  | Get an error string for the given error code. |
| `void` | [`printInputFormats`](#printinputformats)  | Print all available FFmpeg demuxer (input) format names to the given stream. |
| `void` | [`printOutputFormats`](#printoutputformats)  | Print all available FFmpeg muxer (output) format names to the given stream. |
| `void` | [`printEncoders`](#printencoders)  | Print all available FFmpeg encoder names to the given stream. |
| [`AVPacketHolder`](#avpacketholder) | [`makeOwnedPacket`](#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`](#initaudiocodecfromcontext)  | Populate an [AudioCodec](https://auscaster.com/icey/docs/api-reference/icy-av-AudioCodec.md#audiocodec) from an open AVCodecContext. |
| `AVSampleFormat` | [`selectSampleFormat`](#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`](#issampleformatsupported)  | Check whether a specific sample format is in the codec's supported list. |
| `bool` | [`formatIsPlanar`](#formatisplanar)  | Return true if the named sample format is planar (e.g. "fltp", "s16p"). |
| `bool` | [`formatIsPlanar`](#formatisplanar-1)  | Return true if the given AVSampleFormat is planar. |
| `AVFrame *` | [`createVideoFrame`](#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`](#clonevideoframe)  | Perform a deep copy of an AVFrame including its buffer data and properties. |
| `void` | [`initVideoCodecFromContext`](#initvideocodecfromcontext)  | Populate a [VideoCodec](https://auscaster.com/icey/docs/api-reference/icy-av-VideoCodec.md#videocodec) from an open AVStream and AVCodecContext. |
| `AVPixelFormat` | [`selectPixelFormat`](#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. |
| `std::optional< std::pair< const AVInputFormat *, std::string > >` | [`parseDeviceUrl`](#parsedeviceurl)  | Parse a libavdevice URL scheme. |

---

<a id="fpstointerval"></a>

### fpsToInterval

`inline`

```cpp
inline int64_t fpsToInterval(int fps)
```

[Defined in src/av/include/icy/av/codec.h:241](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/codec.h#L241)

Convert a frame rate to a nanosecond frame interval. 
#### Returns
The interval in nanoseconds between frames, or the minimum interval if fps is zero.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `fps` | `int` | The frame rate in frames per second. |

---

<a id="intervaltofps"></a>

### intervalToFps

`inline`

```cpp
inline int intervalToFps(int64_t interval)
```

[Defined in src/av/include/icy/av/codec.h:251](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/codec.h#L251)

Convert a nanosecond frame interval to a frame rate. 
#### Returns
The frame rate in frames per second, or zero if interval is zero.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `interval` | `int64_t` | The nanosecond interval between frames. |

---

<a id="intervaltofpsfloat"></a>

### intervalToFpsFloat

`inline`

```cpp
inline float intervalToFpsFloat(int64_t interval)
```

[Defined in src/av/include/icy/av/codec.h:263](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/codec.h#L263)

Convert a nanosecond frame interval to a floating-point frame rate. 
#### Returns
The frame rate in frames per second as a float, or 0.0f if interval is zero.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `interval` | `int64_t` | The nanosecond interval between frames. |

---

<a id="initializeffmpeg"></a>

### initializeFFmpeg

```cpp
void initializeFFmpeg()
```

[Defined in src/av/include/icy/av/ffmpeg.h:39](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/ffmpeg.h#L39)

Initialize the FFmpeg library.

---

<a id="uninitializeffmpeg"></a>

### uninitializeFFmpeg

```cpp
void uninitializeFFmpeg()
```

[Defined in src/av/include/icy/av/ffmpeg.h:42](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/ffmpeg.h#L42)

Uninitializes the FFmpeg library.

---

<a id="averror"></a>

### averror

```cpp
std::string averror(const int error)
```

[Defined in src/av/include/icy/av/ffmpeg.h:45](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/ffmpeg.h#L45)

Get an error string for the given error code.

---

<a id="printinputformats"></a>

### printInputFormats

```cpp
void printInputFormats(std::ostream & ost, const char * delim = " ")
```

[Defined in src/av/include/icy/av/ffmpeg.h:50](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/ffmpeg.h#L50)

Print all available FFmpeg demuxer (input) format names to the given stream.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `ost` | `std::ostream &` | The output stream to write to. |
| `delim` | `const char *` | Delimiter inserted between each name. |

---

<a id="printoutputformats"></a>

### printOutputFormats

```cpp
void printOutputFormats(std::ostream & ost, const char * delim = " ")
```

[Defined in src/av/include/icy/av/ffmpeg.h:55](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/ffmpeg.h#L55)

Print all available FFmpeg muxer (output) format names to the given stream.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `ost` | `std::ostream &` | The output stream to write to. |
| `delim` | `const char *` | Delimiter inserted between each name. |

---

<a id="printencoders"></a>

### printEncoders

```cpp
void printEncoders(std::ostream & ost, const char * delim = " ")
```

[Defined in src/av/include/icy/av/ffmpeg.h:60](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/ffmpeg.h#L60)

Print all available FFmpeg encoder names to the given stream.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `ost` | `std::ostream &` | The output stream to write to. |
| `delim` | `const char *` | Delimiter inserted between each name. |

---

<a id="makeownedpacket"></a>

### makeOwnedPacket

```cpp
AVPacketHolder makeOwnedPacket(const MediaPacket & packet, int streamIndex, AVRational timeBase)
```

[Defined in src/av/include/icy/av/ffmpeg.h:113](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/ffmpeg.h#L113)

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.

---

<a id="initaudiocodecfromcontext"></a>

### initAudioCodecFromContext

```cpp
void initAudioCodecFromContext(const AVCodecContext * ctx, AudioCodec & params)
```

[Defined in src/av/include/icy/av/audiocontext.h:112](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/audiocontext.h#L112)

Populate an [AudioCodec](https://auscaster.com/icey/docs/api-reference/icy-av-AudioCodec.md#audiocodec) from an open AVCodecContext.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `ctx` | `const AVCodecContext *` | The FFmpeg codec context to read from. |
| `params` | [`AudioCodec`](https://auscaster.com/icey/docs/api-reference/icy-av-AudioCodec.md#audiocodec) & | The [AudioCodec](https://auscaster.com/icey/docs/api-reference/icy-av-AudioCodec.md#audiocodec) struct to fill with codec, channel, sample rate, and format info. |

---

<a id="selectsampleformat"></a>

### selectSampleFormat

```cpp
AVSampleFormat selectSampleFormat(const AVCodec * codec, av::AudioCodec & params)
```

[Defined in src/av/include/icy/av/audiocontext.h:119](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/audiocontext.h#L119)

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. 
#### Returns
The chosen AVSampleFormat, or AV_SAMPLE_FMT_NONE if none is compatible.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `codec` | `const AVCodec *` | The FFmpeg codec whose supported formats are queried. |
| `params` | [`av::AudioCodec`](https://auscaster.com/icey/docs/api-reference/icy-av-AudioCodec.md#audiocodec) & | The audio codec parameters specifying the desired sample format. |

---

<a id="issampleformatsupported"></a>

### isSampleFormatSupported

```cpp
bool isSampleFormatSupported(const AVCodec * codec, enum AVSampleFormat sampleFormat)
```

[Defined in src/av/include/icy/av/audiocontext.h:125](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/audiocontext.h#L125)

Check whether a specific sample format is in the codec's supported list. 
#### Returns
True if the format is supported.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `codec` | `const AVCodec *` | The FFmpeg codec to query. |
| `sampleFormat` | `enum AVSampleFormat` | The AVSampleFormat to look up. |

---

<a id="formatisplanar"></a>

### formatIsPlanar

```cpp
bool formatIsPlanar(const std::string & pixfmt)
```

[Defined in src/av/include/icy/av/audiocontext.h:129](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/audiocontext.h#L129)

Return true if the named sample format is planar (e.g. "fltp", "s16p").

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `pixfmt` | `const std::string &` | The sample format name string. |

---

<a id="formatisplanar-1"></a>

### formatIsPlanar

```cpp
bool formatIsPlanar(AVSampleFormat format)
```

[Defined in src/av/include/icy/av/audiocontext.h:133](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/audiocontext.h#L133)

Return true if the given AVSampleFormat is planar.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `format` | `AVSampleFormat` | The AVSampleFormat to check. |

---

<a id="createvideoframe"></a>

### createVideoFrame

```cpp
AVFrame * createVideoFrame(AVPixelFormat pixelFmt, int width, int height)
```

[Defined in src/av/include/icy/av/videocontext.h:130](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/videocontext.h#L130)

Allocate a new AVFrame with the given pixel format and dimensions. Uses av_frame_get_buffer for reference-counted allocation with 16-byte alignment. 
#### Returns
A newly allocated AVFrame, or nullptr on failure.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `pixelFmt` | `AVPixelFormat` | The pixel format for the frame. |
| `width` | `int` | The frame width in pixels. |
| `height` | `int` | The frame height in pixels. |

---

<a id="clonevideoframe"></a>

### cloneVideoFrame

```cpp
AVFrame * cloneVideoFrame(AVFrame * source)
```

[Defined in src/av/include/icy/av/videocontext.h:135](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/videocontext.h#L135)

Perform a deep copy of an AVFrame including its buffer data and properties. 
#### Returns
A newly allocated AVFrame with copied data. Caller owns the result.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `source` | `AVFrame *` | The source frame to copy. |

---

<a id="initvideocodecfromcontext"></a>

### initVideoCodecFromContext

```cpp
void initVideoCodecFromContext(const AVStream * stream, const AVCodecContext * ctx, VideoCodec & params)
```

[Defined in src/av/include/icy/av/videocontext.h:141](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/videocontext.h#L141)

Populate a [VideoCodec](https://auscaster.com/icey/docs/api-reference/icy-av-VideoCodec.md#videocodec) from an open AVStream and AVCodecContext.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `stream` | `const AVStream *` | The AVStream for frame rate information (may be null). |
| `ctx` | `const AVCodecContext *` | The FFmpeg codec context to read from. |
| `params` | [`VideoCodec`](https://auscaster.com/icey/docs/api-reference/icy-av-VideoCodec.md#videocodec) & | The [VideoCodec](https://auscaster.com/icey/docs/api-reference/icy-av-VideoCodec.md#videocodec) struct to fill with codec, dimension, and format info. |

---

<a id="selectpixelformat"></a>

### selectPixelFormat

```cpp
AVPixelFormat selectPixelFormat(const AVCodec * codec, VideoCodec & params)
```

[Defined in src/av/include/icy/av/videocontext.h:148](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/videocontext.h#L148)

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. 
#### Returns
The chosen AVPixelFormat.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `codec` | `const AVCodec *` | The FFmpeg codec whose supported formats are queried. |
| `params` | [`VideoCodec`](https://auscaster.com/icey/docs/api-reference/icy-av-VideoCodec.md#videocodec) & | The video codec parameters specifying the desired pixel format. |

---

<a id="parsedeviceurl"></a>

### parseDeviceUrl

```cpp
std::optional< std::pair< const AVInputFormat *, std::string > > parseDeviceUrl(std::string_view source)
```

[Defined in src/av/include/icy/av/devicemanager.h:358](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/devicemanager.h#L358)

Parse a libavdevice URL scheme.

Recognises: avfoundation:<spec> (macOS, e.g. "0:0", "0:none") [v4l2](https://auscaster.com/icey/docs/api-reference/icy-av-v4l2.md#v4l2):<path> (Linux, e.g. "/dev/video0") dshow:<spec> (Windows, e.g. "video=Logitech HD WebCam")

On match returns the libavformat input format (looked up via `av_find_input_format`) and the portion of `source` after the scheme prefix. Returns `std::nullopt` for non-device sources (file paths, `rtsp://`, `rtmp://`, etc.), leaving the caller to use FFmpeg's auto-detection.

Throws `std::runtime_error` if a recognised scheme has no matching input format on this build (libavdevice not linked, or the backend is not compiled in on this platform).

## Variables

| Return | Name | Description |
|--------|------|-------------|
| `constexpr int` | [`kMaxPlanarAudioPlanes`](#kmaxplanaraudioplanes) `static` `constexpr` |  |

---

<a id="kmaxplanaraudioplanes"></a>

### kMaxPlanarAudioPlanes

`static` `constexpr`

```cpp
constexpr int kMaxPlanarAudioPlanes = 8
```

[Defined in src/av/include/icy/av/packet.h:26](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/packet.h#L26)
