Hi Jeffrey, Some thoughts:
iTunes doesn't use QuickTime for playback, at least not in the way that any other application does. As far as I know, REALbasic is just wrapping the QuickTime API in some REALbasic objects and the MoviePlayer control. I'd doubt that the RB MoviePlayer is using a sample rate of 43,892 kHz. It's more likely that the endpoint is being calculated incorrectly in some cases, or is being estimated by QuickTime when opened. The sample code I posted (IIRC) actually extracts the audio - i.e., works through the entire file and converts the encoded MP3 track into raw samples - so once it's done, you would have the true number of samples from the file. Out of interest, is the MP3 in question a VBR (Variable Bit Rate) MP3? If so, that might explain why only certain MP3s (from Bruce) have this problem. The QuickTime MP3 importer isn't a big fan of VBR files, and this might be the source of the inconsistencies. I could believe that for a long VBR, QuickTime might estimate the length inaccurately. I guess my other question would be, what are you looking to use the duration info for? Dave. > From: Jeffrey Mattox <[EMAIL PROTECTED]> > Reply-To: REALbasic NUG <[email protected]> > Date: Fri, 31 Mar 2006 16:51:18 -0600 > To: <[email protected]> > Subject: MoviePlayer and MP3 audio sample rates > > Summary: > > The RB MoviePlayer appears to be using a sample rate of 43,892 kHz > for mp3 files, instead of 44,100 kHz. > > > Details: > > I am processing 53-minute mp3 files (podcasts) and, among other > things, visualizing the waveform. To get the audio samples, I am > using Dave Addey's code posted on the RB forums and here: > > http://tinyurl.com/pzlnt > > I discovered a problem when trying to match the player position with > the corresponding audio sample in the waveform. > > > Observations: > > If I use Sound Studio to convert the file to AIFF, then everything is > fine, and I get consistent readings from these various sources: > > iTunes, Finder, QuickTime Player, Sound Studio, and my RB application: > > Length: 53:00 (mm:ss) > Sample rate: 44,100 kHz > Samples: 140,234,105 > > > Mysteries: > > 1. If I use the original mp3 file, then the RB MoviePlayer reports > the length as 53:15 (and it actually takes that long to play). QT > Player and iTunes still report 53:00 when using the mp3. > > 2. The code referenced above thinks the sample rate is 44,100, but > it generates 140,899,941 samples (at 44,100 that is 53:15) of which > the last 665,836 samples are zero (a "tail"). Prior to the tail, > there are 140,234,105 useful samples (same as the AIFF). Somehow, > this code thinks the length is 53:15, too, even though it still uses > 44,100 kHz for the valid samples. > > So, it appears that the RB player is using a sample rate of 43,892 > kHz. That accounts for the extra 15 seconds. I can correlate the RB > position to the samples as follows: > > sample_index = MyMoviePlayer.Position * 43892 > > Can you offer any insights into these mysteries? And is there a way > to fetch the sample rate being used by the MoviePlayer? > > Jeff > _______________________________________________ > Unsubscribe or switch delivery mode: > <http://www.realsoftware.com/support/listmanager/> > > Search the archives of this list here: > <http://support.realsoftware.com/listarchives/lists.html> _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html>
