使用 C#/C++ 从 iPhone 电影获取矩阵 (CGAffineTransform) 信息

发布于 2024-12-03 14:24:12 字数 603 浏览 1 评论 0原文

当 iPhone 录制视频时,它会将相机中的数据直接保存到磁盘上。告诉播放器如何重新定向视频的是变换矩阵。它是一种数学结构,用于更改 X、Y 空间中像素的位置。

在 iPhone 和 Macintosh 中,我可以询问视频它的 Transform 是什么,然后我得到带有 abcd tx 和 ty 的 CGAffineTransform。苹果在这里描述了 变换矩阵

有了这些信息,我可以确定视频布局应该是什么,并确定它是否期望在显示前旋转。

我可以在 osx 和 ios 环境中轻松获取此信息。我正在尝试确定一种方法来获取与 Windows 相同的矩阵信息。首选 C#,但如果我必须使用 C++,那就这样吧。 Active X 解决方案是完全不可取的,我希望 Windows 版 Quicktime SDK 有一些用处。不然苹果写这个到底是为了什么?

如果有人知道如何从视频或任何开始的地方获取变换矩阵,请为我指出正确的方向。

When the iPhone records a video it puts the data from the camera directly onto the disk. What tells the player how to reorient the video is the Transform Matrix. Its a Mathematics structure that is used to change the position of the pixels in X,Y space.

In the iPhone and in the Macintosh I can ask the Video what its Transform is, and I get back a CGAffineTransform with a b c d tx and ty. Apple describes the Transform Matrix here

With this information I can determine what the Video layout is supposed to be and determine if it is expecting to be rotated before display.

I can get this information with ease in the osx and ios environments. I am trying to determine a way to get the same matrix information with Windows. Preferrable C# however if I must use C++ then so be it. Active X solutions are entirely undesirable and I am hoping that the Quicktime SDK for windows has some use. Otherwise what the heck did Apple write it for ??

If anyone knows how to obtain the Transform Matrix from a video or any place to start please, point me in the right direction.

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

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

发布评论

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

评论(1

铜锣湾横着走 2024-12-10 14:24:12

看来 CGAffineTransform 需要从文件本身中直接提取出来。我使用 Quicktime 文件格式规范 pdf 来了解该文件以及在哪里获取 CGAffineMatrix

这里是包含矩阵数据的页面的链接

Quicktime 文件格式规范矩阵信息

正如您从该剪辑中看到的,矩阵位于电影标头原子中。端庄的“mvhd”类型。

它总共有 36 个字节长,并且在“mvhd”原子类型名之后总共有 36 个字节。

考虑到帧和轨道的文件格式规范,矩阵可以在视频播放过程中发生变化。但根据我的经验,这种方法不适用于从 iPhone 输出的视频。

我想在不久的将来,需要从每一帧中抓取矩阵,也许 FFMpeg 或其他视频格式应用程序可以将其应用到其帧采集器和视频转换器中。但由于我目前没有使用此矩阵信息的 ffmpeg 版本,我将创建一个简单的电影标题捕获器,它将拉出矩阵并允许我相应地调整我的 ffmpeg 命令行参数,从而允许我适当地翻译我的视频..

如果我想出更好的主意,我会尝试将这篇文章包含在该知识中。

来自 Quicktime 文件格式的剪辑

关于此答案过程的旁注

对于所有这些谁对这个问题投了反对票,因为你不知道我在说什么。要求澄清就足够了。因为你不理解或不知道答案而进来投票,既不具有建设性也不公平。这是一个非常具体的问题,这个答案不仅对我自己有帮助。

我相信帮助传播各种知识,以及那些认为投反对票有帮助的人,因为你们不知道如何提供帮助。我希望这能让您更好地理解人们想要解决的问题。仅仅因为您不知道问题是什么,并不意味着您应该对此嗤之以鼻,当然也不意味着您应该忽视那些寻找您无法提供的答案的人。

我很高兴我的问题得到了答案,并且肯定会接受对我给出的答案的任何进一步的批评。也许这个答案会引发更多关于这个问题的问题,我将能够学习并为未来的讨论做出贡献,

谢谢 StackOverflow 恢复我的问题,以便我可以适当地回答它。

It appears that the CGAffineTransform is something that will need to be pulled right out of the file itself. I used the Quicktime File Format Specification pdf to gain an understanding of the file and where to get the CGAffineMatrix

Here is a link to the page with the Matrix data on it

Quicktime File Format Specification Matrix Info

as you can see from this clip the matrix is in the Movie header atom. dignified with the 'mvhd' type.

it is a total of 36 Bytes long and is a total of 36 bytes after the 'mvhd' atom typename.

Given the file format specifications of the frames and tracks the Matrix can change throughout the playback of the video. But it is my experience that this method is not exercised on the videos that are output from the iphone.

I imagine that the matrix will need to be grabbed from each frame sometime in the near future and perhaps this is something that FFMpeg or other video format applications can work into their frame grabbers and video translators. But since I currently do not have a version of ffmpeg that used this matrix information I will be creating a simple Movie header grabber that will pull out the matrix and allow me to adjust my ffmpeg command line parameters accordingly, allowing me to translate my video appropriately..

If I come up with a better idea I will try to include this post on that knowledge.

Clip from the Quicktime File format

A side note on the journey to this answer

For all of those who downvoted this question because You did not know what I was talking about. A request to clarify could have been quite sufficient. Coming in and downvoting because you dont understand or dont know the answer is neither constructive or fair. This is a very specific question and this answer will assist more than just myself.

I believe in helping to spread all kinds of knowledge and those of you who think its helpful to downvote because you just dont have any clue on how to help. I hope this gives you a better understanding of the issues that people are looking to solve. Just because you dont know what the problem is does not mean you should turn your nose up at it and certainly does not mean that you should discount those looking for answers that you cannot provide.

I am glad that I have an answer to my question and will definitely be open to any further criticism to the answer that I have given. Perhaps this answer will spark more questions about this issue and I will be able to learn and contribute to the future discussions about it

Thank you StackOverflow for restoring my question so I could answer it appropriately.

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