获取 QuickTime 元数据:编解码器、比特率、维度
我发现很难确定如何使用 QTKit 或 OS X 中较旧的 QuickTime API(针对 10.5+)从 QuickTime 影片中提取以下信息:
- 使用的视频和音频编解码器(例如“H.264”)
- 视频和音频比特率(例如 64 kbps)
- 尺寸
我遇到的具体问题是:
1)我发现的视频和音频编解码器名称的唯一方法涉及使用ImageDescriptionHandle
和 SoundDescriptionHandle
,两者似乎都需要仅 Carbon 的方法 NewHandleClear
和 DisposeHandle
,以及仅需要 32 位媒体对象。是否有一种更现代的方法不需要 Carbon 框架并且兼容 64 位?
2)对于比特率,我获取 GetMediaDataSizeTime64 并除以曲目持续时间(以秒为单位)。但是,对于一个音轨,该方法返回 128 kbps 的值,但使用音轨媒体和 kQTAudioPropertyID_FormatString
参数调用 QTSoundDescriptionGetProperty
会返回一串“ 64 kbps”。为什么这两个值会不同?有没有更好的方法来计算曲目的比特率?
3) 对于某一特定电影,[QTMovie movieAttributes] objectForKey:QTMovieNaturalSizeAttribute]
或 [QTTrack attributeForKey:QTTrackDimensionsAttribute]
返回的尺寸不正确。返回的尺寸为 720 x 480,但 QuickTime Player 中的实际视图尺寸为 640 x 480。播放器的信息窗口显示尺寸字符串“720 x 480 (640 x 480)”。有没有更好的方法来确定实际的电影尺寸?
提前致谢!
I'm finding it difficult to determine how to extract the following information from a QuickTime movie, either using QTKit or the older QuickTime APIs in OS X, targeting 10.5+:
- Video and audio codecs used (e.g. "H.264")
- Video and audio bitrates (e.g. 64 kbps)
- Dimensions
The specific problems I've encountered are:
1) The only means to the video and audio codec names that I've found involve the use of ImageDescriptionHandle
and SoundDescriptionHandle
, both of which appear to require the Carbon-only methods NewHandleClear
and DisposeHandle
, as well as requiring the 32-bit only Media object. Is there a more modern method that doesn't require the Carbon framework and is 64-bit compatible?
2) For the bitrate, I'm getting the GetMediaDataSizeTime64 and dividing by the track duration in seconds. However, in the case of one audio track, that method returns a value of 128 kbps, but calling QTSoundDescriptionGetProperty
with the audio track media and the kQTAudioPropertyID_FormatString
param returns a string of "64 kbps". Why would those two values be different? Is there a better way to calculate a track's bitrate?
3) Dimensions returned by [QTMovie movieAttributes] objectForKey:QTMovieNaturalSizeAttribute]
or by [QTTrack attributeForKey:QTTrackDimensionsAttribute]
are incorrect for one particular movie. The size returned is 720 x 480, but the actual view size in QuickTime Player is 640 x 480. Player's info window shows a size string of "720 x 480 (640 x 480)". Is there a better way to determine the actual movie dimensions?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此元数据可以从
[movie Track]
QTTrack*
对象获取。1)通过轨道枚举可以找到视频和音频轨道。
QTMedia* media = [track media];
有关编解码器的信息:
2) 要计算电影的比特率,您需要计算所有轨道的总数据大小并将其除以电影持续时间。
枚举轨道得到每个轨道的数据大小:
3) 获取电影的尺寸
但是,视频轨道的实际尺寸可能会有所不同:
This metadata can be obtained from the
[movie tracks]
QTTrack*
objects.1) Enumerating through the tracks you can find the video and audio tracks.
QTMedia* media = [track media];
The information about codecs:
2) To calculate the movie's bitrate you need to calculate the total data size of all tracks and divide it on the movie duration.
Enumerating through the tracks get the data size of each track:
3) To get the movie's dimensions
However, the actual dimensions of the video track may be different: