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

【FFMPEG】Filtering Introduction[翻译/举例]

Filtering Introduction

Filtering in FFmpeg is enabled through the libavfilter library.

FFmpeg中的Filtering可以通过libavfilter library来使用。

In libavfilter, a filter can have multiple inputs and multiple outputs. To illustrate the sorts of things that are possible, we consider the following filtergraph.

在libavfilter中,一个filter可以有多个输入和多个输出。为了说明这些事情可实现的可能,我们看下下面这幅图

                [main]
input --> split ---------------------> overlay --> output|                             ^|[tmp]                  [flip]|+-----> crop --> vflip -------+

This filtergraph splits the input stream in two streams, then sends one stream through the crop filter and the vflip filter, before merging it back with the other stream by overlaying it on top. You can use the following command to achieve this:

这副图中input stream被切割为2个stream,然后将其中一路stream通过crop filter和vflip filter送出然后通过盖在另一路stream上方的方式与另一路stream融合。你可以通过下面的命令来实现此功能:

ffmpeg -i INPUT -vf "split [main][tmp]; [tmp] crop=iw:ih/2:0:0, vflip [flip]; [main][flip] overlay=0:H/2" OUTPUT

The result will be that the top half of the video is mirrored onto the bottom half of the output video.

上述命令的执行结果是视频的上半部分是输出视频的下半部分的镜像。

Filters in the same linear chain are separated by commas, and distinct linear chains of filters are separated by semicolons. In our example,crop,vflip are in one linear chain, split and overlay are separately in another. The points where the linear chains join are labelled by names enclosed in square brackets. In the example, the split filter generates two outputs that are associated to the labels [main] and [tmp].

同一线性链路中的Filters使用逗号隔开,不同链路中的filters使用分号隔离。在我们的例子中crop和vflip是一个线性链路,split 和 overlay在另一个线性链路。两条线性链路的交汇点使用使用方括号中的名称来标记。在例子中,split filter产生了两个输出分别标记为[main]和[tmp]

The stream sent to the second output of split, labelled as [tmp], is processed through the crop filter, which crops away the lower half part of the video, and then vertically flipped. The overlay filter takes in input the first unchanged output of the split filter (which was labelled as [main]), and overlay on its lower half the output generated by the crop,vflip filterchain.

spilt输出的第二路stream被标记为[tmp], 该stream被 crop filter处理:裁剪掉视频的下半部分,然后垂直翻转.overlay filter 将 split filter(标记为[main])的第一个未更改输出作为输入,并在其下半部分覆盖crop,vflip filterchain生成的输出。

Some filters take in input a list of parameters: they are specified after the filter name and an equal sign, and are separated from each other by a colon.

一些过滤器接受参数列表的输入:它们在filter名称和等号之后指定,并且彼此之间用冒号分隔。

There exist so-called source filters that do not have an audio/video input, and sink filters that will not have audio/video output.

没有audio/video输入的filters被称作source filters, 没有audio/video输出的filters被称作 sink filters。

Filtergraph description

A filtergraph is a directed graph of connected filters. It can contain cycles, and there can be multiple links between a pair of filters. Each link has one input pad on one side connecting it to one filter from which it takes its input, and one output pad on the other side connecting it to one filter accepting its output.

filtergraph是连接filters的有向图。它可以包含循环,一对filters中间可以存在多个链路。每个链接的一侧有一个 input pad ,将其连接到一个filter ,从中获取输入,另一侧有一个output pad,将其连接到一个接受其输出的filter。

Each filter in a filtergraph is an instance of a filter class registered in the application, which defines the features and the number of input and output pads of the filter.

filtergraph 中的每个filter 都是在应用程序中注册的filter class的实例,它定义了filter的特征和 input output pad的数量。

A filter with no input pads is called a “source”, and a filter with no output pads is called a “sink”.

没有输入pads 的filter 称为“source”,没有输出pads 的filter 称为“sink”。

Filtergraph syntax

A filtergraph has a textual representation, which is recognized by the -filter/-vf/-af and -filter_complex options in ffmpeg and -vf/-af in ffplay, and by the avfilter_graph_parse_ptr() function defined in libavfilter/avfilter.h.

