Mac OSX: compile mplayer redux

In this post I will explain how I am compiling mplayer on Mac OSX Leopard using the Uoti’s mplayer fork build script. The script automates all the build process of ffmpeg, mplayer and libass. It is better than my previous method because it includes automatically the most recent version of libass (the one coming with mplayer is ancient).


First you need to install a couple of dependencies, you could compile them manually but it is not worth the hassle. Use MacPorts instead.

sudo port install git-core autoconf automake libtool pkgconfig freetype fontconfig libiconv ncurses zlib lzo2 libpng

Now make sure your MacPorts bin directory is at the start of your PATH, this will override the automake and autoconf shipping with Leopard. Your last .bash_profile line should look something like this:

export PATH=/opt/local/bin:/opt/local/sbin:${PATH}

Download the build scripts:

git clone git://repo.or.cz/mplayer-build.git

To launch the build script you do not use the usual ./configure && make && make install, read the README for more information on how the scripts work.

Download the source code for ffmpeg, libass and mplayer, and enable multithreading in ffmpeg:

cd mplayer-build
./init
./enable-mt

Now you need to edit some configuration file or the compilation will fail. First you need to add

--cc=gcc-4.2

to the common_options file (this should be optional on Snow Leopard since it comes with gcc4.2 as default compiler).

Second add

--disable-x11
--disable-gl
--disable-mencoder

to the mplayer_options file.

Third add

--enable-encoder=png

to ffmpeg_options file if you want to take screenshots with the MplayerOSX Extended GUI.

Fourth you need to remove ‘–cpu=native’, from script/ffmpeg-config and if you are on a core2 or core2duo add ‘–cpu=core2’,.

Now you are ready to compile everything, just run:

export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig"
make

The build script will take care of compiling ffmpeg, libass, mplayer and then linking them together.
After you are done you should find your mplayer executable in the mplayer subdirectory.

To use your newly compiled mplayer with the MPlayerOSX Extended GUI:

cd mplayer
sudo cp mplayer /Applications/MPlayer\ OSX\ Extended.app/Contents/Resources/External_Binaries/mplayer.app/Contents/MacOS/mplayer

That’s all folks! enjoy.

Advertisements

16 Comments »

  1. […] with 2 comments NOTE: This guide is outdated, for the current reccomended way to build mplayer please check my other post here. […]

  2. Adriasil said

    Is it possible to do this after doing the previous outdated one?

    • pigoz said

      Yes it is possible. If you have Snow Leopard follow the related article or download the binaries :)

      • Adriasil said

        I just have regular leopard: do I just follow this one?

      • pigoz said

        yes follow this one. mplayer in 64bit though is a LOT faster :p

  3. Adriasil said

    sorry I saw this post afterwards…

  4. Adriasil said

    I am getting command not found for:

    –cc=gcc-4.2

    • pigoz said

      Have you installed XCode?

      • Adriasil said

        Yeah, I have… I’m just supposed to be using terminal for this, right?

      • pigoz said

        no, you need to add that string to the common_options file in your mplayer-build directory.

      • Adriasil said

        How do I do that?

        (sorry I’m completely new to this.)

      • pigoz said

        Just open the file with TexEdit, TextMate, vim, emacs or any other text editor.

      • Adriasil said

        Open mplayer with text edit?

        then what?

      • pigoz said

        Open “common_options” with the text editor, its written clearly in the article. Then you add the –cc=gcc-4.2

        Same for other configuration files.

  5. Adriasil said

    Oh, I see, sorry, Thanks a heap!

  6. rioroute said

    I am getting an error…..

    From what little coding experience I have, it looks like everything goes well until here;

    License: GPL version 2 or later
    Creating config.mak and config.h…
    config.h is unchanged
    make -C ffmpeg_build install
    install -d “/Users/brucewardlow/mplayer-build/build_libs/lib”
    install -m 644 libpostproc/libpostproc.a “/Users/brucewardlow/mplayer-build/build_libs/lib”
    ranlib “/Users/brucewardlow/mplayer-build/build_libs/lib/libpostproc.a”
    install -d “/Users/brucewardlow/mplayer-build/build_libs/lib”
    install -m 644 libavdevice/libavdevice.a “/Users/brucewardlow/mplayer-build/build_libs/lib”
    ranlib “/Users/brucewardlow/mplayer-build/build_libs/lib/libavdevice.a”
    install -d “/Users/brucewardlow/mplayer-build/build_libs/lib”
    install -m 644 libavformat/libavformat.a “/Users/brucewardlow/mplayer-build/build_libs/lib”
    ranlib “/Users/brucewardlow/mplayer-build/build_libs/lib/libavformat.a”
    gcc-4.2 -DHAVE_AV_CONFIG_H -I. -I”/Users/brucewardlow/mplayer-build/ffmpeg-mt” -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DPIC -march=core2 -std=c99 -fomit-frame-pointer -fPIC -Wdeclaration-after-statement -Wall -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wno-pointer-sign -Wcast-qual -Wwrite-strings -Wundef -O2 -fno-math-errno -fno-tree-vectorize -MD -MP -MF libavcodec/x86/dsputil_mmx.d -MT libavcodec/x86/dsputil_mmx.o -c -o libavcodec/x86/dsputil_mmx.o /Users/brucewardlow/mplayer-build/ffmpeg-mt/libavcodec/x86/dsputil_mmx.c
    /Users/brucewardlow/mplayer-build/ffmpeg-mt/libavcodec/x86/h264dsp_mmx.c: In function ‘put_h264_qpel4_h_lowpass_3dnow’:
    /Users/brucewardlow/mplayer-build/ffmpeg-mt/libavcodec/x86/h264dsp_mmx.c:2058: error: can’t find a register in class ‘GENERAL_REGS’ while reloading ‘asm’
    /Users/brucewardlow/mplayer-build/ffmpeg-mt/libavcodec/x86/h264dsp_mmx.c:2058: error: ‘asm’ operand has impossible constraints
    make[1]: *** [libavcodec/x86/dsputil_mmx.o] Error 1
    make: *** [ffmpeg] Error 2

RSS feed for comments on this post · TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: