• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: AAC Priming Info Under 64-bit
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AAC Priming Info Under 64-bit


  • Subject: Re: AAC Priming Info Under 64-bit
  • From: Michael Miller <email@hidden>
  • Date: Thu, 18 Oct 2012 17:14:23 -0400

Hi Heinrich,

I saw your post while searching for solutions but came up empty-handed just like you. I'm not sure how much you can rely on the result of the method below. It does give me 2112 and seems to make some amount of sense, but again, seems a little bit fragile.

I'm using AVAssetReader to get out compressed frames from the AVAsset by passing in NULL for the options dictionary in the AVAssetReaderTrackOutput. When I start reading, I know what presentation time I asked for. AVFoundation will accommodate that request by returning a CMSampleBuffer with a TrimAtStart attachment that seems to cover both the priming frames and the offset into the buffer to make its output presentation timestamp match the requested time. Therefore, I do something like this:

CMTime startTime = CMTimeMake(10000, 44100);
CMTimeRange range = CMTimeRangeMake(startTime, kCMTimePositiveInfinity);
[assetReader setTimeRange:range];
AVAssetTrack* track = [[asset tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0];


AVAssetReaderTrackOutput* output = [AVAssetReaderTrackOutput assetReaderTrackOutputWithTrack:track outputSettings:nil];
[assetReader addOutput:output];
[assetReader startReading];


if ([assetReader status] == AVAssetReaderStatusReading)
{
if (CMSampleBufferRef buffer = [output copyNextSampleBuffer])
{
if (::CMSampleBufferGetDataBuffer(buffer))
{
// The time of the buffer we received, which should preceed the time we requested
CMTime presentationTime = ::CMSampleBufferGetPresentationTimeStamp(buffer);


// The time we requested in presentation units
CMTime requestedTime = [track samplePresentationTimeForTrackTime:startTime];


// trim = priming frames + offset into buffer to satisfy our requested time
CFDictionaryRef trimAtStartDictionary = (CFDictionaryRef)::CMGetAttachment(buffer, kCMSampleBufferAttachmentKey_TrimDurationAtStart, NULL);
CMTime trimAtStart = trimAtStartDictionary ? ::CMTimeMakeFromDictionary(trimAtStartDictionary) : kCMTimeZero;


// Therefore, priming frames = trim - offset
CMTime offset = ::CMTimeSubtract(requestedTime, presentationTime);
CMTime primingFrames = CMTimeSubtract(trimAtStart, offset);
printf("Priming frames: ");
CMTimeShow(primingFrames);
}


CFRelease(buffer);
}
}

Relying on the AudioConverter's result based upon the AudioStreamBasicDescription and magic cookie in the CMFormatDescription seems more sound to me, but again, it fails in 64-bit for some reason.

Thanks!
Michael Miller

On Oct 18, 2012, at 4:23 PM, Heinrich Fink wrote:

Hi Michael,

Unfortunately, I can't use the AudioFile API to get the packet table because I'm dealing with both movie files and audio files. And AVFoundation doesn't seem to provide this information in any direct way, though I can introspect about it in a somewhat sketchy fashion.

I know this is not really helping you with  your main issue, but I have posted a question about retrieving priming/remainder figures

with AVFoundation recently, but haven't got an answer so far (I need to read mov files as well...). Would you mind briefly describing the "sketchy" way of doing so? I would really appreciate that!

I would be glad to run your example code, and give you feedback on that, once I'm back in the office.

Best regards,

Heinrich



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: AAC Priming Info Under 64-bit
      • From: Heinrich Fink <email@hidden>
References: 
 >Re: AAC Priming Info Under 64-bit (From: Heinrich Fink <email@hidden>)

  • Prev by Date: Re: AAC Priming Info Under 64-bit
  • Next by Date: Re: AAC Priming Info Under 64-bit
  • Previous by thread: Re: AAC Priming Info Under 64-bit
  • Next by thread: Re: AAC Priming Info Under 64-bit
  • Index(es):
    • Date
    • Thread