filtergraph 有一个文本表示,它在ffmpeg中通过 -filter/-vf/-af和 -filter_complex 选项识别,ffplay中通过-vf/-af 识别。并通过 avfilter_graph_parse_ptr()在中定义的函数 libavfilter/avfilter.h函数解析。

A filterchain consists of a sequence of connected filters, each one connected to the previous one in the sequence. A filterchain is represented by a list of “,”-separated filter descriptions.

filterchain 由一系列连接的filters组成,每个filters都连接到序列中的前一个filters。filterchain 由“,”分隔的filter列表表示。

A filtergraph consists of a sequence of filterchains. A sequence of filterchains is represented by a list of “;”-separated filterchain descriptions.

filtergraph由一系列过filterchains组成。filterchains序列由“;”分隔的过filterchains描述列表表示。

A filter is represented by a string of the form: [in_link_1]…[in_link_N]filter_name@id=arguments[out_link_1]…[out_link_M]

过滤器由以下形式的字符串表示: [ in_link_1 ]…[ in_link_N ] filter_name@id = arguments [ out_link_1 ] … [ out_link_M ]

filter_name is the name of the filter class of which the described filter is an instance of, and has to be the name of one of the filter classes registered in the program optionally followed by “@id”. The name of the filter class is optionally followed by a string “=arguments”.

filter_name是filter class的名称,filter_name所描述的filter是它的一个实例,并且必须是在程序中注册的filter class之一的名称,可选地后跟“@id ”。filter class的名称后面可以选择跟一个字符串“= arguments ”。

arguments is a string which contains the parameters used to initialize the filter instance. It may have one of two forms:
A ’:’-separated list of key=value pairs.
A ’:’-separated list of value. In this case, the keys are assumed to be the option names in the order they are declared. E.g. the fade filter declares three options in this order – type, start_frame and nb_frames. Then the parameter list in:0:30 means that the value in is assigned to the option type, 0 to start_frame and 30 to nb_frames.
A ’:’-separated list of mixed direct value and long key=value pairs. The direct value must precede the key=value pairs, and follow the same constraints order of the previous point. The following key=value pairs can be set in any preferred order.

arguments是一个字符串,其中包含用于初始化filter实例的参数。它可能具有以下两种形式之一:

  • 以“:”分隔的键=值对列表。
  • 以“:”分隔的值列表。在这种情况下,假定键是按声明顺序排列的选项名称。例如,fade过滤器按此顺序声明三个选项 –type, start_frame and nb_frames. 那么参数列表in:0:30表示将in的值 赋值给option type, 0赋值给start_frame和30赋值给nb_frames.
  • 以“:”分隔的混合直接值和长键=值对列表 。直接值必须在键=值对之前,并遵循与前一点相同的约束顺序。可以按任何首选顺序设置 以下
    键=值对。

If the option value itself is a list of items (e.g. the format filter takes a list of pixel formats), the items in the list are usually separated by ‘|’.

如果option值本身是一个列表(例如,format filter采用像素格式列表),则列表中的项目通常由 ‘|’.

The list of arguments can be quoted using the character ‘'’ as initial and ending mark, and the character ‘\’ for escaping the characters within the quoted text; otherwise the argument string is considered terminated when the next special character (belonging to the set ‘[]=;,’) is encountered.

arguments list可以使用字符 ‘'’作为开始和结束标记被引用,字符 ‘’ 用于转义引用文本中的字符;否则 当下一个特殊字符( ‘[]=;,’)被遇到的时候,argument字符串将被认为中断了。

A special syntax implemented in the ffmpeg CLI tool allows loading option values from files. This is done be prepending a slash ’/’ to the option name, then the supplied value is interpreted as a path from which the actual value is loaded. E.g.

ffmpeg -i <INPUT> -vf drawtext=/text=/tmp/some_text <OUTPUT>

ffmpeg中实现的特殊语法,CLI 工具允许从文件加载选项值。这是通过在选项名称前添加一个斜杠“/”来完成的,然后将提供的值解释为加载实际值的路径。

