Saturday, September 8, 2012

Building MPlayer and Mencoder for Windows

MPlayer logo

MPlayer is one of my favorite media players. It is used with a frontend like smplayer, gnome-mplayer and MPlayerGUI to provide a good alternative to Windows Media Player. Although there are already several Win32 builds of MPlayer on the net, I like to build MPlayer on my own using MinGW compiler because I want to optimize my build for my CPU. So I installed MinGW and compiled MPlayer as follows.

  1. Build ffmpeg statically or dynamically as shown in this post.

  2. (Optional) Compile the lzo library:
    ./configure --prefix=/mingw && make && make install
  3. (Optional) Fribidi is a rendering library for right-to-left scripts, such as Arabic and Hebrew. If you are a speaker of such right-to-left languages, compile fribidi statically as shown below:

    ./configure --prefix=/mingw --disable-shared --disable-debug
    make
    make install

    More information can be found here.

  4. Download JPEG source from ijg.org and complie JPEG:
    ./configure --prefix=/mingw --enable-static
    make
    make install
  5. Compile libPNG:
    ./configure --prefix=/mingw --disable-shared
    make
    make install
  6. Compile libiconv, Freetype, expat and fontconfig statically in that order:
    ./configure --prefix=/mingw --disable-shared
    make install
  7. Compile libdca:
    ./configure --prefix=/mingw
    make
    make install
  8. (Optional) Download DirectX headers from any of the following locations and unpack them in /mingw/include:
  9. Download the latest mplayer source (mplayer-export-snapshot.tar.bz2) and unpack it. (patch 1 and patch 2)
    tar xjvf mplayer-export-snapshot.tar.bz2
    cd mplayer-export-2010-02-07/

    Then, run ./configure:

    CPPFLAGS='-DFRIBIDI_ENTRY="" ' ./configure --prefix=/mingw --enable-runtime-cpudetection --enable-static --enable-theora --enable-fribidi --disable-ffmpeg_a --disable-gl --disable-vidix --yasm=/mingw/bin/yasm --extra-libs='-lfribidi'

    The CPPFLAGS value allows fribidi to be linked statically.

  10. Build Mplayer:
    make

    After successful build, strip the executables:

    strip m*.exe

    Optionally, compress the executables with upx:

    upx --best --strip-relocs=0 mplayer.exe
    upx --best --strip-relocs=0 mencoder.exe
  11. Download MPlayer codecs from here. The MPlayer codecs for Windows platform has a filename like windows-essential-20071007.zip. Extract the codecs package and you'll get a folder "windows-essential-20071007". Rename it as "codecs" and move the "codecs" folder inside where mplayer.exe file is located.

  12. Make sure that HOME environment variable is set to your personal folder(for example, C:\Users\Jocelyn). Upon the first run of mplayer, a new folder named mplayer will be created in your HOME folder. Copy codecs.conf to the mplayer folder. The "config" file stores default options for playing movie files. Open the "config" file and make changes as follows:

    # Write your default config options here!
    cdrom-device=D:
    dvd-device=D:
    ao=dsound
    vo=direct3d
    font=C:\WINDOWS\FONTS\MALGUN.TTF
    framedrop=yes
    subcp=cp949

My win32 build of mplayer can be downloaded from here. It is recommended that the zip archive should be extracted in C:\Program Files.

Running MPlayer

Now, let's try mplayer. First, get a movie file ready. In the Command Prompt, type a command in the following form:

mplayer mymoviefile.avi

Alternatively,

mplayer -vo direct3d -ao win32 -font C:\WINDOWS\FONTS\Tahoma.ttf -framedrop mymoviefile.avi

A new window will pop up with the movie playing inside it.

The next step is to get and set up SMPlayer.

About This Blog

KBlog logo This blog seeks to provide useful information to people, based on the author's knowledge and experience. Thanks for visiting the blog and posting your comments.

© Contents by KBlog

© Blogger template by Emporium Digital 2008

Follow by Email

Total Pageviews