[assetWriterInput requestMediaDataWhenReadyOnQueue:mediaInputQueue
usingBlock: ^
{
// NSLog (@"top of block");
while (assetWriterInput.readyForMoreMediaData) {
CMSampleBufferRef nextBuffer = [assetReaderOutput copyNextSampleBuffer];
if (nextBuffer) {
// append buffer
[assetWriterInput appendSampleBuffer: nextBuffer];
convertedByteCount += CMSampleBufferGetTotalSampleSize (nextBuffer);
// http://stackoverflow.com/questions/19119422/convert-caf-file-to-wav-file-with-progress-bar-in-ios
CMTime progressTime = CMSampleBufferGetPresentationTimeStamp(nextBuffer);
CMTime sampleDuration = CMSampleBufferGetDuration(nextBuffer);
if (CMTIME_IS_NUMERIC(sampleDuration))
progressTime= CMTimeAdd(progressTime, sampleDuration);
float dProgress= CMTimeGetSeconds(progressTime) / CMTimeGetSeconds(songAsset.duration);
NSLLog(@"progress:%f",dProgress);
}
From: Kevin Dixon <
email@hidden>
Date: Thursday, June 16, 2016 at 1:15 PM
To: Andrew Davidson <
email@hidden>
Cc: coreaudio-api <
email@hidden>
Subject: Re: AVAssetReader how to get file size
You will have to represent your progress bar with the duration I think. You can look at the current format settings (e.g. Sample Rate, etc) to determine how much data you've pulled out with copyNextBuffer as you go as a percentage of duration
Kevin