Re: Using AVPlayer to play MPMediaItem and add iPod EQ to the output
Re: Using AVPlayer to play MPMediaItem and add iPod EQ to the output
- Subject: Re: Using AVPlayer to play MPMediaItem and add iPod EQ to the output
- From: Kevin Dixon <email@hidden>
- Date: Wed, 01 Aug 2012 16:41:59 -0700
Fedry,
I was rendering the MPMediaItem with AVAssetReader, then recording the
output of the headphone jack (at the same sampling rate as my RemoteIO
unit was outputting).
By surrounding the real song with a 1kHz tone before and after it in
the playlist, it became clear where each file actually started and
stopped.
In software this would be trickier. Going back to Heinrich's question,
even with AVURLAssetPreferPreciseDurationAndTimingKey the reported
duration does not change.
On the first block from AVAssetReader, you could analyze the buffer
until you reach the first non-zero sample.
On the last block from AVAssetReader, you could analyze the buffer in
reverse until you reach a non-zero sample.
Neither of these approaches are particularly accurate, for example the
song might actually have some silence that was meant to be part of the
song.
Best of luck
-Kevin
On Wed, Aug 1, 2012 at 1:40 AM, Fedry Kemilau <email@hidden> wrote:
> Hi Kevin,
>
> How do you determine if there is silence in the beginning or end of an MPMediaItem?
>
> Regards,
> Fedry
>
>
> On 1 Aug, 2012, at 3:29 PM, Heinrich Fink <email@hidden> wrote:
>
> I am glad that worked for you. I still haven’t found a way how to access the actual number of valid audio samples ahead of copying the complete file. I will start a separate thread on this issue here.
>
> Just in case you don’t know that one already: ‘afinfo’ is a really useful tool to introspect an audio file from the command line. It also shows you the amount of prime/remainder samples of a compressed file.
>
> best regards,
>
> Heinrich
>
> On Jul 31, 2012, at 23:52 , Kevin Dixon <email@hidden> wrote:
>
>> Thanks Heinrich, I hadn't known about that property before. Now that I
>> am setting it to YES, I actually see a different behavior in
>> decoding-- those songs which I expect to be gapless are indeed playing
>> that way (I suppose removing the priming/remainder samples?)
>>
>> -Kevin
>>
>> On Tue, Jul 31, 2012 at 1:06 PM, Heinrich Fink <email@hidden> wrote:
>>> hi kevin,
>>>
>>>> This works well enough, but I've noticed that some tracks that play as
>>>> gapless under the main iOS Music App, or even in Winamp do not come
>>>> out gapless through this API. The decoded MP3s (from AVAssetReader)
>>>> may have 500-2000 samples of silence at the beginning or end, so I'm
>>>> curious about this as well.
>>>
>>> I believe what you describe are the priming/remainder samples which are specific to some audio codecs. AAC, for example, could have something like 2112 priming sample and 134 remainder samples. I think there are similar numbers for the mp3 codec.
>>>
>>> I have also recently build an audio scheduling system with an AUGraph that uses an AVAssetReader to access audio samples. I use an AVAssetReaderTrackOutput that is configured to return decoded non-interleaved float audio data. I ran into a problem that is similar to yours: When I read the AVURLAsset’s property “duration” (I have set ’AVURLAssetPreferPreciseDurationAndTimingKey’ set to ‘YES’): the returned property shows the full number of samples (priming samples + valid samples + remainder samples). However, I believe the correct number should be the ‘valid’ samples only as this is also the amount of samples returned by the AVAssetReaderTrackOutput. The ExtAudioFile API, for example, explicitly handles priming/remainder samples (checkout the property kExtAudioFileProperty_PacketTable described here http://developer.apple.com/library/ios/#documentation/MusicAudio/Reference/ExtendedAudioFileServicesReference/Reference/reference.html#//apple_ref/doc/c_ref/kExtAudioFileProperty_PacketTable)
>>>
>>> I have filed a bug about the AVURLAsset.duration not returning the correct amount of actual decodable audio samples. Does anyone else have experience with AVFoundation and priming/remainder samples?
>>>
>>> best regards,
>>>
>>> Heinrich Fink
>>>
>>
>
>
> _______________________________________________
> 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
>
_______________________________________________
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