Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于Timeline中的overlays轨道 #8

Closed
xuzhenhao opened this issue Nov 23, 2018 · 4 comments
Closed

关于Timeline中的overlays轨道 #8

xuzhenhao opened this issue Nov 23, 2018 · 4 comments

Comments

@xuzhenhao
Copy link

没有找到关于overlayers轨道的demo。研究了下你的源码,不知道理解的对不对,请教一下。如果要使用overlays轨道,实现当前track中x:50,y,50的坐标中放一个size为50*50的overlay。参考了了ImageOverlayItem的实现方法,可以通过trackItem.configuration.videoConfiguration.transform配置来传相应的transform实现,这样可以实现,但使用起来不是很方便。

我的理解,overlays: [VideoProvider] ,overlays不只是VideoProvider协议,更合适的是进一步封装了frame的协议。

@vitoziv
Copy link
Contributor

vitoziv commented Nov 25, 2018

确实是有提供设置 frame 的设置比较方便。我重新思考了一下对 frame 的支持,你的建议提醒了我。在 videoConfiguration 里的 baseContentMode 其实会和 frame 有设置上的冲突,只有在 baseContentMode 为 custom 的时候才适合设置 frame。

所以我重构了一下 frame 的位置,ImageOverlayItem 里面不再有 frame 属性,而是在 videoConfiguration 的 baseContentMode 里设置 frame。

代码大概是这样

let frame = CGRect()
videoConfiguration.baseContentMode = .custom(frame)

这样,无论是视频还是图片都可以设置 frame 了

你可以拉最新的代码试试

@xuzhenhao
Copy link
Author

确实是有提供设置 frame 的设置比较方便。我重新思考了一下对 frame 的支持,你的建议提醒了我。在 videoConfiguration 里的 baseContentMode 其实会和 frame 有设置上的冲突,只有在 baseContentMode 为 custom 的时候才适合设置 frame。

所以我重构了一下 frame 的位置,ImageOverlayItem 里面不再有 frame 属性,而是在 videoConfiguration 的 baseContentMode 里设置 frame。

代码大概是这样

let frame = CGRect()
videoConfiguration.baseContentMode = .custom(frame)

这样,无论是视频还是图片都可以设置 frame 了

你可以拉最新的代码试试

给效率点赞。另外请教一个问题,目前frame的效果是和CompositionGenerator的renderSize强关联的。不知道在实际项目中,是如何处理这种问题的。如果用户导出时,选择的尺寸改变了,是遍历一遍配置,进行相应的缩放修改还是有更好的方案。
另外,我参考了videoleap的交互体验,似乎也不是很理想,像从16:9调整成1:1,不是等比例的,所有的layer就会错位,需要用户重新手动修改一遍。

@vitoziv
Copy link
Contributor

vitoziv commented Nov 26, 2018

frame 是基于原始图像的大小进行缩放的,和 renderSize 没关系。只是 frame 的位置是基于 renderSize 的画布设置的,位置可能不是想要的。有想到可能可以引入对齐方式、anchorPoint 之类的东西,但是这种功能在 UI 上会比较复杂,现在我也还没有想到更好的方案哈。

@xuzhenhao
Copy link
Author

frame 是基于原始图像的大小进行缩放的,和 renderSize 没关系。只是 frame 的位置是基于 renderSize 的画布设置的,位置可能不是想要的。有想到可能可以引入对齐方式、anchorPoint 之类的东西,但是这种功能在 UI 上会比较复杂,现在我也还没有想到更好的方案哈。

感谢解答

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants