FFmpeg-backed RGBA video writer. More...
#include <MXWrite/mxwrite.hpp>
Public Member Functions | |
| void | close () |
| Close the writer and flush pending packets. | |
| bool | get_block_when_full () const |
| Check whether the encoder queue blocks instead of dropping frames. | |
| std::uint64_t | get_bytes_written () const |
| Return the current logical byte position of the output muxer. | |
| double | get_duration () const |
| Return the encoded duration in seconds. | |
| int64_t | get_frame_count () const |
| Return the output timeline length in nominal frame ticks. | |
| bool | is_hardware_encode () const |
| True when FFmpeg identifies the active encoder as hardware or hybrid. | |
| bool | is_open () const |
| Check whether the writer is currently open. | |
| bool | open (const std::string &filename, int width, int height, float fps, const char *crf) |
| Open an output file using the legacy CRF string interface. | |
| bool | open (const std::string &filename, int width, int height, float fps, const EncodeOptions &opts) |
| Open an output file using explicit encoder options. | |
| bool | open_ts (const std::string &filename, int width, int height, float fps, const char *crf) |
| Open a timestamp-based output stream using the legacy CRF string interface. | |
| bool | open_ts (const std::string &filename, int width, int height, float fps, const EncodeOptions &opts) |
| Open a timestamp-based output stream using explicit encoder options. | |
| void | set_block_when_full (bool value) |
| If true, keep one pending frame and pace producer threads to the encoder instead of dropping frames. Intended for headless/batch transcoding where every input frame must reach the output. Default: false. | |
| void | write (void *rgba_buffer) |
| Queue a host RGBA frame for immediate-mode encoding. | |
| void | write_at_pts (void *rgba_buffer, int64_t pts) |
| Queue a host RGBA frame with an explicit presentation timestamp. | |
| bool | write_cuda_rgba (void *cuda_rgba_buffer, int src_stride, bool bottom_up=false) |
| Queue a CUDA RGBA frame for encoding. | |
| bool | write_cuda_rgba_at_pts (void *cuda_rgba_buffer, int src_stride, int64_t pts, bool bottom_up=false) |
| Queue a CUDA RGBA frame with an explicit presentation timestamp. | |
| void | write_hdr_rgba16 (void *rgba16_buffer) |
| Write a 16-bit RGBA frame that is already PQ- or HLG-encoded in BT.2020 primaries (8 bytes/pixel: R16,G16,B16,A16, little-endian unsigned normalised). | |
| void | write_hdr_rgba16_at_pts (void *rgba16_buffer, int64_t pts) |
| Queue a 16-bit HDR RGBA frame with an explicit presentation timestamp. | |
| void | write_ts (void *rgba_buffer) |
| Queue a host RGBA frame using capture timestamps. | |
| Writer ()=default | |
| Construct a closed writer. | |
| ~Writer () | |
| Close the writer on destruction if it is still open. | |
FFmpeg-backed RGBA video writer.
The writer accepts host RGBA buffers, optional CUDA device buffers, and 16-bit HDR RGBA buffers. It can encode either frame-by-frame or from timestamped frames, depending on the open mode.
Definition at line 139 of file mxwrite.hpp.
|
default |
Construct a closed writer.
|
inline |
Close the writer on destruction if it is still open.
Definition at line 266 of file mxwrite.hpp.
| void Writer::close | ( | ) |
Close the writer and flush pending packets.
Definition at line 2425 of file mxwrite.cpp.
|
inline |
Check whether the encoder queue blocks instead of dropping frames.
Definition at line 250 of file mxwrite.hpp.
|
inline |
Return the current logical byte position of the output muxer.
Definition at line 260 of file mxwrite.hpp.
| double Writer::get_duration | ( | ) | const |
Return the encoded duration in seconds.
Definition at line 2483 of file mxwrite.cpp.
|
inline |
Return the output timeline length in nominal frame ticks.
For sequential writes this equals the submitted frame count. Explicit PTS writes may leave gaps, in which case it is the highest accepted PTS plus one.
Definition at line 258 of file mxwrite.hpp.
|
inline |
True when FFmpeg identifies the active encoder as hardware or hybrid.
Definition at line 244 of file mxwrite.hpp.
|
inline |
Check whether the writer is currently open.
Definition at line 242 of file mxwrite.hpp.
| bool Writer::open | ( | const std::string & | filename, |
| int | width, | ||
| int | height, | ||
| float | fps, | ||
| const char * | crf ) |
Open an output file using the legacy CRF string interface.
| filename | Output file path. |
| width | Output width in pixels. |
| height | Output height in pixels. |
| fps | Output frame rate. |
| crf | Constant Rate Factor as a string. |
Definition at line 1039 of file mxwrite.cpp.
| bool Writer::open | ( | const std::string & | filename, |
| int | width, | ||
| int | height, | ||
| float | fps, | ||
| const EncodeOptions & | opts ) |
Open an output file using explicit encoder options.
| filename | Output file path. |
| width | Output width in pixels. |
| height | Output height in pixels. |
| fps | Output frame rate. |
| opts | Encoder configuration. |
Definition at line 1055 of file mxwrite.cpp.
| bool Writer::open_ts | ( | const std::string & | filename, |
| int | width, | ||
| int | height, | ||
| float | fps, | ||
| const char * | crf ) |
Open a timestamp-based output stream using the legacy CRF string interface.
| filename | Output file path. |
| width | Output width in pixels. |
| height | Output height in pixels. |
| fps | Nominal input frame rate. |
| crf | Constant Rate Factor as a string. |
Definition at line 1060 of file mxwrite.cpp.
| bool Writer::open_ts | ( | const std::string & | filename, |
| int | width, | ||
| int | height, | ||
| float | fps, | ||
| const EncodeOptions & | opts ) |
Open a timestamp-based output stream using explicit encoder options.
| filename | Output file path. |
| width | Output width in pixels. |
| height | Output height in pixels. |
| fps | Nominal input frame rate. |
| opts | Encoder configuration. |
Definition at line 1075 of file mxwrite.cpp.
|
inline |
If true, keep one pending frame and pace producer threads to the encoder instead of dropping frames. Intended for headless/batch transcoding where every input frame must reach the output. Default: false.
Definition at line 248 of file mxwrite.hpp.
| void Writer::write | ( | void * | rgba_buffer | ) |
Queue a host RGBA frame for immediate-mode encoding.
| rgba_buffer | Pointer to tightly packed RGBA8 pixels. |
Definition at line 1859 of file mxwrite.cpp.
| void Writer::write_at_pts | ( | void * | rgba_buffer, |
| int64_t | pts ) |
Queue a host RGBA frame with an explicit presentation timestamp.
| rgba_buffer | Pointer to tightly packed RGBA8 pixels. |
| pts | Presentation timestamp in units of the configured frame time base. |
Definition at line 1863 of file mxwrite.cpp.
| bool Writer::write_cuda_rgba | ( | void * | cuda_rgba_buffer, |
| int | src_stride, | ||
| bool | bottom_up = false ) |
Queue a CUDA RGBA frame for encoding.
| cuda_rgba_buffer | CUDA device pointer. |
| src_stride | Source row pitch in bytes. |
| bottom_up | Whether the source is stored bottom-up. |
Definition at line 2072 of file mxwrite.cpp.
| bool Writer::write_cuda_rgba_at_pts | ( | void * | cuda_rgba_buffer, |
| int | src_stride, | ||
| int64_t | pts, | ||
| bool | bottom_up = false ) |
Queue a CUDA RGBA frame with an explicit presentation timestamp.
| cuda_rgba_buffer | CUDA device pointer. |
| src_stride | Source row pitch in bytes. |
| pts | Presentation timestamp in units of the configured frame time base. |
| bottom_up | Whether the source is stored bottom-up. |
Definition at line 2077 of file mxwrite.cpp.
| void Writer::write_hdr_rgba16 | ( | void * | rgba16_buffer | ) |
Write a 16-bit RGBA frame that is already PQ- or HLG-encoded in BT.2020 primaries (8 bytes/pixel: R16,G16,B16,A16, little-endian unsigned normalised).
The data is expected to originate from the HDR GPU encode pass: it is BT.2020 primaries with a non-linear PQ (or HLG) transfer already applied, so this path skips colour-space conversion and only performs (a) the BT.2020 non-constant-luminance RGB'->YCbCr' matrix, and (b) 16-bit -> 10-bit limited-range scaling, producing AV_PIX_FMT_YUV420P10LE for libx265 Main10. Requires the writer to have been opened with EncodeOptions::HdrInfo::enabled.
| rgba16_buffer | Pointer to tightly packed RGBA16 pixels. |
Definition at line 1978 of file mxwrite.cpp.
| void Writer::write_hdr_rgba16_at_pts | ( | void * | rgba16_buffer, |
| int64_t | pts ) |
Queue a 16-bit HDR RGBA frame with an explicit presentation timestamp.
| rgba16_buffer | Pointer to tightly packed RGBA16 pixels. |
| pts | Presentation timestamp in units of the configured frame time base. |
Definition at line 1982 of file mxwrite.cpp.
| void Writer::write_ts | ( | void * | rgba_buffer | ) |
Queue a host RGBA frame using capture timestamps.
| rgba_buffer | Pointer to tightly packed RGBA8 pixels. |
Definition at line 2211 of file mxwrite.cpp.