我是靠谱客的博主 哭泣酸奶,这篇文章主要介绍视频压缩的流程,现在分享给大家,希望可以做个参考。

初始化:
av_register_all


avformat_alloc_output_context2


avcodec_find_encoder


avcodec_alloc_context3


av_dict_set


//打开编码器
avcodec_open2


//Add a new stream to output,should be called by the user before avformat_write_header() for muxing
avformat_new_stream


//Open output URL,set before avformat_write_header() for muxing
avio_open


//Write File Header
avformat_write_header(ofmt_ctx, NULL);




循环编码:  编码时需写入PTS, enc_pkt.dts = enc_pkt.pts;
avcodec_alloc_frame


//Frame分配内存
avpicture_fill


av_init_packet


//编码
avcodec_encode_video2
av_frame_free


//设置DTS -->PTS ,通过DTSPTS实现音视频同步
enc_pkt.pts = av_rescale_q(framecnt*calc_duration, time_base_q, time_base);
//DTS -->PTS
enc_pkt.dts = enc_pkt.pts;


av_interleaved_write_frame
av_free_packet


flush:
while (1) {
av_init_packet

avcodec_encode_video2

//Write PTS


}


close:
释放内存。。。

最后

以上就是哭泣酸奶最近收集整理的关于视频压缩的流程的全部内容,更多相关视频压缩内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(51)

评论列表共有 0 条评论

立即
投稿
返回
顶部