MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ write_packet()

bool MayaFlux::IO::FFmpegMuxContext::write_packet ( AVPacket *  pkt)

Submit one encoded packet for interleaved writing.

Uses av_interleaved_write_frame, which buffers packets internally to preserve correct interleaving order for containers that require it (MP4, MKV). For single-stream audio-only containers (WAV, FLAC) this is equivalent to av_write_frame.

The packet's stream_index, PTS, DTS, and duration must be set by the calling encode context before this call. Ownership of the packet data is transferred to FFmpeg; the caller must not reference pkt after return.

Parameters
pktEncoded packet with all fields populated.
Returns
True on success.

Definition at line 124 of file FFmpegMuxContext.cpp.

125{
127 m_last_error = "write_packet called before header was written";
128 return false;
129 }
130
131 int ret = av_interleaved_write_frame(format_context, pkt);
132 if (ret < 0) {
133 char errbuf[AV_ERROR_MAX_STRING_SIZE];
134 av_strerror(ret, errbuf, sizeof(errbuf));
135 m_last_error = std::string("av_interleaved_write_frame failed: ") + errbuf;
136 return false;
137 }
138
139 return true;
140}
AVFormatContext * format_context
Owned; freed in close().

References format_context, m_header_written, and m_last_error.

Referenced by MayaFlux::IO::AudioEncodeContext::drain_packets(), and MayaFlux::IO::VideoEncodeContext::drain_packets().

+ Here is the caller graph for this function: