aac_adtstoasc bitstream filter

FFmpeg官方文档对aac_adtstoasc的说明:

aac_adtstoasc bitstream filter_第1张图片


1)将AAC编码器编码后的原始码流(ADTS头 + ES流)封装为MP4或者FLV或者MOV等格式时,需要先将ADTS头转换为MPEG-4 AudioSpecficConfig (将音频相关编解码参数提取出来),并将原始码流中的ADTS头去掉(只剩下ES流)。


2)相反,从MP4或者FLV或者MOV等格式文件中解封装出AAC码流(只有ES流)时,需要在解析出的AAC码流前添加ADTS头(含音频相关编解码参数)。


ADTS AAC
ADTS_header AAC ES ADTS_header AAC ES
...
ADTS_header AAC ES


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. Because MP4 has its own way of transporting meta information (here transport info), writing that transport prefix before each frame will make the data unreadable.

//ofmt_ctx is AVFormatContext
//enc_ctx is the AVCodecContext of the current stream 
if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER)
    enc_ctx->flags |= CODEC_FLAG_GLOBAL_HEADER;

Without them the encoder may add the metadatas in the data which is sent to the container. For AACit is the ADTS header, for H264 it is SPS and PPS data.


你可能感兴趣的:(AAC)