I am using AVAssetWriter to create an MPEG4 file.
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];
before [assetWriter finishWritingWithCompletionHandler
then it doesn't write the file.
This is how I call 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: is almost the same thing as calling finishRecording() in that it stops the recording when called. The difference is that after recording, endSessionAtSourceTime: will edit out (remove) any frames received after the specified 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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.