"OF_ERROR: error in MediaGetStaticFrameRate, ofQtUtils"

I’m experiencing an odd failure in my OF app. I’m analyzing H.264 video files, and most can be processed just fine. However, a few won’t process, and I get the error I cited in the subject line of this topic:

OF_ERROR: error in MediaGetStaticFrameRate, ofQtUtils

I’m not sure if it’s fractional framerates (23.98, for example) or some other H.264 file setting. I’m compressing the videos with the same preset out of Rhozet Carbon Coder. I’m a bit stumped. Any help would be greatly appreciated.

can you post an example and a very short (not heavy) movie that demo’s the behavior you are seeing. my head isn’t really in the quicktime code, but I remember that it came from here (as I remember):


take care,

Thanks for reading my post, Zach. I know your time is valuable and precious, so I’ll try to be as succinct as possible. Here’s a sample file that’s causing the error I mentioned:


(~ 30MB)

I’ll post some sample code in a later reply to this thread, but essentially I load the source file via args passed to the command line invocation of the OF app, and I use OFVideoPlayer.nextFrame() to step through the video frame by frame, analyzing the frames with some OpenCV routines.


Ok, I think I’ve narrowed down the issue, and I’ve managed to get an app that compiles and reads H.264 files. My thinking is that the ofVideoPlayer::loadMovie() method needs a modification for files like H.264, where GetMovieNextInterestingTime() returns only two interesting times when there should be many more than that. So, I added this mod to loadMovie():

AFTER this code:

while( curMovieTime >= 0 ) {  
	flags = nextTimeMediaSample;  
nFrames--; // there's an extra time step at the end of themovie  

I added this code:

if(nFrames == 2){  
		Media movieMedia;  
		MediaHandler movieMediaHandler;  
		MovieGetVideoMediaAndMediaHandler(moviePtr, &movieMedia, &movieMediaHandler);  
		nFrames = GetMediaSampleCount(movieMedia);  

Also, in MediaGetStaticFrameRate() method of ofQtUtil.cpp, I uncommented the QuickTime 7 line of code, and commented out the GetMediaDuration() line of code:

//Quicktime 7.0 code  
TimeValue64 duration = GetMediaDisplayDuration(inMovieMedia);  
//TimeValue64 duration = GetMediaDuration(inMovieMedia);  

Now, my OF app at least gets the right number of frames in the loaded H.264 movie, and nextFrame() works without throwing the error I mentioned at the beginning of this thread. However, going from frame to frame seems to be much slower now. Any thoughts? Should I look at some other classes and/or methods related to ofVideoPlayer.nextFrame()?

Many thanks in advance.

Ok, a quick update. I thought the app was reading to the end of the H.264 file, but it appears to always stop short of the end, and not by just a few frames. But, I’m going by ofVideoPlayer.getTotalNumFrames(), which I’ve indirectly modified by altering the value of nFrames with my previous post info, and ofVideoPlayer.getCurrentFrame().

I’m trying to also determine how this error suddenly appeared–I had been running a compiled version of this OF app for a month or so without this QT error surfacing. I thought at first that perhaps an update to the encoding software I’m using (Rhozet Carbon Coder) may have been the culprit, outputting different H.264 headers or something of that ilk. But, I also installed an update to QuickTime on the Mac server running the OF app, and I think that probably has something more to do with why GetMovieNextInterestingTime() is suddenly failing. Hard to say.

Hey Zach, Did you guys ever figure out what was going on with this?

I’m having the exact same problem. In my OF code, I can successfully call myMovie.setFrame(), .previous(), .next() on some H.264 movies, but on others I get the “error in MediaGetStaticFrameRate” as described above. In the Quicktime player, all the info on the movies - size, framerate, colordepth etc. (everything listed) - is exactly the same.

In the MediaGetStaticFrameRate function in the ofQtUtils - which all the above call - when I get the error, it seems to run past the GetMediaSampleCount(inMovieMedia) call, but throws the error after that. So, presumably the GetMediaDuration() call is the problem??

Here’s how I checked:

long sampleCount = GetMediaSampleCount(inMovieMedia);  
  OSErr err = GetMoviesError();  
  if (sampleCount && err == noErr)  
      /* find the media duration */  
	  printf("no error at GetMediaSampleCount"); //This prints before error message  
    //Quicktime 7.0 code  
    //TimeValue64 duration = GetMediaDisplayDuration(inMovieMedia);   
    TimeValue64 duration = GetMediaDuration(inMovieMedia); //next printf doesn't print, so error must be here  
    err = GetMoviesError();  
    if (err == noErr)  
		printf("no error at GetMediaDuration");  
        /* get the media time scale */  
      TimeValue64 timeScale = GetMediaTimeScale(inMovieMedia);  
      err = GetMoviesError();  
      if (err == noErr)  
		  printf("no error at GetMediaTimeScale");  
        /* calculate the frame rate:  
          frame rate = (sample count * media time scale) / media duration  
        *outFPS = (double)sampleCount * (double)timeScale / (double)duration;  

Any thoughts?

ofMovie.setPosition() still works (since it doesn’t call MedieGetStaticFrameRate), so I’ll use that as a work around, but I’d be curious to know if anyone figured out what’s going on . . .