Comments (4)
确实是有提供设置 frame 的设置比较方便。我重新思考了一下对 frame 的支持,你的建议提醒了我。在 videoConfiguration 里的 baseContentMode 其实会和 frame 有设置上的冲突,只有在 baseContentMode 为 custom 的时候才适合设置 frame。
所以我重构了一下 frame 的位置,ImageOverlayItem 里面不再有 frame 属性,而是在 videoConfiguration 的 baseContentMode 里设置 frame。
代码大概是这样
let frame = CGRect()
videoConfiguration.baseContentMode = .custom(frame)
这样,无论是视频还是图片都可以设置 frame 了
你可以拉最新的代码试试
from cabbage.
确实是有提供设置 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就会错位,需要用户重新手动修改一遍。
from cabbage.
frame 是基于原始图像的大小进行缩放的,和 renderSize 没关系。只是 frame 的位置是基于 renderSize 的画布设置的,位置可能不是想要的。有想到可能可以引入对齐方式、anchorPoint 之类的东西,但是这种功能在 UI 上会比较复杂,现在我也还没有想到更好的方案哈。
from cabbage.
frame 是基于原始图像的大小进行缩放的,和 renderSize 没关系。只是 frame 的位置是基于 renderSize 的画布设置的,位置可能不是想要的。有想到可能可以引入对齐方式、anchorPoint 之类的东西,但是这种功能在 UI 上会比较复杂,现在我也还没有想到更好的方案哈。
感谢解答
from cabbage.
Related Issues (20)
- Player add blur background HOT 6
- Use Kingfisher to report an error
- About the text overlay, edit, drag and drop, zoom. HOT 1
- CIImage Memory leak HOT 2
- Overlay H.265 Video with Transparency HOT 4
- option to change number of frames on export
- Sound gone when scaled video HOT 1
- Multiple timelines HOT 1
- black screen when the audio overlay goes to finish HOT 2
- transition demo not work HOT 1
- 如何知道轨道和片段之间的关系
- Is this framework support multiple layer blend mode? HOT 1
- Capture the current frame in composed player item HOT 1
- avplayer seek后,影音不同步 HOT 1
- Exported video appears to be darker (colour shifting) HOT 3
- Orientation problem: some videos are rotated by 90 or 180 degrees
- Example of merging several videos in sequence
- Example project doesn't work on Xcode 15 HOT 1
- 导出视频需要的时间太长
- how to support animation tools? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cabbage.