I'm starting from an apple demo app called AVMovieEditor. I'm trying to add a visual display of the playback speed. Without any modification from me AVMovieEditor responds to the J,K & L keys like a video editing application. J plays in reverse, J again plays faster in reverse, K is pause, L plays, L again plays faster, etc...

I've successfully created an observer however every time I check the AVplayer.rate it is either -1,0 or 1, despite playing faster than realtime. Indeed when L is pressed the rate goes from 0 to 1, but then L is pressed a second time and the playback speeds up the rate changes back from 1 to 0? The result is similar with J and reverse playback except the rate changes to -1 and then back to 0.

- (void)addPeriodicTimeObserver { // about 30 times pr second CMTime interval = CMTimeMake(33, 1000); // Queue on which to invoke the callback dispatch_queue_t mainQueue = dispatch_get_main_queue(); // Add time observer self.timeObserverToken = [self.movieViewController.playerView.player addPeriodicTimeObserverForInterval:interval queue:mainQueue usingBlock:^(CMTime time) { NSLog(@"%f %f", self.movieViewController.playerView.player.rate // only shows -1,0,1 despite playback faster then 100% [[self.movieViewController.playerView.player.currentItem.tracks[0] assetTrack] nominalFrameRate]); // Always shows 29.97 }]; }

After much searching I am stumped as to how I can find a useful playback rate?

I'd like to know the actual frame rate of playback, and then I will make an indicator in my GUI to inform the end user the current playback rate.

Edit: I've found another interesting bit of data, but it doesn't solve my problem...

self.movieViewController.playerView.player.currentItem.tracks[0].currentVideoFrameRate

When the above is observed upon starting playback it ramps up from 0 to 30ish, then when L is pressed a second time it ramps up to 60ish. This would solve my problem but for 2 details. First when L is pressed a third time video playback increases, but the currentVideoFrameRate still hangs around 60ish. Second problem is that currentVideoFrameRate only shows positive values. If J is pressed twice and AVPlayer.rate goes back to 0 from -1, there is no way of knowing the frames are traversing in reverse order!

One thing I have found no information on that I think might shed light on a solution is what entity is capturing the J,K & L keyboard events, and what response is being applied?

Edit2: Apple's quicktime player has the functionality I am looking for. It responds to J,K & L like AVMovieEditor but it displays 2x, 5x, 10x, 30x & 60x respectively for it's playback speed and displays them on the left for reverse playback. Is this something reserved for Apple only or can I have it too!?

Edit3: Based on an answer ( Thanks! ) I've started looking at another property AVplayerItem.timebase.rate However this is giving similarly incorrect results.

I can confirm that visually the players rate increases as expected with each press of the "L" key. I would expect that also the "Requested Rate" ( AVplayer.rate ) I was using previously would also increase since I see it visually represented in playback, but not in the reported "Requested Rate". ( it goes to 0 )

The "Playback Actually Occurring Rate" behaves similarly. Except that when I press a stop key, it still displays a rate of 1 presumably because the player was playing at the time of the request to stop. But also AVplayerItem.timebase.rate reports an "Playback Actually Occurring Rate" of 0 when the playback rate is greater than 1 or less than -1.

This is the code I am currently using to see the rate. It's triggered on an observer that watches for changes in the requested rate. Is there a problem with how I am looking at these?

NSLog(@"RequestedPlaybackRate:%f",myAVPlayer.rate); NSLog(@"OccuringPlaybackRate:%f",CMTimebaseGetRate(myAVPlayerItem.timebase));

I will clarify also that the "Requested Rate" is actually what I want, not the "Playback Actually Occurring Rate".

Edit4:

Created a github project for easy reproduction of this problem and submitted a bug report with Apple.

https://github.com/markjwill/AVPlayerRateBug