[英]iOS / iPhone - AVAssetWriter : How to use endSessionAtSourceTime:
I am using AVAssetWriter to create an MPEG4 file. 我正在使用AVAssetWriter创建MPEG4文件。
I start a video session with: 我开始视频会议:
[assetWriter startSessionAtSourceTime:kCMTimeZero];
Now the video file is written fine if I finish the session with this: 现在,如果我以此结束会议,视频文件就写得很好:
[assetWriter finishWritingWithCompletionHandler:^{
}];
But if I call [assetWriter endSessionAtSourceTime:endTime];
但是,如果我调用
[assetWriter endSessionAtSourceTime:endTime];
before [assetWriter finishWritingWithCompletionHandler
then it doesn't write the file. 在
[assetWriter finishWritingWithCompletionHandler
之前,它不会写入文件。
This is how I call endSessionAtSourceTime
: 这就是我所说的
endSessionAtSourceTime
:
endTime = CMTimeMakeWithSeconds(secondsRecorded, 30);
[assetWriter endSessionAtSourceTime:endTime];
Any ideas what i am doing wrong? 任何想法我在做什么错?
I think the issue is that the behavior of endSessionAtSourceTime: doesn't do what you're expecting. 我认为问题在于endSessionAtSourceTime:的行为未达到您的期望。
endSessionAtSourceTime: is almost the same thing as calling finishRecording() in that it stops the recording when called. endSessionAtSourceTime:与调用finishRecording()几乎相同,因为它在被调用时会停止记录。 The difference is that after recording, endSessionAtSourceTime: will edit out (remove) any frames received after the specified sourceTime.
区别在于,录制后,endSessionAtSourceTime:将删除(删除)在指定sourceTime之后收到的所有帧。
Instead, if your intended result is to record a 30second clip, you need to setup an NSTimer or something similar and then call endSessionAtSourceTime: or finishRecording() when the 30 seconds has elapsed 相反,如果您的预期结果是录制30秒的剪辑,则需要设置NSTimer或类似的东西,然后在30秒过去后调用endSessionAtSourceTime:或finishRecording()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.