ffmpeg處理流程

圖解

在這裏插入圖片描述

主流程

1、初始化avformat

av_register_all

2、初始化avformat網絡

avformat_network_init

3、初始化輸入流

1、申請AVFormatContext

avformat_alloc_context

2、打開輸入流

avformat_open_input

3、探測輸入流信息

avformat_find_stream_info

4、查找解碼器(視頻和音頻)

avcodec_find_decoder

5、根據編碼器初始化AVCodecContext

avcodec_open2

4、初始化輸出流

1、申請AVFormatContext

avformat_alloc_output_context2

2、查找編碼器(音頻和視頻)

avcodec_find_encoder

3、根據編碼器創建AVCodecContext

avcodec_alloc_context3

4、根據編碼器類型初始化AVCodecContext

avcodec_open2

5、根據AVFormatContext和編碼器創建輸出流

avformat_new_stream

6、根據URL初始化AVIOContext

avio_open

7、向輸出文件寫流的頭信息

avformat_write_header

5、初始化濾鏡

1、申請AVFilterInOut(輸入和輸出)

avfilter_inout_alloc

2、打開濾鏡(輸入濾鏡和輸入濾鏡)

avfilter_get_by_name

3、申請AVFilterGraph

avfilter_graph_alloc

4、構造濾鏡初始化參數

5、根據AVFilterGraph和初始化參數創建過濾器

avfilter_graph_create_filter

6、構造濾鏡鏈

7、解析濾鏡命令行參數

avfilter_graph_parse_ptr

8、檢查及配置濾鏡鏈

avfilter_graph_config

6、從AVFormatContext讀取packet

av_read_frame

7、解碼packet

avcodec_decode_video2或avcodec_decode_audio4

8、添加進濾鏡

av_buffersrc_add_frame

9、從濾鏡中讀取數據

av_buffersink_get_frame_flags

10、編碼packet

avcodec_encode_video2或avcodec_encode_audio2

11、輸出數據

av_write_frame

12、寫輸出尾

av_write_trailer

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章