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

◆ write_header()

bool MayaFlux::IO::FFmpegMuxContext::write_header ( )

Write the container header to the output file.

Must be called after all stream contexts (audio, video, subtitle, etc.) have been opened and have set their codec parameters on their AVStream. Exactly one call is valid per open(); calling twice is an error.

Returns
True on success.

Definition at line 101 of file FFmpegMuxContext.cpp.

102{
103 if (!format_context) {
104 m_last_error = "write_header called on unopened context";
105 return false;
106 }
107 if (m_header_written) {
108 m_last_error = "write_header called more than once";
109 return false;
110 }
111
112 int ret = avformat_write_header(format_context, nullptr);
113 if (ret < 0) {
114 char errbuf[AV_ERROR_MAX_STRING_SIZE];
115 av_strerror(ret, errbuf, sizeof(errbuf));
116 m_last_error = std::string("avformat_write_header failed: ") + errbuf;
117 return false;
118 }
119
120 m_header_written = true;
121 return true;
122}
AVFormatContext * format_context
Owned; freed in close().

References format_context, m_header_written, and m_last_error.

Referenced by MayaFlux::IO::SoundFileWriter::worker_loop(), and MayaFlux::IO::VideoFileWriter::worker_loop().

+ Here is the caller graph for this function: