On Apr 1, 2006, at 1:30 PM, Jeffrey Mattox wrote:
Been there; done that. As an EditableMovie, the Duration is 3195
seconds, which is 53:15. The TimeScale is 600, the TimeDuration is
1,917,006, and that also yields 3195 seconds. In all respects, the
RB player thinks the length is 53:15, and it actually takes that
long to play.
I just did a test using QuickTime API calls to find the values
directly from the QuickTime engine. (your updated code at end of this
post - its MachO, but can be adapted to any platform but linux)
Here's what my tests show:
QuickTime Player:
Movie length : 52:59:88
MPEG Track length : 52.59.88
iTunes
Player: 53:00
Info-Options: 53:00.042
RB via QT Declares
Duration - 1917006.0 TimeScale units
TimeScale = 600
len = 3195.01 = 53.2501666667 sec = 53:15.01
RB only
len = 53:15
As you can see, there are no two matching values to be found...
EXCEPT REALbasic using Declares directly to the QuickTime API and
REALbasic itself. If you are going to use the QuickTime engine as the
basis for your playback needs, then I would say that REALbasic is the
ONLY one that is correct here. Now, there is the possibility that the
QuickTime engine itself has a bug in it and is reporting one of these
values incorrectly, but again, you have to choose some frame of
reference here. I'm choosing the QuickTime engine, since that's what
we have to work with (and not whatever iTunes or QuickTime player is
doing behind the scenes).
However, every other program (iTunes, QT Player, Sound Studio) says
it's 53:00. Addey's routine gives 53:15 (but that includes 15
seconds of silence at the end) -- another unsolved mystery.
It is a mistake to think that iTunes and QuickTime Player are
necessarily standards by which to measure and not REALbasic. I know
it may be hard to believe, but I think REALbasic is in the right this
time. I've done a lot of QuickTime development and I can say without
hesitation that I've found QTPlayer to not be the greatest when it
comes to reporting the precise length of files. This is true in both
the audio and video realm all the way down to the frame level.
So, the RB MoviePlayer is playing at a slightly slower rate. In
effect, it's adding more samples -- for every 212 samples (at
44,100 Hz), it's adding one phantom sample (yielding 43,892 Hz).
No, I really don't think this is true. It may appear that way and you
can find a value that makes the numbers work, but I honestly think QT
Player and iTunes are not reporting their precise times correctly.
I just need a way to compute the error. So far, I've had to do it
empirically or using prior knowledge of the correct length (53:00).
Instead, I need to fetch one parameter using the Movie.Handle and
OS functions that will give me the correct length. Then, I can
compute the error.
There is no error to computer, unless you want to compute the errors
of iTunes and QuickTime Player. REALbasic is reporting the same
values as the QuickTime engine.
Can I claim this as a bug: these particular mp3 files play longer
in RB than elsewhere?
I would say, no, not yet. Again, I would suggest posting to the
QuickTime lists and say "Hey, why do iTunes, QuickTime Player and
direct calls to the QuickTime engine all report a different duration
for this podcast MP3 on the iTunes store?". Once you get the answer
to that, THEN you can go after REALbasic if you think its the
culprit. I, however, do not.
-Erick
Declare Function GetMovieDuration Lib "/System/Library/Frameworks/
QuickTime.framework/QuickTime" _
(movie as integer) as integer
Declare Function GetMovieTimeScale Lib "/System/Library/
Frameworks/QuickTime.framework/QuickTime" _
(movie as integer) as integer
dim i,n as integer
Dim f as FolderItem
Dim m as Movie
Dim o as OpenDialog
o = new OpenDialog
o.PromptText = "Please select an audio file"
f = o.ShowModal
if ( f <> nil ) then
m = f.OpenAsMovie
if ( m <> nil ) then
MoviePlayer1.Movie = m
// must do this after loading the movie to make the player
clickable (RB bug)
MoviePlayer1.Top = 10
MoviePlayer1.Left = 10
MoviePlayer1.Width = 220
MoviePlayer1.Height = 16
MoviePlayer1.Play()
MoviePlayer1.Position = 100000 // go to the end
i = GetMovieDuration(m.handle)
n = GetMovieTimeScale(m.handle)
MsgBox "GetMovieDuration = "+format(i,"#.0")+" TimeScale
units"+chr(13)+"GetMovieTimeScale="+str(n)+chr(13)+"wristwatch time =
"+str(i/n)+" sec."
end
end
_______________________________________________
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>