【FFmpeg实战】ffplay.c 流程简析
原文链接:https://blog.csdn.net/biezhihua/article/details/90730061
FFplay.c

main()
主函数
avformat_network_init()
初始化网络库()This is optional, and not recommended anymore.
http://ffmpeg.org/doxygen/trunk/group__lavf__core.html#ga84542023693d61e8564c5d457979c932
show_banner()
打印输出FFmpeg版本信息(编译时间,编译选项,类库信息等)
parse_options() 解析命令行输入选项
parse_option()解析参数find_option()_根据参数找到对应的OptionDefwrite_option()_执行OptionDef
SDL_Init() 初始化SDL,FFPlay中的视频与音频都是使用到了SDL
SDL_CreateWindow()创建SDL窗口
https://wiki.libsdl.org/SDL_CreateWindow
SDL_CreateRedner()为SDL窗口创建SDL渲染上下文
https://wiki.libsdl.org/SDL_CreateRenderer
https://wiki.libsdl.org/SDL_RendererFlags
stream_open()
打开输入媒体
frame_queue_init()初始化帧队列,FrameQueue内部是个有限数组,内部根据max_size_来初始化默认缓存数据
f->queue[i].frame = av_frame_alloc()
frame_queue_destory()销毁帧队列,释放初始化时的缓存数据av_frame_free()
packet_queue_init()初始化包队列,PacketQueue内部是个自定义链表
init_clock()初始化时钟,使用默认值(NAN/-1)来初始化时钟的pst/last_update/pst_dirft/serial_等数据。
av_gettime_relative()从未指明的某个点获取到现在的时间(纳秒)time.c File Referenceset_clock_at(c,pts,serial,time)
read_thread()
帧读取线程
avformat_alloc_context()初始化上下文
FFmpeg: Core functions
http://ffmpeg.org/doxygen/trunk/group__lavf__core.html#gac7a91abf2f59648d995894711f070f62
avformat_open_input()打开文件流,读取文件头部数据
avformat_find_stream_info()获取媒体流信息
avformat_seek_file()
av_dump_format()输出媒体信息到控制台
av_find_best_stream()获取最合适的流
av_guess_sample_aspect_ratio()获取流采样率
AVCodecParameters编解码器参数
set_default_window_size()设置窗口大小
calculate_display_rect()根据屏幕宽高和流像素宽高计算出可显示区域
stream_component_open()分别打开视频/音频/字幕解码线程
av_read_pause()/av_read_play()暂停或者播放网络流
FFmpeg: Demuxing
avformat_seek_file()快进
FFmpeg: Demuxing
packet_queue_flush()清空包队列缓存
stream_has_enough_packets()是否有足够的包缓存
av_read_frame()读取一帧流原始数据
packet_queue_put()将读取的包数据加入到队列中
stream_component_open()
分别打开视频/音频/字幕解码线程
avcodec_alloc_context3() 创建编解码器上下文
avcodec_parameters_to_context()从流中复制参数到编解码器上下文中
avcodec_find_decoder()根据编码ID获取编解码器
avcodec_find_decoder_by_name()根据名称查找编解码器
avcodec_open2() 根据编解码器初始化编解码器上下文
audio_open()打开音频解码
av_get_default_channel_layout(wanted_nb_channels)av_get_channel_layout_nb_channels(wanted_channel_layout)sdl_audio_callback()audio_decode_frame()synchronize_audio()swr_convert()SDL_OpenAudioDevice()https://wiki.libsdl.org/SDL_OpenAudioDevice
audio_thread()解码音频帧
decoder_decode_frame()avcodec_send_packet()avcodec_receive_frame()
video_thread()解码视频帧
get_video_frame()获取视频帧decoder_decode_frame()av_guess_sample_aspect_ratio()queue_picture()入队视频图像数据frame_queue_peek_writable()从帧缓存区中等待获取一个可用数据av_frame_move_ref()转移引用frame_queue_push()增加帧队列size
subtitle_thread()__解码字幕帧
frame_queue_peek_writable()decoder_decode_frame()frame_queue_push()
event_loop()
处理键盘事件与视频刷新
video_refresh()处理视频刷新与显示
frame_queue_peek_last()出队图像frame_queue_peek()video_display()显示图像video_open()开打窗口video_image_display()图像展示frame_queue_peek_last()calculate_display_rect()计算显示画面的位置。当拉伸了SDL的窗口的时候,可以让其中的视频保持纵横比upload_texture()SDL_RenderCopyEx()
>>> 音视频开发 视频教程: https://ke.qq.com/course/3202131?flowToken=1031864 >>> 音视频开发学习资料、教学视频,免费分享有需要的可以自行添加学习交流群 739729163 领取
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
