当前位置: 首页 > news >正文

FFmpeg AVFilter的原理(三)- filter是如何被驱动的

首先上官方filter的链接:https://ffmpeg.org/ffmpeg-filters.html
关于filter命令行:FFmpeg-4.0 的filter机制的架构与实现.之一 Filter原理

1、下面是一个avfilter的graph在这里插入图片描述
上图是ffmpeg中doc/examples中filtering_video.c案例的示意图。
特别注意上面蓝色方块箭头,其就是query_format()后的结果,也是filter协商fmt的关键步骤。
本章节主要查看avfilter中的数据是怎么进入的,然后又是怎么出来的。
主要考察两个函数:

av_buffersrc_add_frame_flags()
av_buffersink_get_frame()

下面是其具体用法:

 /* read all packets */while (1) {if ((ret = av_read_frame(fmt_ctx, &packet)) < 0)break;if (packet.stream_index == video_stream_index) {ret = avcodec_send_packet(dec_ctx, &packet);if (ret < 0) {av_log(NULL, AV_LOG_ERROR, "Error while sending a packet to the decoder\n");break;}while (ret >= 0) {ret = avcodec_receive_frame(dec_ctx, frame);if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {break;} else if (ret < 0) {av_log(NULL, AV_LOG_ERROR, "Error while receiving a frame from the decoder\n");goto end;}frame->pts = frame->best_effort_timestamp;/* push the decoded frame into the filtergraph */if (av_buffersrc_add_frame_flags(buffersrc_ctx, frame, AV_BUFFERSRC_FLAG_KEEP_REF) < 0) {av_log(NULL, AV_LOG_ERROR, "Error while feeding the filtergraph\n");break;}/* pull filtered frames from the filtergraph */while (1) {ret = av_buffersink_get_frame(buffersink_ctx, filt_frame);if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)break;if (ret < 0)goto end;display_frame(filt_frame, buffersink_ctx->inputs[0]->time_base);av_frame_unref(filt_frame);}av_frame_unref(frame);}}av_packet_unref(&packet);}

整个函数关系调用图如下:
在这里插入图片描述

http://www.lryc.cn/news/96290.html

相关文章:

  • ARM day8 key1/2/3led
  • windows 系统安装sonarqube
  • Unity噪声图生成(编辑器扩展)
  • http-为什么文件上传要转成Base64
  • htmlCSS-----定位
  • 腾讯云大数据型CVM服务器实例D3和D2处理器CPU型号说明
  • 计算机科学cs/电子信息ei面试准备——数学基础/线性代数复习
  • 极速查找(2)-算法分析
  • flask路由添加参数
  • 网络安全系统教程+学习路线(自学笔记)
  • 23. 合并 K 个升序链表
  • Nexus3部署、配置+SpringBoot项目Demo
  • linux下用docker安装mysql
  • Vue - 可视化用户角色、菜单权限、按钮权限配置(动态获取菜单路由)
  • hive库操作示例
  • LeetCode第 N 个泰波那契数 (认识动态规划)
  • 线程安全问题(内存可见性)
  • STM32MX配置EEPROM(AT24C02)------保姆级教程
  • 微信小程序 样式和全局配置
  • 一.初识C语言
  • filebeat到kafka示例
  • AlmaLinux系统下的Zabbix汉化
  • 【网络编程】(TCP流套接字编程 ServerSocket API Socket API 手写TCP版本的回显服务器 TCP中的长短连接)
  • 企业级PaaS低代码快开平台源码,基于 Salesforce Platform 的开源替代方案
  • 【LeetCode】72.编辑距离
  • 大模型,开源干不掉闭源
  • Redis 九种数据类型的基本操作
  • 爬取微博热搜榜并进行数据分析
  • 基于深度神经网络的肺炎检测系统实现
  • C# LINQ和Lambda表达式对照