Nope, still doesn't work :-)
This is the code I have:
import quicktime.io.*;
import quicktime.*;
import quicktime.std.*;
import quicktime.std.movies.*;
import quicktime.std.movies.media.*;
import java.util.*;
public class FrameCountTest
{
public static void main(String[] args)
{
try
{
if (args.length!=1)
System.out.println("Usage: java
FrameCountTest <moviefile>");
new java.awt.Frame();
QTSession.open();
QTFile qtf = new QTFile(args[0]);
OpenMovieFile openFile = OpenMovieFile.asRead(qtf);
Movie movie = Movie.fromFile(openFile,
StdQTConstants.newMovieDontResolveDataRefs, null);
System.out.println("duration="+movie.getDuration()+"
timescale="+movie.getTimeScale());
movie.task(0);
int flags = StdQTConstants.nextTimeStep;
int[] modes = new
int[]{StdQTConstants.visualMediaCharacteristic};
TimeInfo info =
movie.getNextInterestingTime(flags, modes, 0, 1.0f);
System.out.println(info);
int numframes = 0;
while (info.time>=0)
{
++numframes;
info =
movie.getNextInterestingTime(flags, modes, info.time, 1.0f);
}
System.out.println("frames = "+numframes);
}
catch (Exception e)
{
e.printStackTrace();
}
System.exit(0);
}
}
Output is:
duration=894895 timescale=90000
quicktime.std.movies.TimeInfo[time=-1,duration=0]
frames = 0
For any MPEG-1 or MPEG-2 file. By contrast, applying it to a .mov or
.mp4 file gives the expected results, eg.
duration=243162 timescale=600
quicktime.std.movies.TimeInfo[time=40,duration=40]
frames = 6079
-Rolf
At 10:32 am -0800 8/2/05, Scott Kuechle wrote:
On Feb 8, 2005, at 7:42 AM, Rolf Howarth wrote:
I've seen this statement made here from time to time over the
years but does anyone know *for certain* that this works on MPEG
files? Have you actually tried it?
I'm using QuickTime for Java and have tried this repeatedly, using
every combination of flags and methods I can find, and using
getNextInterestingTime() on Movie, Track and Media. No matter what
I do, all I get is time -1, duration 0, or maybe a -50 paramErr.
Yes, I do set nextTimeStep, on its own and in combination with
other flags.
If anyone can provide a specific set of flags and the name of the
method they're using that they know will find the frame duration
or rate of MPEG-1 and MPEG-2 files then I'd be most grateful!
-Rolf
Try tasking the movie at least once using MoviesTask() beforehand
as there was an issue with this.
See <http://developer.apple.com/qa/qtmtb/qtmtb54.html>
At 12:11 pm -0800 3/2/05, email@hidden wrote:
>Russ --
The other very important detail in Roland's use of
GetMovieNextInterestingTime() is "nextTimeStep".
If you walk MPEG content by mediaSample (using nextTimeMediaSample) you
will see one sample -- one large sample for sure. The nextTimeStep flag
gives the mediahandler an opportunity to return subdivisions like
frames. MPEG and Flash require this. Other kinds of tracks are
compatible with nextTimeStep, too, so there's no need to special case
where you use this.
-- Chris
In addition to these comments, here's a couple of links to some
Q&A's related
to this discussion for anyone who's interested.
http://developer.apple.com/qa/qtmtb/qtmtb54.html
http://developer.apple.com/qa/qa2001/qa1262.html
regards,
edward
Hi,
I am using QT4J to deal with MPEG-1 files. As regularly pointed out
in this list, QT cannot see the audio and video separately but see
MPEG-1 files as a somewhat opaque muxed block, and so on. Having
that in mind:
I am trying to get to know the exact framerate of any (MPEG1) opened
file, fortunately, there is a KB article:
http://developer.apple.com/qa/qa2001/qa1262.html
Translating the code to QT4J I am getting straightforward stuff:
track =
movie.getIndTrackType(1,StdQTConstants.visualMediaCharacteristic,StdQTConstants.movieTrackCharacteristic);
videoMedia = track.getMedia();
mpegMedia = (MPEGMedia) videoMedia; //exception if not MPEG, no problem
MPEGMediaHandler mediaHandler = null;
if (mpegMedia!=null) mediaHandler = (MPEGMediaHandler)mpegMedia.getHandler();
movie.task(0); //as stated in article
QTPointer encodedFrameRate =
mediaHandler.getPublicInfo(StdQTConstants5.kMHInfoEncodedFrameRate);
byte[] frameRate = encodedFrameRate.getBytes();
System.out.println(frameRate);
Only thing different from the article is that the 'characteristic'
used to get the track type is 'kCharacteristicHasVideoFrameRate'
which I can't find anywhere... However, as MPEG-1 files have only
one 'track', there does not seem to be any problem with using
'visualMediaCharacteristic'.
Code runs, but onle a single '0' byte is returned as the frame rate.
Should I file a bug report? (Gotta keep them going folks)
Thanks in advance.
Dani