docs
属性动画

属性动画

属性动画(property animation)是指属性值随时间变化的概念。我们如何表达这一点?服务用来获取某个属性在某一时刻值的 API 是什么?允许程序操作动画的 API 又是什么?

属性动画最早在 v0.9.0 中引入。

  • 关键帧(keyframe)的时间——就像 MLT 中大多数时间或位置的情况一样——可以用帧号、时钟字符串或时间码(timecode)字符串来设置。
  • 负的时间值使其相对于一个对象时长的结尾。
  • 关键帧支持 3 种插值形式:离散(discrete,无插值)、线性,以及平滑的 Catmull-Rom 样条。
  • 除了字符串(仅离散)、整数和浮点数之外,还支持那种有些新引入的 mlt_rect 属性类型。
  • 属性动画与 mlt_rect 的组合旨在取代 mlt_geometry API。

曲线

上面是对下面这个整数属性值所描述曲线的绘制:0|=50; 50|=100; 100=200; 200~=60; -7:00~=180; -2:00~=100; -1=220

位置或时间在等号左边,值在右边,各对之间用分号分隔。空白是可选的,并且当框架从其内部对象表示序列化该值时不会包含空白。

可以在同一条曲线中组合若干种不同的东西。它先是离散的关键帧(|),切换到线性插值的关键帧(=),最后以几个用相对于结尾/宽度的时间码(-)设置的平滑样条关键帧(~)结束。

API

其 C API 见我们的参考文档 mlt_properties (opens in a new tab) (名字中带 anim 的函数)和 mlt_animation (opens in a new tab)。 主要接口是属性(properties)API。动画 API 作为补充,提供动画的展开表示,其中每个关键帧都可以作为一个对象被取出。它还增加了移除关键帧的能力,而这在属性 API 中如果不从一个字符串值重建就无法直接做到。

对于 C++ 以及脚本/托管语言,提供了新的 mlt_properties anim 函数,但尚未提供 mlt_animation。不过,在一个 分支 (opens in a new tab) 中有最近的工作,用于添加 Mlt::Animation API。我们特意避免暴露那些本意上仅供 mlt_properties 使用的 C mlt_animation API 函数。例如,mlt_animation_item 包含一个 mlt_property,但按设计 mlt_property 在 C++ 中并不暴露。你应当能够通过属性 API 完成所有事情。同样,那些需要 fps 和 locale_t 参数的函数被省略了,因为 mlt_properties 和 mlt_property 会使用并提供这些值。如果某些方法看起来是冗余的——例如 Mlt::Properties::get_animation() 和 Mlt::Properties::get_anim()——那是为了相对脚本/托管语言绑定所需,为 C++ 提供更好的选项。

人们可以从包含在 MLT 源代码树中 src/tests/test_properties 和 src/tests/test_animation 里的单元测试中,了解到大量关于如何使用这些 API 的知识。

开发状态

截至 2015 年 6 月 12 日,C++ Mlt::Animation API 正在一个分支中孵化,且并非所有服务的可变属性都支持它。服务确实需要被更新以便按时间获取值。此外,那些原本使用 mlt_geometry 的服务尚未被更新。仍有大量工作要做……。

支持新属性动画的服务: (注意:这份列表已过时,已有更多服务被转换。MLT 的第 7 版增加了一个新的 animation 参数属性,用来指示支持动画的参数,并将取代这份列表。)

  • core/filter_brightness
  • core/filter_gamma
  • core/filter_panner
  • core/producer_tone
  • jackrack/filter_ladspa (as of git 6/24/2015)
  • jackrack/producer_ladspa (as of git 6/24/2015)
  • kdenlive/filter_boxblur
  • kdenlive/filter_wave
  • normalize/filter_volume
  • oldfilm/filter_dust
  • oldfilm/filter_grain
  • oldfilm/filter_lines
  • oldfilm/filter_oldfilm
  • oldfilm/filter_tcolor
  • opengl/filter_movit_blur
  • opengl/filter_movit_deconvolution_sharpen
  • opengl/filter_movit_diffusion
  • opengl/filter_movit_glow
  • opengl/filter_movit_lift_gamma_gain
  • opengl/filter_movit_opacity
  • opengl/filter_movit_resize
  • opengl/filter_movit_saturation
  • opengl/filter_movit_vignette
  • opengl/filter_movit_white_balance
  • opengl/transition_movit_luma
  • opengl/transition_movit_mix
  • plus/filter_charcoal
  • plus/filter_lift_gamma_gain
  • plus/filter_lumakey
  • plus/filter_sepia
  • plusgpl/filter_burn
  • plusgpl/filter_lumaliftgaingamma
  • qt/filter_audiowaveform
  • qt/filter_lightshow

使用旧的 mlt_geometry API 的服务:

  • core/transition_composite
  • gdk/producer_pango
  • motion_est/filter_autotrack_rectangle
  • motion_est/filter_crop_detect
  • motion_est/filter_motion_est
  • plus/transition_affine