

If (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER)Įnc_ctx->flags |= CODEC_FLAG_GLOBAL_HEADER enc_ctx is the AVCodecContext of the current stream Because MP4 has its own way of transporting metainformation (here transport info), writing that transport prefix before each frame will make the data unreadable.Īre you sure you have the following lines and that the flag CODEC_FLAG_GLOBAL_HEADER is set? //ofmt_ctx is AVFormatContext MP4 container requires AV_CODEC_FLAG_GLOBAL_HEADER, which means all stream should contains stream data only, and other data is provided by setting AVCodecContext.extradata.

In this case the unit is the MP4 container code. Adts header allow you to dump AAC data directly to a file, call it foo.aac and open it with other program. Your aac audio frames still have adts headers when provided to a unit of processing which is expecting raw aac.
