Home
AV module

VideoEncoder

Encodes raw video frames into a compressed format.

VideoEncoder

#include <icy/av/videoencoder.h>
struct VideoEncoder

Defined in src/av/include/icy/av/videoencoder.h:30

Inherits: VideoContext Subclassed by: VideoPacketEncoder

Encodes raw video frames into a compressed format.

List of all members

NameKindOwner
formatvariableDeclared here
VideoEncoderfunctionDeclared here
~VideoEncoderfunctionDeclared here
createfunctionDeclared here
closefunctionDeclared here
encodefunctionDeclared here
encodefunctionDeclared here
encodefunctionDeclared here
flushfunctionDeclared here
emittervariableInherited from VideoContext
iparamsvariableInherited from VideoContext
oparamsvariableInherited from VideoContext
streamvariableInherited from VideoContext
ctxvariableInherited from VideoContext
codecvariableInherited from VideoContext
framevariableInherited from VideoContext
convvariableInherited from VideoContext
timevariableInherited from VideoContext
ptsvariableInherited from VideoContext
secondsvariableInherited from VideoContext
errorvariableInherited from VideoContext
VideoContextfunctionInherited from VideoContext
~VideoContextfunctionInherited from VideoContext
VideoContextfunctionInherited from VideoContext
operator=functionInherited from VideoContext
VideoContextfunctionInherited from VideoContext
operator=functionInherited from VideoContext
createfunctionInherited from VideoContext
openfunctionInherited from VideoContext
closefunctionInherited from VideoContext
decodefunctionInherited from VideoContext
encodefunctionInherited from VideoContext
encodefunctionInherited from VideoContext
encodefunctionInherited from VideoContext
flushfunctionInherited from VideoContext
convertfunctionInherited from VideoContext
recreateConverterfunctionInherited from VideoContext

Inherited from VideoContext

KindNameDescription
variableemitter
variableiparamsinput parameters
variableoparamsoutput parameters
variablestreamencoder or decoder stream
variablectxencoder or decoder context
variablecodecencoder or decoder codec
variableframeencoder or decoder frame
variableconvvideo conversion context
variabletimestream time in codec time base
variableptslast packet pts value
variablesecondsvideo time in seconds
variableerrorerror message
functionVideoContext
function~VideoContext virtual noexcept
functionVideoContextDeleted constructor.
functionoperator=Deleted assignment operator.
functionVideoContextDeleted constructor.
functionoperator=Deleted assignment operator.
functioncreate virtualInitialise the AVCodecContext with codec-specific defaults. Overridden by VideoEncoder and VideoDecoder.
functionopen virtualOpen the codec and create the pixel format conversion context if required. Throws std::runtime_error if the codec context has not been created.
functionclose virtualClose the codec context, free the frame, and reset timestamps.
functiondecode virtualDecode a compressed video packet and emit the resulting frame.
functionencode virtualEncode a buffer of interleaved video data.
functionencode virtualEncode a planar video frame.
functionencode virtualEncode a single AVFrame.
functionflush virtualFlush any frames buffered inside the codec and emit remaining output.
functionconvert virtualConvert the video frame and return the result.
functionrecreateConverter virtualRecreate the VideoConverter if the input or output parameters have changed. Called automatically by open() and convert().

Public Attributes

ReturnNameDescription
AVFormatContext *format

format

AVFormatContext * format

Defined in src/av/include/icy/av/videoencoder.h:69

Public Methods

ReturnNameDescription
VideoEncoderConstruct an encoder, optionally tied to an existing muxer context.
voidcreate virtual overrideInitialise the AVCodecContext using oparams. Adds a video stream to format if one was provided at construction.
voidclose virtual overrideClose and free the AVCodecContext and associated resources.
boolencode virtual overrideEncode a single video frame. This method is for interleaved video formats.
boolencode virtual overrideEncode a single video frame. This method is for planar video formats.
boolencode virtual overrideEncode a single AVFrame (typically from a decoder or converter).
voidflush virtual overrideFlush remaining packets to be encoded. This method should be called once before stream closure.

VideoEncoder

VideoEncoder(AVFormatContext * format = nullptr)

Defined in src/av/include/icy/av/videoencoder.h:34

Construct an encoder, optionally tied to an existing muxer context.

Parameters

  • format The AVFormatContext that will receive encoded packets, or nullptr for standalone use.

create

virtual override

virtual void create() override

Defined in src/av/include/icy/av/videoencoder.h:39

Initialise the AVCodecContext using oparams. Adds a video stream to format if one was provided at construction.

Reimplements

close

virtual override

virtual void close() override

Defined in src/av/include/icy/av/videoencoder.h:42

Close and free the AVCodecContext and associated resources.

Reimplements

encode

virtual override

virtual bool encode(uint8_t * data, int size, int64_t pts) override

Defined in src/av/include/icy/av/videoencoder.h:50

Encode a single video frame. This method is for interleaved video formats.

Parameters

  • data The raw video frame buffer.

  • size The buffer size in bytes.

  • pts The presentation timestamp in stream time base units.

Reimplements

encode

virtual override

virtual bool encode(uint8_t * data, int linesize, int64_t pts) override

Defined in src/av/include/icy/av/videoencoder.h:58

Encode a single video frame. This method is for planar video formats.

Parameters

  • data Array of per-plane data pointers (up to 4 planes).

  • linesize Array of per-plane byte strides.

  • pts The presentation timestamp in stream time base units.

Reimplements

encode

virtual override

virtual bool encode(AVFrame * iframe) override

Defined in src/av/include/icy/av/videoencoder.h:63

Encode a single AVFrame (typically from a decoder or converter).

Parameters

  • iframe The source video frame with all fields set.

Returns

True if an encoded packet was produced and emitted.

Reimplements

flush

virtual override

virtual void flush() override

Defined in src/av/include/icy/av/videoencoder.h:67

Flush remaining packets to be encoded. This method should be called once before stream closure.

Reimplements