Media player performance on Mac

Robert Krüger krueger at
Thu Mar 5 10:06:02 UTC 2015

I am running 10.10.1 and the video is a standard h.264 export from FCPX, so
nothing special. I have tried other plain h.264 videos (an iTunes trailer)
with the same result. Have you tried it on Mac?

Another thing that is strange is that files with mov-Extensions do not seem
to be allowed. I had to rename a file to mp4 for it to be accepted. That
feels a bit weird, if the underlying framework is really AVFoundation.

This is the code I used for testing:

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.FlowPane;
import javafx.stage.Stage;

import java.util.List;

 * Simple Media Player Example
public class MediaPlayerExample extends Application {

    public void start(Stage stage) throws Exception {
        FlowPane pane = new FlowPane();

        final List<String> args = getParameters().getRaw();

            throw new IllegalStateException("no file specified");

        final String file = args.get(0);

        final Media media = new Media(file);

        final MediaPlayer player = new MediaPlayer(media);

        MediaView mediaView = new MediaView(player);

            if(player.getStatus() == MediaPlayer.Status.PAUSED){
            } else if(player.getStatus() == MediaPlayer.Status.PLAYING){


        final Scene scene = new Scene(pane);

    public static void main(String[] args) {

On Wed, Mar 4, 2015 at 8:28 PM, David DeHaven <david.dehaven at>

> > I just put a MediaView with a MediaPlayer into a FlowPane and displayed
> it.
> > Playing a Full-HD H.264 file consumes between 40 and 60% of CPU. Playing
> > the same file in Quicktime consumes about 3-4% CPU. What is the reason
> for
> > the dramatic difference? Is the player subsystem not using hardware
> > acceleration for decoding h.264? Is it something else intrinsic to
> > MediaPlayer oder MediaView? I thought 8u40's media support was build on
> top
> > of the AVFoundation framework and thus could compete with native players.
> > Can I set a flag to force hardware acceleration? Is something being done
> > about this? I am a bit worried that an application built on top of this
> > would just eat up our users' battery like crazy.
> Can you link a sample of a movie that’s causing that much of a performance
> difference? There will always be a slight difference, but it should not be
> that much.
> Could also be helpful to know more details about the environment you’re
> running in. Keep in mind the new AVFoundation code is only supported on
> 10.8 and later due to the lack of certain required APIs in 10.7 and 10.6.
> -DrD-

Robert Krüger
Managing Partner
Lesspain GmbH & Co. KG

More information about the openjfx-dev mailing list