将 AVAssetWriter 的输出绕 x 轴旋转 180 度

发布于 2024-12-17 00:06:48 字数 625 浏览 6 评论 0原文

我正在使用 AVAssetWriter 创建 Quicktime 电影文件。目前输出视频是“颠倒的”。理论上,我可以通过将视频绕水平轴旋转 180 度(本质上是“翻转”视频)来纠正此问题。 执行此操作的最佳方法是什么?

目前,我正在尝试将 CGAffineTransform 分配给 myAVAssetWriterInput.transform。也许 CGAffineTransformMake(a, b, c, d, tx, ty) 允许我指定正确的仿射变换矩阵?

Apple 文档 和 < a href="http://en.wikipedia.org/wiki/Transformation_matrix#Affine_transformations" rel="noreferrer">wikipedia 给出了关于如何仿射变换矩阵有效。在一起可能有更好的方法。

I'm creating a Quicktime movie file using AVAssetWriter. Currently the output video is "upside down". In theory I can correct this by rotating the video 180 degrees about the horizontal axis (essentially "flipping" the video). What's the best way to do this?

Currently I'm trying to assign a CGAffineTransform to myAVAssetWriterInput.transform. Perhaps CGAffineTransformMake(a, b, c, d, tx, ty) will allow me to specify the correct affine transformation matrix?

Neither the Apple docs nor wikipedia gives a clear explanation on how an affine transformation matrix works. And there might be a better way all together.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

病女 2024-12-24 00:06:48
myAVAssetWriterInput.transform = CGAffineTransformMakeRotation(M_PI);

如果您想将视频绕 z 轴旋转 180 度,或者

myAVAssetWriterInput.transform = CGAffineTransformMakeScale(1, -1);

如果您想在 x 轴上反射

myAVAssetWriterInput.transform = CGAffineTransformMakeRotation(M_PI);

if you want to rotate the video 180 degrees around z-axis, or

myAVAssetWriterInput.transform = CGAffineTransformMakeScale(1, -1);

if you want to reflect in x-axis

天生の放荡 2024-12-24 00:06:48

[AVAssetTrack PreferredTransform] 将返回正确的 CGAffineTransform。

您可以将此 CGAffineTransform 分配给 writeInput

[AVAssetTrack preferredTransform] will return the right CGAffineTransform.

You can assign this CGAffineTransform to writeInput.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文