#include <icy/av/multiplexencoder.h>Inherits:
IEncoderSubclassed by:MultiplexPacketEncoder
Multiplexing encoder that writes synchronized audio and video streams.
| Return | Name | Description |
|---|---|---|
PacketSignal | emitter |
PacketSignal emitter| Return | Name | Description |
|---|---|---|
MultiplexEncoder | Construct the encoder with the given options. | |
MultiplexEncoder | Deleted constructor. | |
MultiplexEncoder | Deleted constructor. | |
void | init virtual | Open the output container, create codec streams, and write the format header. |
void | uninit virtual | Flush encoded packets, write the format trailer, and close the output container. |
void | cleanup virtual | Release all resources allocated by init() without writing a trailer. |
void | createVideo virtual | Create the video encoder and add the stream to the output container. |
void | freeVideo virtual | Flush and free the video encoder and its stream. |
bool | encodeVideo virtual | Encode a single video frame. All frame values must be set, such as size, pixel format, and PTS. |
bool | encodeVideo virtual | Encode a single interleaved video frame. If the frame time is specified it should be the microseconds offset since the start of the input stream. If no time is specified a real-time value will be assigned to the frame. |
bool | encodeVideo virtual | Encode a single planar video frame. |
void | createAudio virtual | Create the audio encoder and add the stream to the output container. |
void | freeAudio virtual | Flush and free the audio encoder and its stream. |
bool | encodeAudio virtual | Encode a single interleaved audio frame. |
bool | encodeAudio virtual | Encode a single planar audio frame. |
void | flush virtual | Flush any buffered or queued packets to the output container. |
const EncoderOptions & | options virtual const | #### Returns |
VideoEncoder * | video | #### Returns |
AudioEncoder * | audio | #### Returns |
MultiplexEncoder(const EncoderOptions & options)Construct the encoder with the given options.
options The encoder configuration (input/output formats and file paths).MultiplexEncoder(const MultiplexEncoder &) = deleteDeleted constructor.
MultiplexEncoder(MultiplexEncoder &&) = deleteDeleted constructor.
virtual
virtual void init()Open the output container, create codec streams, and write the format header.
virtual
virtual void uninit()Flush encoded packets, write the format trailer, and close the output container.
virtual
virtual void cleanup()Release all resources allocated by init() without writing a trailer.
virtual
virtual void createVideo()Create the video encoder and add the stream to the output container.
virtual
virtual void freeVideo()Flush and free the video encoder and its stream.
virtual
virtual bool encodeVideo(AVFrame * frame)Encode a single video frame. All frame values must be set, such as size, pixel format, and PTS.
virtual
virtual bool encodeVideo(uint8_t * buffer, int bufferSize, int width, int height, int64_t time)Encode a single interleaved video frame. If the frame time is specified it should be the microseconds offset since the start of the input stream. If no time is specified a real-time value will be assigned to the frame.
buffer The raw video frame buffer.
bufferSize The buffer size in bytes.
width The frame width in pixels.
height The frame height in pixels.
time The timestamp in microseconds, or AV_NOPTS_VALUE for realtime.
virtual
virtual bool encodeVideo(uint8_t * data, int linesize, int width, int height, int64_t time)Encode a single planar video frame.
data Array of per-plane data pointers (up to 4 planes).
linesize Array of per-plane byte strides.
width The frame width in pixels.
height The frame height in pixels.
time The timestamp in microseconds, or AV_NOPTS_VALUE for realtime.
virtual
virtual void createAudio()Create the audio encoder and add the stream to the output container.
virtual
virtual void freeAudio()Flush and free the audio encoder and its stream.
virtual
virtual bool encodeAudio(uint8_t * buffer, int numSamples, int64_t time)Encode a single interleaved audio frame.
buffer The interleaved audio sample buffer.
numSamples The number of samples per channel.
time The timestamp in microseconds, or AV_NOPTS_VALUE for realtime.
virtual
virtual bool encodeAudio(uint8_t * data, int numSamples, int64_t time)Encode a single planar audio frame.
data Array of per-plane sample buffers (one per channel).
numSamples The number of samples per channel.
time The timestamp in microseconds, or AV_NOPTS_VALUE for realtime.
virtual
virtual void flush()Flush any buffered or queued packets to the output container.
virtual const
virtual const EncoderOptions & options() constA read-only view of the encoder's configuration options.
VideoEncoder * video()The active VideoEncoder, or nullptr if video has not been created.
AudioEncoder * audio()The active AudioEncoder, or nullptr if audio has not been created.
| Return | Name | Description |
|---|---|---|
EncoderOptions | _options | |
AVFormatContext * | _formatCtx | |
std::unique_ptr< VideoEncoder > | _video | |
std::unique_ptr< AudioEncoder > | _audio | |
AVIOContext * | _ioCtx | |
std::unique_ptr< uint8_t[]> | _ioBuffer | |
int64_t | _pts | |
std::mutex | _mutex |
EncoderOptions _optionsAVFormatContext * _formatCtxstd::unique_ptr< VideoEncoder > _videostd::unique_ptr< AudioEncoder > _audioAVIOContext * _ioCtxstd::unique_ptr< uint8_t[]> _ioBufferint64_t _ptsstd::mutex _mutex| Return | Name | Description |
|---|---|---|
bool | writeOutputPacket | |
bool | updateStreamPts | Convert input microseconds to the stream time base. |
void | onVideoEncoded | |
void | onAudioEncoded |
bool writeOutputPacket(AVPacket & packet)bool updateStreamPts(AVStream * stream, int64_t * pts)Convert input microseconds to the stream time base.
stream The target stream for time base conversion.
pts Pointer to the timestamp; converted in place.
void onVideoEncoded(av::VideoPacket & packet)void onAudioEncoded(av::AudioPacket & packet)