will load the text to be drawn from /tmp/some_text. API users wishing to implement a similar feature should use the avfilter_graph_segment_*() functions together with custom IO code.

上述命令中将加载要从中绘制的文本/tmp/some_text. 希望实现类似功能的 API 用户应将这些avfilter_graph_segment_*() 功能与自定义 IO 代码一起使用。

The name and arguments of the filter are optionally preceded and followed by a list of link labels. A link label allows one to name a link and associate it to a filter output or input pad. The preceding labels in_link_1 … in_link_N, are associated to the filter input pads, the following labels out_link_1 … out_link_M, are associated to the output pads.

filter的名称和参数可选地前后跟有链接标签列表。链接标签允许人们命名链接并将其关联到filter 输出或输入pad。前面的标签in_link_1 … in_link_N与pad输入pad相关联,以下标签out_link_1 … out_link_M与输出pad相关联。

When two link labels with the same name are found in the filtergraph, a link between the corresponding input and output pad is created.

当在filtergraph中找到两个具有相同名称的链接标签时,将创建相应输入和输出pad 之间的链接。

If an output pad is not labelled, it is linked by default to the first unlabelled input pad of the next filter in the filterchain. For example in the filterchain
如果未标记输pad,则默认情况下将其链接到过滤器链中下一个filterchain的第一个未标记输入pad。例如在下面的filterchain中

nullsrc, split[L1], [L2]overlay, nullsink

the split filter instance has two output pads, and the overlay filter instance two input pads. The first output pad of split is labelled “L1”, the first input pad of overlay is labelled “L2”, and the second output pad of split is linked to the second input pad of overlay, which are both unlabelled.

split filter实例有两个输出pad,overlay filter实例有两个输入pad。split 的第一个输出pad标记为“L1”,overlay 的第一个输入pad标记为“L2”,split 的第二个输出pad链接到 overlay 的第二个输入pad,两者均未标记。

In a filter description, if the input label of the first filter is not specified, “in” is assumed; if the output label of the last filter is not specified, “out” is assumed.

在filter description中,如果没有指定第一个filter的输入标签,则假定为“in”;如果未指定最后一个filter的输出标签,则假定为“out”。

In a complete filterchain all the unlabelled filter input and output pads must be connected. A filtergraph is considered valid if all the filter input and output pads of all the filterchains are connected.

在完整的filterchain中,所有未标记的filter 输入和输出pads都必须连接。如果所有过filtergraph的所有过滤器输入和输出pad都已连接,则过filtergraph被认为是有效的。

Libavfilter will automatically insert scale filters where format conversion is required. It is possible to specify swscale flags for those automatically inserted scalers by prepending sws_flags=flags; to the filtergraph description.

Libavfilter 会自动在需要格式转换的地方插入缩放filters 。可以通过 在 filtergraph 描述之前为那些自动插入的缩放器指定 swscale 标志。 sws_flags=flags;

Here is a BNF description of the filtergraph syntax:

NAME             ::= sequence of alphanumeric characters and '_'
FILTER_NAME      ::= NAME["@"NAME]
LINKLABEL        ::= "[" NAME "]"
LINKLABELS       ::= LINKLABEL [LINKLABELS]
FILTER_ARGUMENTS ::= sequence of chars (possibly quoted)
FILTER           ::= [LINKLABELS] FILTER_NAME ["=" FILTER_ARGUMENTS] [LINKLABELS]
FILTERCHAIN      ::= FILTER [,FILTERCHAIN]
FILTERGRAPH      ::= [sws_flags=flags;] FILTERCHAIN [;FILTERGRAPH]

相关文章:

【FFMPEG】Filtering Introduction[翻译/举例]

Filtering Introduction Filtering in FFmpeg is enabled through the libavfilter library. FFmpeg中的Filtering可以通过libavfilter library来使用。 In libavfilter, a filter can have multiple inputs and multiple outputs. To illustrate the sorts of things that are…...

什么是IP65?仅仅是防水等级吗?看完本文直呼666!

IP65在硬件设备&#xff0c;准确的来说在电气设备中&#xff0c;这个参数很常见&#xff0c;但是作为网络技术的博主&#xff0c;为啥要介绍IP65&#xff1f; 这个很好解释&#xff0c;因为网络设备&#xff0c;比如路由器、交换机&#xff0c;还有服务器、监控等都是属于电气…...

