Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MPEG1 framerate



Sorry, no, as far as I know there is no way to get the frame rate of an MPEG movie from QTJava. My last message to quicktime-api on the subject is attached below. It's just plain broken, and has been for ever. Feel free to raise another bug report with Apple!

-Rolf

At 8:30 pm +0000 8/2/05, Rolf Howarth wrote:
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

At 7:30 pm +0200 8/7/05, Daniel Giribet wrote:
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

-- Rolf Howarth Square Box Systems Ltd Stratford-upon-Avon UK. http://www.squarebox.co.uk _______________________________________________ Do not post admin requests to the list. They will be ignored. QuickTime-java mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/quicktime-java/email@hidden

This email sent to email@hidden
References: 
 >Re: MPEG1 to AVI, no audio (Alex Shaykevich) (From: Daniel Giribet <email@hidden>)
 >MPEG1 framerate (From: Daniel Giribet <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.