avformatwriteheader
avformat_write_header is a function in FFmpeg’s libavformat that writes the header for an output format associated with a given AVFormatContext. It initializes the container file’s header based on the configured streams and metadata and is typically called after opening the output and configuring streams, but before writing any packet data.
int avformat_write_header(AVFormatContext *s, AVDictionary **options);
The first argument, s, is a pointer to an initialized AVFormatContext with an open IO context and
0 on success, or a negative error code on failure. The error codes follow FFmpeg’s conventional negative
Call avformat_write_header after setting up the output context (including avio_open) and creating or configuring streams, and
Some muxers may write necessary header information automatically during the first packet write, in which case