音视频重新封装的流程

avformat_open_input():打开输入文件。

(avcodec_copy_context()不用此函数了)现在使用avcodec_parameters_from_context() / avcodec_parameters_to_context() :赋值AVCodecContext的参数。

avformat_alloc_output_context2():初始化输出文件。

avio_open():打开输出文件。

avformat_write_header():写入文件头。

//////av_compare_ts():比较时间戳,决定写入视频还是写入音频。这个函数相对要少见一些。

av_read_frame():从输入文件读取一个AVPacket。

av_interleaved_write_frame():写入一个AVPacket到输出文件。

av_write_trailer():写入文件尾。

avcodec_parameters_to_context(vc, ic->streams[videoStream]->codecpar)------->把AVStream->codecpar(AVCodecParameters) 复制到 AVCodecContext            ( 解码时候)

avcodec_parameters_from_context(vc, ic->streams[videoStream]->codecpar)------->AVStream->codecpar(AVCodecParameters) 从 AVCodecContext 复制来的   (编码时候)

猜你喜欢

转载自www.cnblogs.com/liunx1109/p/9341524.html