Why isReadyForMoreMediaData is false sometimes?

Hi, Recording Videos with AVAssetWriter, capture fps(camera output fps) is ok, but final result video fps was lower, the reason is AVAssetWriterInput.isReadyForMoreMediaData is false sometimes.

Yes, I have read document many times, it said need to set expectsMediaDataInRealTime to true and balabala...

I really be tortured by this problem for a long time, can I debug this problem? or any advice?

Answered by Engineer in 802950022

Hello @PhonJac, the discussion section in isReadyForMoreMediaData explains that when expectsMediaDataInRealTime, the isReadyForMoreMediaData property becomes false only when the input can’t process media samples at the current data rate. If that is the case, your app may need to reduce the rate at which it appends samples, or drop them altogether.

If you cannot reduce the rate at which samples are acquired, and you don't want to drop samples, one suggestion is to implement some queueing mechanism to cope with AVAssetWriterInput. In that case, it might be easier to use requestMediaDataWhenReady(on:using:), effectively regarding this queueing mechanism as a non-real-time source.

Hello @PhonJac, the discussion section in isReadyForMoreMediaData explains that when expectsMediaDataInRealTime, the isReadyForMoreMediaData property becomes false only when the input can’t process media samples at the current data rate. If that is the case, your app may need to reduce the rate at which it appends samples, or drop them altogether.

If you cannot reduce the rate at which samples are acquired, and you don't want to drop samples, one suggestion is to implement some queueing mechanism to cope with AVAssetWriterInput. In that case, it might be easier to use requestMediaDataWhenReady(on:using:), effectively regarding this queueing mechanism as a non-real-time source.

Phon, what frame rate and resolution are you attempting to write with AssetWriter? What are your video compression settings? That might give us a clue why the writes are taking a long time.

Why isReadyForMoreMediaData is false sometimes?
 
 
Q