如何使用 QTMovie API 提取流媒体 (RTSP) 电影的 QTTrack?
有谁知道如何使用 QTMovie (QTKit) API 获取 RTSP 流媒体电影的 QTTracks?
基本上我想从电影中提取音频和视频轨道,并在播放之前进行一些额外的处理。
以下是一个简化的代码片段,这对于本地电影文件非常有用,但对于 RTSP 流则失败:
NSError* err = nil;
QTMovie* myMovie = [QTMovie movieWithURL: @"rtsp://example.com/123.mov" error: &err];
NSNumber* loadState = [mMovie attributeForKey: QTMovieLoadStateAttribute];
// This succeeds
if ( [loadState intValue] >= QTMovieLoadStatePlayable ) {
// This fails - audioTracks returns a count of 0
NSArray* audioTracks = [mMovie tracksOfMediaType: QTMediaTypeSound];
if ( [audioTracks count] > 0 ) {
[self processTrack: (QTTrack*)[audioTracks lastObject]];
}
}
提前感谢您的所有帮助。
Is anyone aware of how to get the QTTracks for a RTSP streamed movie using QTMovie (QTKit) APIs?
Basically I want to extract audio and video tracks from the movie and do some extra processing before playing them.
Following is a simplified code snippet, this works great for local movie files but fails for RTSP streams:
NSError* err = nil;
QTMovie* myMovie = [QTMovie movieWithURL: @"rtsp://example.com/123.mov" error: &err];
NSNumber* loadState = [mMovie attributeForKey: QTMovieLoadStateAttribute];
// This succeeds
if ( [loadState intValue] >= QTMovieLoadStatePlayable ) {
// This fails - audioTracks returns a count of 0
NSArray* audioTracks = [mMovie tracksOfMediaType: QTMediaTypeSound];
if ( [audioTracks count] > 0 ) {
[self processTrack: (QTTrack*)[audioTracks lastObject]];
}
}
Thanks in advance for all your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于 rtsp 流,QTMovie 处理的实际文件是一个“流媒体处理程序”容器,大小约为 10kb,您可以通过查看 QTMovieDataSizeAttribute 键是否低于 200 左右来验证,无法获取其中的实际数据流(即使使用 10.7 AVCaptureInput API)
With rtsp streams the actual file the QTMovie works on is a "stream media handler" container, about 10kb in size, you can verify by seeing if the QTMovieDataSizeAttribute key is under 200 or so, there is no way to get to the actual data in the stream (not even with the 10.7 AVCaptureInput api)