Flask入门(10):数据库连接池

目录10.数据库连接池模式一模式二示例&#xff1a;使用数据库连接池进行登录验证10.数据库连接池 参考&#xff1a;https://www.cnblogs.com/wangkun122/articles/8992637.html 通过DBUtils实现数据库连接池 安装&#xff1a; pip install DBUtils1.2注意&#xff1a;pytho…...

华为OD机试C++实现 - 最小步骤数

最近更新的博客 华为OD机试 - 入栈出栈(C++) | 附带编码思路 【2023】 华为OD机试 - 箱子之形摆放(C++) | 附带编码思路 【2023】 华为OD机试 - 简易内存池 2(C++) | 附带编码思路 【2023】 华为OD机试 - 第 N 个排列(C++) | 附带编码思路 【2023】 华为OD机试 - 考古…...

数仓:用户行为类指标一网打尽

前言 用户行为分析是对用户在产品或触点上产生的行为及行为背后的数据进行分析&#xff0c;通过构建用户行为数据分析体系或者用户画像&#xff0c;来改变产品、营销、运营决策&#xff0c;实现精细化运营&#xff0c;指导业务增长。总之&#xff0c;很重要。 先来看下用户类…...

mysql数据库的主从复制

一、实现主从复制的方式。 异步复制&#xff1a;它是mysql默认的同步方式&#xff0c;从库通过io线程去拉取 bin log时&#xff0c;主库不需要关注这个时候是否有从库在同步数据&#xff0c;他只做自己的事情就可以了&#xff0c; 整个复制过程都是异步完成的 ; 半同步复制&…...

【极海APM32替代笔记】低功耗模式、WFI命令等进入不了休眠的可能原因(系统定时器SysTick一直产生中断)

【极海APM32替代笔记】低功耗模式、WFI命令等进入不了休眠的可能原因&#xff08;系统定时器SysTick一直产生中断&#xff09; 【STM32笔记】低功耗模式配置及避坑汇总 前文&#xff1a; blog.csdn.net/weixin_53403301/article/details/128216064 【STM32笔记】HAL库低功耗模…...

一文搞懂秒杀系统,欢迎参与开源,提交PR,提高竞争力。早日上岸,升职加薪。

前言 秒杀和高并发是面试的高频考点&#xff0c;也是我们做电商项目必知必会的场景。欢迎大家参与我们的开源项目&#xff0c;提交PR&#xff0c;提高竞争力。早日上岸&#xff0c;升职加薪。 知识点详解 秒杀系统架构图 秒杀流程图 秒杀系统设计 这篇文章一万多字&#xff0c;…...

华为OD机试真题 用 C++ 实现 - 子序列长度 | 多看题,提高通过率

最近更新的博客 华为OD机试 - 入栈出栈(C++) | 附带编码思路 【2023】 华为OD机试 - 箱子之形摆放(C++) | 附带编码思路 【2023】 华为OD机试 - 简易内存池 2(C++) | 附带编码思路 【2023】 华为OD机试 - 第 N 个排列(C++) | 附带编码思路 【2023】 华为OD机试 - 考古…...

华为OD机试题 - 符合条件的子串长度(JavaScript)| 包含代码编写思路

最近更新的博客 华为OD机试题 - 字符串加密(JavaScript) 华为OD机试题 - 字母消消乐(JavaScript) 华为OD机试题 - 字母计数(JavaScript) 华为OD机试题 - 整数分解(JavaScript) 华为OD机试题 - 单词反转(JavaScript) 华为OD机试题 最近更新的博客使用说明符合条件的子…...

快速读懂网络拓扑图

快速读懂网络拓扑图几重常见的网络拓扑总线型拓扑简介优点缺点环型拓扑简介优点缺点星型拓扑简介优点缺点网络层级机构节点结点链路通路不同的连接线代表什么意思&#xff1f;不同颜色、粗细的直线代表什么意思&#xff1f;闪电线-串行链路几重常见的网络拓扑 总线型拓扑 简介…...

《上海市创新型企业总部认定和奖励管理办法》

各区人民政府、有关单位&#xff1a; 为加快推动上海创新型经济发展&#xff0c;支持各类高成长性企业和研发机构升级打造创新型企业总部&#xff0c;培育壮大更多高能级创新主体&#xff0c;为建设具有全球影响力的科技创新中心提供支撑&#xff0c;现将《上海市创新型企业总…...

LeetCode 160. 相交链表 -- 消除长度差

相交链表 简单 2K 相关企业 给你两个单链表的头节点 headA 和 headB &#xff0c;请你找出并返回两个单链表相交的起始节点。如果两个链表不存在相交节点&#xff0c;返回 null 。 图示两个链表在节点 c1 开始相交&#xff1a; 题目数据 保证 整个链式结构中不存在环。 注意…...

《分布式技术原理与算法解析》学习笔记Day19

分布式通信&#xff1a;消息队列 什么是消息队列&#xff1f; 队列是一种具有先进先出特点的数据结构&#xff0c;消息队列是基于队列实现的、存储具有特定格式的消息数据。消息以特定格式放入这个队列的尾部后直接返回&#xff0c;不需要系统马上处理&#xff0c;之后有其他…...

云、安全、网络三位一体,Akamai 推出大规模分布式边缘和云平台 Akamai Connected Cloud

出品 | CSDN 云计算 云服务市场规模在持续增长。 基于网络技术积累与优势&#xff0c;与布局边缘计算之后&#xff0c;巨头 Akamai 在继续推进它的技术与产品进程。近日&#xff0c;Akamai 正式推出大规模分布式边缘和云平台 Akamai Connected Cloud&#xff0c;包含云计算、安…...

生产者消费者模型(多线程工作)

目录 1.模型前提 2.阻塞队列&#xff08;消费场所&#xff09; 3. 实验 4.有关效率 1.模型前提 以单生产者对单消费者为例子&#xff1a; 前提一&#xff1a;有一个缓冲区作为消费场所。 前提二&#xff1a;有两种功能不同的线程分别具有消费与生产的能力。 前提三&…...

InnoDB锁

1、共享排他锁 Shared and Exclusive Locks--共享锁&#xff08;SLock&#xff09;&#xff0c;允许持有该锁的事务读取一行数据--排它锁&#xff08;XLock&#xff09;&#xff0c;允许持有该锁的事务删除或者更新一行数据特性&#xff1a;--行级锁--如果一个事务持有当前行的…...

Java Stream、File、IO 超详细整理,适合新手入门

目录 Java Stream Java File Java IO Java Stream Java Stream 是 Java 8 中引入的一种新的抽象数据类型&#xff0c;它允许开发人员使用函数式编程的方式来处理集合数据。 使用 Java Stream 可以方便地进行过滤、映射、排序和聚合等操作。下面是一个简单的示例&#xff1a;…...

华为OD机试真题Python实现【寻找密码】真题+解题思路+代码(20222023)

寻找密码 题目 小王在进行游戏大闯关,有一个关卡需要输入一个密码才能通过,密码获得的条件如下: 在一个密码本中,每一页都有一个由 26 个小写字母组成的若干位密码, 从它的末尾开始依次去掉一位得到的新密码也在密码本中存在。 请输出符合要求的密码,如果由多个符合要求…...

springboot和springframework版本依赖关系

springboot和springframework版本依赖关系 springboot版本springframework版本发布时间1.0.x1.0.0.RELEASE4.0.3.RELEASE2014.041.0.1.RELEASE4.0.3.RELEASE2014.041.0.2.RELEASE4.0.3.RELEASE2014.041.1.x1.1.0.RELEASE4.0.5.RELEASE2014.061.1.1.RELEASE4.0.5.RELEASE2014.0…...

(LeetCode 每日一题) 3442. 奇偶频次间的最大差值 I (哈希、字符串)

题目&#xff1a;3442. 奇偶频次间的最大差值 I 思路 &#xff1a;哈希&#xff0c;时间复杂度0(n)。 用哈希表来记录每个字符串中字符的分布情况&#xff0c;哈希表这里用数组即可实现。 C版本&#xff1a; class Solution { public:int maxDifference(string s) {int a[26]…...

