有人可以解释一下源时间、电影时间、演示时间等吗?
在我的 iOS 应用程序中,我需要将图像保存为短视频片段。我使用 AVAssetWriter 和 AVAssetWriterPixelBufferAdaptor 来完成这项工作,这要归功于该网站上的一些精彩帖子,但我不得不捏造开始和结束会话时间以及演示时间,因为我不太理解它们。
下面的片段创建了一个 2 秒的视频,但我通过反复试验设置了不同的时间。老实说,我不知道为什么它不创建 3 秒的视频。
// start session
videoWriter.movieFragmentInterval = CMTimeMake(1,600);
[videoWriter startWriting];
CMTime startTime = CMTimeMake(0, 600);
[videoWriter startSessionAtSourceTime:startTime];
while (1) {
if (![writerInput isReadyForMoreMediaData]) {
NSLog(@"Not ready for data");
} else {
[avAdaptor appendPixelBuffer:pixelBuffer
withPresentationTime:CMTimeMake(1200,600)];
break;
}
}
//Finish the session:
[writerInput markAsFinished];
CMTime endTime = CMTimeMake(1800, 600);
[videoWriter endSessionAtSourceTime:endTime];
[videoWriter finishWriting];
谁能解释一下这个片段中的各种时间设置,或者给我指出一个有帮助的文档?我已经阅读了苹果文档,直到我斗鸡眼,但我猜他们假设的知识比我目前拥有的知识更多。
蒂亚:约翰
In my iOS app, I need to save an image as a short video segment. I have this working using AVAssetWriter and AVAssetWriterPixelBufferAdaptor, thanks to some of the great posts on this site, but I've had to fudge the start and end session times, and presentation times, because I don't really understand them.
The following fragment creates a 2 second video, but I've set the various times by trial and error. I'm not sure why it doesn't create a 3 second video, to be honest.
// start session
videoWriter.movieFragmentInterval = CMTimeMake(1,600);
[videoWriter startWriting];
CMTime startTime = CMTimeMake(0, 600);
[videoWriter startSessionAtSourceTime:startTime];
while (1) {
if (![writerInput isReadyForMoreMediaData]) {
NSLog(@"Not ready for data");
} else {
[avAdaptor appendPixelBuffer:pixelBuffer
withPresentationTime:CMTimeMake(1200,600)];
break;
}
}
//Finish the session:
[writerInput markAsFinished];
CMTime endTime = CMTimeMake(1800, 600);
[videoWriter endSessionAtSourceTime:endTime];
[videoWriter finishWriting];
Can anyone explain the various time settings in this fragment, or point me to a document that will help? I've read the apple docs until I'm cross-eyed, but they assume more knowledge than I currently have, I guess.
TIA: John
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论