1. FxPlug 4.0 SDK
昨天下班回家,给家里的电脑也安上了FxPlug,家里的FCPX跟Motion版本比较新,可以使用FxPlug 4.0。一套流程走下载,感觉比FxPlug 3.0方便不少。省去了拷贝文件去特定目录的工作。官方自带的Example编译完,运行一遍Wrapper Application,立刻就可以在Motion里面找到这个效果。
2. 几个概念
FxPlug 4涉及几个概念,第一个是Host Applications,文档里说:
Host Applications Plug-ins can be used in both Final Cut Pro X and Motion—referred to as the host applications. Plug-ins can be used directly in Motion, but before they can be applied in Final Cut Pro X, they must be wrapped in a template. (This is outlined in Preparing Plug-ins for Use in FCPX.) Once built, plug-ins are recognized by macOS automatically and are vended to the host applications on-request.
如果说FCPX跟Motion是Host Application,那么用FxPlug写的插件就是Host Applications Plug-ins。
接下来是PlugInKit与XPC service,文档里说:
macOS includes a technology called PlugInKit to discover and register plug-ins on a system. Once a host application launches, PlugInKit reports a list of plug-ins that are available to that type of host. When a plug-in is instantiated, the out-of-process XPC service comes to life and establishes a connection with the host application, and mediates the transfer of information.
PlugInKit是macOS的一套插件机制,XPC service是macOS的跨进程通讯的技术(OS X interprocess communication technology)。这些都是技术概念,了解一下就好。
这几个概念了解下来,感觉本质还是把复杂接口(包括复制文件到指定路径)封装,遵循一定的协议,提供服务。如图所示,我们编写的FxPlug插件,通过PlugInKit被系统识别后,当打开FCPX或者Motion 5并且被调用的时候,FCPX通过XPC与插件通信(传输图像等)。
3. 为什么一定要Motion 5
昨天还不理解为什么FxPlug的效果不能在FCPX里直接用,看完FxPlug 4的文档后,感觉有点儿懂了。Motion 5在编写插件的流程里,是为了降低使用的复杂度。使用FCPX剪辑影片时,追求的是完成特定的任务,比方说完成一次转场,而这个转场也许可以提供几个简单参数在FCPX中调整,但是较为复杂的参数,比如像是模糊多少度、粒子系统创建多少个粒子,粒子生命周期在什么范围等,最好把这些复杂性,封装在Motion里。这样一来,在整个视频产业链里,写代码,做特效,做剪辑,各司其职,嘿嘿。