Day131 | 灵神 | 回溯算法 | 子集型 子集

Day131 | 灵神 | 回溯算法 | 子集型 子集 78.子集 78. 子集 - 力扣&#xff08;LeetCode&#xff09; 思路&#xff1a; 笔者写过很多次这道题了&#xff0c;不想写题解了&#xff0c;大家看灵神讲解吧 回溯算法套路①子集型回溯【基础算法精讲 14】_哔哩哔哩_bilibili 完…...

《从零掌握MIPI CSI-2: 协议精解与FPGA摄像头开发实战》-- CSI-2 协议详细解析 (一)

CSI-2 协议详细解析 (一&#xff09; 1. CSI-2层定义&#xff08;CSI-2 Layer Definitions&#xff09; 分层结构 &#xff1a;CSI-2协议分为6层&#xff1a; 物理层&#xff08;PHY Layer&#xff09; &#xff1a; 定义电气特性、时钟机制和传输介质&#xff08;导线&#…...

基于Docker Compose部署Java微服务项目

一. 创建根项目 根项目&#xff08;父项目&#xff09;主要用于依赖管理 一些需要注意的点&#xff1a; 打包方式需要为 pom<modules>里需要注册子模块不要引入maven的打包插件&#xff0c;否则打包时会出问题 <?xml version"1.0" encoding"UTF-8…...

IT供电系统绝缘监测及故障定位解决方案

随着新能源的快速发展&#xff0c;光伏电站、储能系统及充电设备已广泛应用于现代能源网络。在光伏领域&#xff0c;IT供电系统凭借其持续供电性好、安全性高等优势成为光伏首选&#xff0c;但在长期运行中&#xff0c;例如老化、潮湿、隐裂、机械损伤等问题会影响光伏板绝缘层…...

成都鼎讯硬核科技!雷达目标与干扰模拟器,以卓越性能制胜电磁频谱战

在现代战争中&#xff0c;电磁频谱已成为继陆、海、空、天之后的 “第五维战场”&#xff0c;雷达作为电磁频谱领域的关键装备&#xff0c;其干扰与抗干扰能力的较量&#xff0c;直接影响着战争的胜负走向。由成都鼎讯科技匠心打造的雷达目标与干扰模拟器&#xff0c;凭借数字射…...

实现弹窗随键盘上移居中

实现弹窗随键盘上移的核心思路 在Android中&#xff0c;可以通过监听键盘的显示和隐藏事件&#xff0c;动态调整弹窗的位置。关键点在于获取键盘高度&#xff0c;并计算剩余屏幕空间以重新定位弹窗。 // 在Activity或Fragment中设置键盘监听 val rootView findViewById<V…...

Java毕业设计:WML信息查询与后端信息发布系统开发

JAVAWML信息查询与后端信息发布系统实现 一、系统概述 本系统基于Java和WML(无线标记语言)技术开发&#xff0c;实现了移动设备上的信息查询与后端信息发布功能。系统采用B/S架构&#xff0c;服务器端使用Java Servlet处理请求&#xff0c;数据库采用MySQL存储信息&#xff0…...

BLEU评分:机器翻译质量评估的黄金标准

BLEU评分&#xff1a;机器翻译质量评估的黄金标准 1. 引言 在自然语言处理(NLP)领域&#xff0c;衡量一个机器翻译模型的性能至关重要。BLEU (Bilingual Evaluation Understudy) 作为一种自动化评估指标&#xff0c;自2002年由IBM的Kishore Papineni等人提出以来&#xff0c;…...

【Elasticsearch】Elasticsearch 在大数据生态圈的地位 实践经验

Elasticsearch 在大数据生态圈的地位 & 实践经验 1.Elasticsearch 的优势1.1 Elasticsearch 解决的核心问题1.1.1 传统方案的短板1.1.2 Elasticsearch 的解决方案 1.2 与大数据组件的对比优势1.3 关键优势技术支撑1.4 Elasticsearch 的竞品1.4.1 全文搜索领域1.4.2 日志分析…...