Compiling PS3 Media Server on OSX

For help and support with issues specific to Mac OS X
Forum rules
Please make sure you follow the Problem Reporting Guidelines before posting if you want a reply.

Re: Compiling PS3 Media Server on OSX

Postby Wolf » Sun May 01, 2011 12:37 pm

Really looking forward to it! :)
Wolf
 
Posts: 35
Joined: Fri Mar 05, 2010 10:06 pm

Re: Compiling PS3 Media Server on OSX

Postby Redlum » Sun May 01, 2011 7:25 pm

The last one I posted had some problems, fixed those and the remaining issues in this version. It should be fully functional now with everything that's required by PS3 Media Server.

I'm going to add it to the repository and use it for the next official OS X build. All credits to Raptor339 for doing the hard part :).

- Added mencoder_mt
- Fixed x264, theora and vorbis
- Updated mplayer revision, had some issues with the previous one
- Added more libs to ffmpeg and mplayer since we have them anyway
- Added thread option (will considerably speedup the compile time on multicore systems)
- Several small fixes and general cleanup

Code: Select all
#!/bin/sh
#
# build-pms-osx.sh
#
# Version: 1.6
# Last updated: 2011-05-01
# Author: Patrick Atoon
#
#
# DESCRIPTION
#
# Building a statically linked PS3 Media Server for OSX is not an easy
# task and requires advanced knowledge of building the libraries and
# tools involved.
#
# This script will take care of building all that is required to build
# a statically linked PS3 Media Server for OSX.
# It will attempt to build universal binaries (for Intel and PCC)  where
# possible. However, some libraries do not support this and the script
# will compile for the current architecture.
#
# The script will compile the PS3 Media Server disk image file:
#
#    pms-macosx-x.xx.x.dmg
#
# This script is provided as is. If it works for you, good! If it does
# not, try to figure out why and share your findings on the PS3 Media
# Server forums (http://www.ps3mediaserver.org/forum/)
#
#
# REQUIREMENTS
#
# Some Developer tools need to be installed manually. The script detects
# this and provides help. Other sources will be downloaded automatically.
#
#
# ACKNOWLEDGEMENTS
#
# Many thanks to the PS3 Media Server developers and forum moderators
# for keeping the project alive and the info coming. Special thanks to
# Adrian Stutz for sharing his findings of how to build a statically
# linked MPlayerOSX (http://www.mplayerosx.ch/), without his hard work
# this script would not have been possible. Also thanks to Redlum for
# his assistance in getting this script production ready.
#
#
# TODO
#
# - Clean up dependencies that are not needed for PMS
# - Add PPC and universal build (with lipo)
#
#
# COPYRIGHT
#
# This script is distributed under the Creative Commons Attribution 3.0
# (CC BY) license. This means you are free to copy, distribute, transmit
# and adapt it to suit your needs, as long as you mention the original
# author in your work.
# For more details, see http://creativecommons.org/licenses/by/3.0/
#
#
# CONFIGURATION
#
# Set FIXED_REVISIONS to "no" to check out the latest revisions.
# Default is "yes" to check out the last known working revision.
FIXED_REVISIONS="yes"
#
# Set TARGET_ARCHITECTURE for building binaries. Choose one of the
# following:
#    native: build for your own computer
#    i386: build for Intel 386
#    ppc: build for PowerPC
#    universal: build for both Intel 386 and PowerPC (not functional yet)
#
TARGET_ARCHITECTURE="i386"
#
# Set the amount of threads that are used for compiling everything. This
# should generally be the same as the amount of CPU cores in your computer
# (look for Total Number Of Cores in System Profiler if you don't know it).
THREADS="2"


##########################################
# It should not be necessary to change anything below this line


# Binaries
ANT=/usr/bin/ant
CURL=/usr/bin/curl
GCC=/usr/bin/gcc
GIT=/usr/local/git/bin/git
HDID=/usr/bin/hdid
HDIUTIL=/usr/bin/hdiutil
MAKE=/usr/bin/make
SED=/usr/bin/sed
SVN=/usr/bin/svn
TAR=/usr/bin/tar
YASM=/usr/local/bin/yasm
UNZIP=/usr/bin/unzip

##########################################
# Create a directory when it does not exist
#
createdir() {
    if [ ! -d $1 ]; then
        mkdir $1
    fi
}


##########################################
# Check for gcc, make, svn, ant and curl
#
check_xcode() {
    if [ ! -x $GCC -o ! -x $SVN -o ! -x $ANT -o ! -x $CURL -o ! -x $MAKE ]; then
        cat << EOM
It seems you are missing Xcode from Apple, which is required to run this script.

Please go to http://developer.apple.com/technologies/xcode.html, create a free
Apple developer account and download Xcode and install it.
EOM
        exit;
    fi
}


##########################################
# Check for yasm
#
check_yasm() {
    if [ ! -x $YASM ]; then
        cat << EOM
It seems you are missing "yasm", which is required to run this script.
Please run the following commands to install "yasm":

    $SVN checkout http://www.tortall.net/svn/yasm/trunk/yasm yasm
    cd yasm
    ./autogen.sh
    ./configure
    make
    sudo make install
    cd $WORKDIR

EOM
        exit;
    fi
}


##########################################
# Check for git
#
check_git() {
    if [ ! -x $GIT ]; then
        cat << EOM
It seems you are missing "git", which is required to run this script.
Please go to http://code.google.com/p/git-osx-installer/, download git
and install it.
EOM
        exit;
    fi
}


##########################################
# Check for jarbundler
#
check_jarbundler() {
    # See if the jar file exists
    ls /usr/share/ant/lib/jarbundler-*.jar > /dev/null 2>&1

    if [ "$?" == "1" ]; then
        cat << EOM
It seems you are missing "jarbundler", which is required to run this script.
Please go to http://www.informagen.com/JarBundler/ , download the jarbundler
and install it.
EOM
        exit;
    fi
}


##########################################
# Set the compiler flags to determine the architecture to compile for
# Optional parameter: architecture flags string to replace the default,
# e.g. "-arch ppc -faltivec -mcpu=7450"
#
set_flags() {
    # Minimum OS version as target
    export MACOSX_DEPLOYMENT_TARGET=10.5
    export CFLAGS="-mmacosx-version-min=10.5 -isystem /Developer/SDKs/MacOSX10.5.sdk"
    export LDFLAGS="-mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk"
    export CXXFLAGS="-mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk"

    if [ "$1" != "" ]; then
        # Use the supplied parameter string for architecture flags
        export CFLAGS="$CFLAGS $1"
        export LDFLAGS="$LDFLAGS $1"
        export CXXFLAGS="$CXXFLAGS $1"
    else
        # Uncomment for single architecture binary
        export CFLAGS="$CFLAGS -arch $ARCHITECTURE"
        export LDFLAGS="$LDFLAGS -arch $ARCHITECTURE"
        export CXXFLAGS="$CXXFLAGS -arch $ARCHITECTURE"

        # For universal binaries, choose both i386 and PPC as target
        # export CFLAGS="$CFLAGS -arch i386 -arch ppc"
        # export LDFLAGS="$LDFLAGS -arch i386 -arch ppc"
        # export CXXFLAGS="$CXXFLAGS -arch i386 -arch ppc"
       
        # For PCC
        # export CFLAGS="$CFLAGS -arch ppc -faltivec -mcpu=7450"
        # export LDFLAGS="$LDFLAGS -arch ppc"
        # export CXXFLAGS="$CXXFLAGS -arch ppc -faltivec -mcpu=7450"
    fi

    # Paths of the build environment
    export LDFLAGS="$LDFLAGS -L$TARGET/lib -Wl,-search_paths_first"
    export CFLAGS="$CFLAGS -I$TARGET/include"
    export CXXFLAGS="$CXXFLAGS -I$TARGET/include"
}


##########################################
# Initialize building environment
#
initialize() {
    WORKDIR=`pwd`

    # Directories for statically compiled libraries
    TARGET="$WORKDIR/target"
    SRC="$WORKDIR/src"
    createdir "$SRC"
    createdir "$TARGET"

    if [ "$TARGET_ARCHITECTURE" == "native" ]; then
        ARCHITECTURE=`/usr/bin/uname -p`
    elif [ "$TARGET_ARCHITECTURE" == "universal" ]; then
        # FIXME: Hmmm...
        ARCHITECTURE=`/usr/bin/uname -p`
    else
        ARCHITECTURE=$TARGET_ARCHITECTURE
    fi

    # Set default compiler flags
    set_flags

    # Reset paths for compiling
    export PATH="$TARGET/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
    export PKG_CONFIG_PATH=""
}


##########################################
# DCRAW
# http://www.cybercom.net/~dcoffin/dcraw/
#
build_dcraw() {
    cd $SRC

    if [ ! -d dcraw-9.07 ]; then
        $CURL -L http://www.cybercom.net/~dcoffin/dcraw/archive/dcraw-9.07.tar.gz > dcraw-9.07.tar.gz
        $TAR xzf dcraw-9.07.tar.gz -s /dcraw/dcraw-9.07/
    fi

    cd dcraw-9.07
    set_flags
    $GCC -O4 -o dcraw dcraw.c -lm -ljpeg -DNO_LCMS $CFLAGS -L$TARGET/lib
    createdir $TARGET/bin
    cp dcraw $TARGET/bin
    cd $WORKDIR
}


##########################################
# EXPAT
# http://expat.sourceforge.net/
#
build_expat() {
    cd $SRC

    if [ ! -d expat-2.0.1 ]; then
        $CURL -L http://garr.dl.sourceforge.net/project/expat/expat/2.0.1/expat-2.0.1.tar.gz > expat-2.0.1.tar.gz
        $TAR xzf expat-2.0.1.tar.gz
    fi

    cd expat-2.0.1
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    $MAKE install
    cd $WORKDIR
}


##########################################
# FAAD2
# http://www.audiocoding.com/faad2.html
#
build_faad2() {
    cd $SRC

    if [ ! -d faad2-2.7 ]; then
        $CURL -L http://mesh.dl.sourceforge.net/project/faac/faad2-src/faad2-2.7/faad2-2.7.tar.gz > faad2-2.7.tar.gz
        $TAR xzf faad2-2.7.tar.gz
    fi

    cd faad2-2.7
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    $MAKE install
    cd $WORKDIR
}


##########################################
# FLAC
# http://flac.sourceforge.net/
#
build_flac() {
    cd $SRC

    if [ ! -d flac-1.2.1 ]; then
        $CURL -L http://downloads.xiph.org/releases/flac/flac-1.2.1.tar.gz > flac-1.2.1.tar.gz
        $TAR xzf flac-1.2.1.tar.gz
    fi

    cd flac-1.2.1
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --disable-asm-optimizations --prefix=$TARGET
    $MAKE -j$THREADS
    $MAKE install
    cd $WORKDIR
}


##########################################
# FONTCONFIG
# http://fontconfig.org/wiki/
#
build_fontconfig() {
    cd $SRC

    if [ ! -d fontconfig-2.8.0 ]; then
        $CURL -L http://www.freedesktop.org/software/fontconfig/release/fontconfig-2.8.0.tar.gz > fontconfig-2.8.0.tar.gz
        $TAR xzf fontconfig-2.8.0.tar.gz
    fi

    cd fontconfig-2.8.0
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    $MAKE install
    cd $WORKDIR
}


##########################################
# FREETYPE
# http://www.freetype.org/
#
build_freetype() {
    cd $SRC

    if [ ! -d freetype-2.4.4 ]; then
        $CURL -L http://download.savannah.gnu.org/releases/freetype/freetype-2.4.4.tar.gz > freetype-2.4.4.tar.gz
        $TAR xzf freetype-2.4.4.tar.gz
    fi

    cd freetype-2.4.4
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    $MAKE install
    cd $WORKDIR
}


##########################################
# FRIBIDI
# http://fribidi.org/
#
build_fribidi() {
    cd $SRC

    if [ ! -d fribidi-0.19.2 ]; then
        $CURL -L http://fribidi.org/download/fribidi-0.19.2.tar.gz > fribidi-0.19.2.tar.gz
        $TAR xzf fribidi-0.19.2.tar.gz
    fi

    cd fribidi-0.19.2
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET

    $MAKE -j$THREADS
    $MAKE install
    cd $WORKDIR
}


##########################################
# GIFLIB
# http://sourceforge.net/projects/giflib/
#
build_giflib() {
    cd $SRC

    if [ ! -d giflib-4.1.6 ]; then
        $CURL -L http://leaseweb.dl.sourceforge.net/project/giflib/giflib%204.x/giflib-4.1.6/giflib-4.1.6.tar.bz2 > giflib-4.1.6.tar.bz2
        $TAR xjf giflib-4.1.6.tar.bz2
    fi

    cd giflib-4.1.6
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    $MAKE install
    cd $WORKDIR
}


##########################################
# ICONV
# http://www.gnu.org/software/libiconv/
#
build_iconv() {
    cd $SRC

    if [ ! -d libiconv-1.13.1 ]; then
        $CURL -L http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz > libiconv-1.13.1.tar.gz
        $TAR xzf libiconv-1.13.1.tar.gz
    fi

    cd libiconv-1.13.1
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    $MAKE install
    cd $WORKDIR
}


##########################################
# JPEG
# http://www.ijg.org/
#
build_jpeg() {
    cd $SRC

    if [ ! -d jpeg-8c ]; then
        $CURL -L http://www.ijg.org/files/jpegsrc.v8c.tar.gz > jpegsrc.v8c.tar.gz
        $TAR xzf jpegsrc.v8c.tar.gz
    fi

    cd jpeg-8c
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    $MAKE install
    cd $WORKDIR
}


##########################################
# LAME
# http://lame.sourceforge.net/
#
build_lame() {
    cd $SRC

    if [ ! -d lame-3.98.4 ]; then
        $CURL -L http://sourceforge.net/projects/lame/files/lame/3.98.4/lame-3.98.4.tar.gz/download > lame-3.98.4.tar.gz
        $TAR xzf lame-3.98.4.tar.gz
    fi

    cd lame-3.98.4
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET

    $MAKE -j$THREADS
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBDCA
# http://www.videolan.org/developers/libdca.html
#
build_libdca() {
    cd $SRC

    if [ ! -d libdca-0.0.5 ]; then
        $CURL -L http://download.videolan.org/pub/videolan/libdca/0.0.5/libdca-0.0.5.tar.bz2 > libdca-0.0.5.tar.bz2
        $TAR xjf libdca-0.0.5.tar.bz2
    fi

    cd libdca-0.0.5
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBDV
# http://libdv.sourceforge.net/
#
build_libdv() {
    cd $SRC

    if [ ! -d libdv-1.0.0 ]; then
        $CURL -L http://puzzle.dl.sourceforge.net/project/libdv/libdv/1.0.0/libdv-1.0.0.tar.gz > libdv-1.0.0.tar.gz
        $TAR xzf libdv-1.0.0.tar.gz
    fi

    cd libdv-1.0.0
    set_flags
    export LDFLAGS="$LDFLAGS -flat_namespace -undefined suppress"
    ./configure --disable-shared --disable-dependency-tracking --disable-xv --disable-gtk --disable-sdl --disable-asm --prefix=$TARGET
    $MAKE -j$THREADS
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBDVDCSS
# http://www.videolan.org/developers/libdvdcss.html
#
build_libdvdcss() {
    cd $SRC

    if [ ! -d libdvdcss-1.2.9 ]; then
        $CURL -L http://download.videolan.org/pub/libdvdcss/1.2.9/libdvdcss-1.2.9.tar.gz > libdvdcss-1.2.9.tar.gz
        $TAR xzf libdvdcss-1.2.9.tar.gz
    fi

    cd libdvdcss-1.2.9
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBDVDNAV
# svn://svn.mplayerhq.hu/dvdnav/trunk/libdvdnav/
#
build_libdvdnav() {
    cd $SRC

    if [ "$FIXED_REVISIONS" == "yes" ]; then
        REVISION="-r 1226"
    else
        REVISION=""
    fi

    if [ ! -d libdvdnav ]; then
        $SVN checkout $REVISION svn://svn.mplayerhq.hu/dvdnav/trunk/libdvdnav/ libdvdnav
        cd libdvdnav
    else
        cd libdvdnav
        $SVN update $REVISION
    fi

    set_flags
    ./autogen.sh --with-dvdread-config=$TARGET/bin/dvdread-config --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    $MAKE install
    cd $WORKDIR
}

##########################################
# LIBDVDREAD
# svn://svn.mplayerhq.hu/dvdnav/trunk/libdvdread/
#
build_libdvdread() {
    cd $SRC

    if [ "$FIXED_REVISIONS" == "yes" ]; then
        REVISION="-r 1226"
    else
        REVISION=""
    fi

    if [ ! -d libdvdread ]; then
        $SVN checkout $REVISION svn://svn.mplayerhq.hu/dvdnav/trunk/libdvdread/ libdvdread
        cd libdvdread
    else
        cd libdvdread
        $SVN update $REVISION
    fi

    set_flags
    ./autogen.sh --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBMAD
# http://www.underbit.com/products/mad/
#
build_libmad() {
    cd $SRC

    if [ ! -d libmad-0.15.1b ]; then
        $CURL -L ftp://ftp.mars.org/pub/mpeg/libmad-0.15.1b.tar.gz > libmad-0.15.1b.tar.gz
        $TAR xzf libmad-0.15.1b.tar.gz
    fi

    cd libmad-0.15.1b

    if [ "$ARCHITECTURE" == "i386" ]; then
        set_flags "-arch i386"
        ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    else
        set_flags "-arch ppc"
        ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    fi

    $MAKE -j$THREADS
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBMEDIAINFO
# http://sourceforge.net/projects/mediainfo/
#
build_libmediainfo() {
    cd $SRC

    if [ ! -d libmediainfo_0.7.44 ]; then
        $CURL -L http://freefr.dl.sourceforge.net/project/mediainfo/source/libmediainfo/0.7.44/libmediainfo_0.7.44.tar.bz2 > libmediainfo_0.7.44.tar.bz2
        $TAR xjf libmediainfo_0.7.44.tar.bz2 -s /MediaInfoLib/libmediainfo_0.7.44/
    fi

    cd libmediainfo_0.7.44
    cd Project/GNU/Library
    export CFLAGS=
    export LDFLAGS=
    export CXXFLAGS=

    # Note: libmediainfo requires libzen source to compile
    ./autogen
    ./configure --enable-arch-i386 --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBPNG
# http://www.libpng.org/pub/png/libpng.html
#
build_libpng() {
    cd $SRC

    if [ ! -d libpng-1.5.2 ]; then
        $CURL -L http://mesh.dl.sourceforge.net/project/libpng/libpng15/1.5.2/libpng-1.5.2.tar.gz > libpng-1.5.2.tar.gz
        $TAR xzf libpng-1.5.2.tar.gz
    fi

    cd libpng-1.5.2
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBOGG
# http://xiph.org/downloads/
#
build_libogg() {
    cd $SRC

    if [ ! -d libogg-1.2.2 ]; then
        $CURL -L http://downloads.xiph.org/releases/ogg/libogg-1.2.2.tar.gz > libogg-1.2.2.tar.gz
        $TAR xzf libogg-1.2.2.tar.gz
    fi

    cd libogg-1.2.2
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBVORBIS
# http://xiph.org/downloads/
#
build_libvorbis() {
    cd $SRC

    if [ ! -d libvorbis-1.3.2 ]; then
        $CURL -L http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.2.tar.gz > libvorbis-1.3.2.tar.gz
        $TAR xzf libvorbis-1.3.2.tar.gz
    fi

    cd libvorbis-1.3.2
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --with-ogg=$TARGET --prefix=$TARGET
    $MAKE -j$THREADS
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBTHEORA
# http://xiph.org/downloads/
#
build_libtheora() {
    cd $SRC

    if [ ! -d libtheora-1.1.1 ]; then
        $CURL -L http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.bz2 > libtheora-1.1.1.tar.bz2
        $TAR xjf libtheora-1.1.1.tar.bz2
    fi

    cd libtheora-1.1.1
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --with-ogg=$TARGET --with-vorbis=$TARGET --prefix=$TARGET
    $MAKE -j$THREADS
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBZEN
# http://sourceforge.net/projects/zenlib/
#
build_libzen() {
    cd $SRC

    if [ ! -d libzen_0.4.19 ]; then
        $CURL -L http://heanet.dl.sourceforge.net/project/zenlib/ZenLib%20-%20Sources/0.4.19/libzen_0.4.19.tar.bz2 > libzen_0.4.19.tar.bz2
        $TAR xjf libzen_0.4.19.tar.bz2 -s /ZenLib/libzen_0.4.19/

        # libmediainfo needs this
        ln -s libzen_0.4.19 ZenLib
    fi

    cd libzen_0.4.19
    cd Project/GNU/Library
    export CFLAGS=
    export LDFLAGS=
    export CXXFLAGS=
    ./autogen
    ./configure --enable-arch-i386 --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    $MAKE install
    cd $WORKDIR
}


##########################################
# LZO2
# http://www.oberhumer.com/opensource/lzo/
#
build_lzo2() {
    cd $SRC

    if [ ! -d lzo-2.04 ]; then
        $CURL -L http://www.oberhumer.com/opensource/lzo/download/lzo-2.04.tar.gz > lzo-2.04.tar.gz
        $TAR xzf lzo-2.04.tar.gz
    fi

    cd lzo-2.04

    if [ "$ARCHITECTURE" == "i386" ]; then
        set_flags "-arch i386"
        ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    else
        set_flags "-arch ppc"
        ./configure --disable-shared --disable-dependency-tracking --disable-asm --prefix=$TARGET
    fi

    $MAKE -j$THREADS
    $MAKE install
    cd $WORKDIR
}


##########################################
# NCURSES
# http://www.gnu.org/software/ncurses/
#
build_ncurses() {
    cd $SRC

    if [ ! -d ncurses-5.9 ]; then
        $CURL -L http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz > ncurses-5.9.tar.gz
        $TAR xzf ncurses-5.9.tar.gz
    fi

    cd ncurses-5.9
    set_flags
    ./configure --without-shared --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE libs
    $MAKE install.libs
    cd $WORKDIR
}


##########################################
# TSMUXER
# http://www.smlabs.net/en/products/tsmuxer/
# http://www.videohelp.com/tools/tsMuxeR
# Interesting Open Source followup project in development: https://github.com/kierank/libmpegts
#
build_tsMuxeR() {
    cd $SRC

    if [ ! -d tsMuxeR_1.10.6 ]; then
        $CURL -H "Referer: http://www.videohelp.com/tools/tsMuxeR" -L http://www.videohelp.com/download/tsMuxeR_1.10.6.dmg > tsMuxeR_1.10.6.dmg
        createdir tsMuxeR_1.10.6
    fi

    # Nothing to build. Just open the disk image, copy the binary and detach the disk image
    $HDID tsMuxeR_1.10.6.dmg
    cp -f /Volumes/tsMuxeR/tsMuxerGUI.app/Contents/MacOS/tsMuxeR tsMuxeR_1.10.6/tsMuxeR
    cp -f tsMuxeR_1.10.6/tsMuxeR $TARGET/bin
    $HDIUTIL detach /Volumes/tsMuxeR
    cd $WORKDIR
}


##########################################
# X264
# svn://svn.videolan.org/x264/trunk
#
build_x264() {
    cd $SRC

    if [ -d x264 ]; then
        cd x264
        $GIT pull
    else
        $GIT clone git://git.videolan.org/x264.git x264
        cd x264
    fi

    if [ "$FIXED_REVISIONS" == "yes" ]; then
        $GIT checkout "`$GIT rev-list master -n 1 --first-parent --before=2011-04-24`"
    fi

    set_flags
    ./configure --prefix=$TARGET --host=x86-apple-darwin10 --disable-asm
    $MAKE -j$THREADS
    $MAKE install
    cd $WORKDIR
}


##########################################
# XVID
# http://www.xvid.org/
#
build_xvid() {
    cd $SRC

    if [ ! -d xvidcore-1.3.1 ]; then
        $CURL -L http://downloads.xvid.org/downloads/xvidcore-1.3.1.tar.gz > xvidcore-1.3.1.tar.gz
        $TAR xzf xvidcore-1.3.1.tar.gz -s /xvidcore/xvidcore-1.3.1/
    fi

    cd xvidcore-1.3.1/build/generic
    set_flags
    ./configure --prefix=$TARGET
    $MAKE -j$THREADS
    $MAKE install

    cd $WORKDIR
}


##########################################
# ZLIB
# http://zlib.net/
#
build_zlib() {
    cd $SRC

    if [ ! -d zlib-1.2.5 ]; then
        $CURL -L http://zlib.net/zlib-1.2.5.tar.gz > zlib-1.2.5.tar.gz
        $TAR xzf zlib-1.2.5.tar.gz
    fi

    cd zlib-1.2.5
    set_flags
    ./configure --prefix=$TARGET
    $MAKE -j$THREADS
    $MAKE install
    cd $WORKDIR
}


##########################################
# FFMPEG
# http://www.ffmpeg.org/
#
build_ffmpeg() {
    cd $SRC
    if [ -d ffmpeg ]; then
        cd ffmpeg
        $GIT pull
    else
        $GIT clone git://git.videolan.org/ffmpeg.git ffmpeg
        cd ffmpeg
    fi

    if [ "$FIXED_REVISIONS" == "yes" ]; then
        $GIT checkout "`$GIT rev-list master -n 1 --first-parent --before=2011-04-24`"
    fi

    set_flags
    ./configure --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libxvid \
    --enable-libtheora --enable-libvorbis --disable-shared --prefix=$TARGET
    $MAKE -j$THREADS
    $MAKE install
    cd $WORKDIR
}



##########################################
# MPLAYER
# http://www.mplayerhq.hu/design7/news.html
#
build_mplayer() {
    cd $SRC

    if [ "$FIXED_REVISIONS" == "yes" ]; then
        REVISION="-r 33342"
    else
        REVISION=""
    fi

    if [ -d mplayer ]; then
        cd mplayer
        $SVN update $REVISION
    else
        $SVN checkout $REVISION svn://svn.mplayerhq.hu/mplayer/trunk mplayer
        cd mplayer
    fi

    # Copy ffmpeg source to avoid making another git clone by configure
    cp -rf $SRC/ffmpeg .

    set_flags

    # Extra flags for compiling mplayer
   export CFLAGS="-O4 -fomit-frame-pointer -pipe $CFLAGS"
   export CXXFLAGS="-O4 -fomit-frame-pointer -pipe $CXXFLAGS"

    # Theora/vorbis seems broken in this revision, disable it for now
    ./configure --disable-x11 --disable-gl --disable-qtx --disable-dvdread-internal \
    --disable-theora --disable-libvorbis \
    --with-freetype-config=$TARGET/bin/freetype-config --prefix=$TARGET

    # Somehow -I/usr/X11/include still made it into the config.mak, regardless of the --disable-x11
    $SED -i -e "s/-I\/usr\/X11\/include//g" config.mak

    # Remove the ffmpeg directory and copy the compiled ffmpeg again to avoid "make" rebuilding it
    rm -rf ffmpeg
    cp -rf $SRC/ffmpeg .

    $MAKE -j$THREADS
    $MAKE install

    cd $WORKDIR
}

##########################################
# MENCODER_MT (multi-threaded)
# http://www.mplayerhq.hu/design7/news.html
# http://gitorious.org/ffmpeg/ffmpeg-mt
#
build_mencoder_mt() {
    cd $SRC

    if [ "$FIXED_REVISIONS" == "yes" ]; then
        REVISION="-r 33342"
    else
        REVISION=""
    fi

    if [ -d mencoder_mt ]; then
        cd mencoder_mt
        $SVN update $REVISION
    else
        $SVN checkout $REVISION svn://svn.mplayerhq.hu/mplayer/trunk mencoder_mt
        cd mencoder_mt
    fi

    # Remove the bundled ffmpeg and replace it with ffmpeg-mt
    rm -rf ffmpeg
   $GIT clone git://gitorious.org/~astrange/ffmpeg/ffmpeg-mt.git ffmpeg

    set_flags

    # Extra flags for compiling mplayer
   export CFLAGS="-O4 -fomit-frame-pointer -pipe $CFLAGS"
   export CXXFLAGS="-O4 -fomit-frame-pointer -pipe $CXXFLAGS"

    # Theora/vorbis seems broken in this revision, disable it for now
    ./configure --disable-x11 --disable-gl --disable-qtx --disable-dvdread-internal \
    --disable-theora --disable-libvorbis \
    --with-freetype-config=$TARGET/bin/freetype-config --prefix=$TARGET

    # Somehow -I/usr/X11/include still made it into the config.mak, regardless of the --disable-x11
    $SED -i -e "s/-I\/usr\/X11\/include//g" config.mak

    $MAKE -j$THREADS
   cp mencoder $TARGET/bin/mencoder_mt

    cd $WORKDIR
}


##########################################
# PS3MEDIASERVER
# http://code.google.com/p/ps3mediaserver/
#
build_ps3mediaserver() {
    cd $SRC

    if [ "$FIXED_REVISIONS" == "yes" ]; then
        REVISION="-r 552"
    else
        REVISION=""
    fi

    if [ -d ps3mediaserver ]; then
        cd ps3mediaserver
        $SVN update $REVISION
    else
        $SVN checkout $REVISION http://ps3mediaserver.googlecode.com/svn/trunk/ps3mediaserver ps3mediaserver
        cd ps3mediaserver
    fi

    cd osx
   
    # Overwrite with the home built tools
    cp $TARGET/bin/dcraw .
    cp $TARGET/bin/ffmpeg .
    cp $TARGET/bin/flac .
    cp $TARGET/bin/mplayer .
    cp $TARGET/bin/mencoder .
   cp $TARGET/bin/mencoder_mt .
    cp $TARGET/bin/tsMuxeR .

    set_flags
    $ANT DMG
    cp pms-macosx-*.dmg $WORKDIR
    cd $WORKDIR
}


##########################################
# Finally, execute the script...
#

# Check requirements
check_xcode
check_yasm
check_git
check_jarbundler

# Initialize variables for compiling
initialize

# Build static libraries to link against
build_zlib
build_expat
build_faad2
build_fontconfig
build_freetype
build_fribidi
build_giflib
build_jpeg
build_iconv
build_ncurses
build_lame
build_libdca
build_libdv
build_libdvdcss
build_libdvdread
build_libdvdnav
build_libmad
build_libzen
# Note: libmediainfo requires libzen to build
build_libmediainfo
build_libpng
build_libogg
build_libvorbis
build_libtheora
build_lzo2
build_x264
build_xvid

# Build tools for including with PS3 Media Server
build_flac
build_dcraw
build_tsMuxeR
build_ffmpeg
build_mplayer
build_mencoder_mt

# Build PS3 Media Server itself
build_ps3mediaserver
Redlum
Project Member
 
Posts: 371
Joined: Mon Jan 12, 2009 9:13 pm

Re: Compiling PS3 Media Server on OSX

Postby Raptor399 » Sun May 01, 2011 11:40 pm

Excellent work, Redlum!
Takes 20 minutes to download and compile everything, but then you have a working PS3 Media Server! :-D
Thanks for fixing up the script!
Raptor399
Project Member
 
Posts: 1916
Joined: Thu Mar 10, 2011 12:06 am

Re: Compiling PS3 Media Server on OSX

Postby Tom Foolery » Mon May 02, 2011 2:37 am

Good Job for this. This is great work


I can't wait to get my hands on the new version
Tom Foolery
 
Posts: 13
Joined: Fri Apr 10, 2009 7:58 pm

Re: Compiling PS3 Media Server on OSX

Postby Raptor399 » Sun May 08, 2011 9:30 am

I was working to improve the script some more, when I discovered a bug: MPlayer was not compiling correct.
The result was that the regular binaries as currently shipped with PMS were used, not the compiled ones!
This can easily be verified; mencoder reports to be revision 29241, whereas the script ought to build revision 33342.

I fixed the compilation bug for MPlayer, but that only revealed a much bigger bug. :shock: Revision 33342 of mencoder makes videos play with horribly distorted sound! When viewing a regular Quicktime movie, the audio starts seconds later, sounds robotic and runs about 3x as slow as it should.

Using the old revision 29214 is impossible, it refuses to build. I have tried a couple of random revisions of MPlayer including the newest one, but either they don't build or they have the same distorted sound. :-(

Below is an improved version of the script.
Changes:

- Added visual cue to be able to follow the build process better
- When important things fail, the script now stops
- Fixed git pull for existing files
- Fixed version.sh for ffmpeg to give the real version instead of UNKNOWN
- Fixed MPlayer build error by also disabling theora and vorbis for ffmpeg.
- Building now fully works for architecture "x86_64".
- Dropped the TODO to build universal binaries, focussing instead on facilitating simple single architecture builds.
- The resulting .dmg file now contains the name of the architecture it was built for.

Known bugs:

- mencoder gives delayed and distorted sound
- PMS packs the shipped binary dcrawU, not the compiled dcraw

Code: Select all
#!/bin/sh
#
# build-pms-osx.sh
#
# Version: 1.7
# Last updated: 2011-05-08
# Author: Patrick Atoon
#
#
# DESCRIPTION
#
# Building a statically linked PS3 Media Server for OSX is not an easy
# task and requires advanced knowledge of building the libraries and
# tools involved.
#
# This script will take care of building all that is required to build
# a statically linked PS3 Media Server for a specific architecture on OSX.
#
# The script will compile the PS3 Media Server disk image file:
#
#    pms-macosx-xxxx-x.xx.x.dmg
#
# This script is provided as is. If it works for you, good! If it does
# not, try to figure out why and share your findings on the PS3 Media
# Server forums (http://www.ps3mediaserver.org/forum/).
#
#
# REQUIREMENTS
#
# Some Developer tools need to be installed manually. The script detects
# this and provides help. Other sources will be downloaded automatically.
#
#
# ACKNOWLEDGEMENTS
#
# Many thanks to the PS3 Media Server developers and forum moderators
# for keeping the project alive and the info coming. Special thanks to
# Adrian Stutz for sharing his findings of how to build a statically
# linked MPlayerOSX (http://www.mplayerosx.ch/), without his hard work
# this script would not have been possible. Also thanks to Redlum for
# his assistance in getting this script production ready.
#
#
# TODO
#
# - Clean up dependencies that are not needed for PMS
#
#
# KNOWN BUGS
#
# - mencoder gives delayed and distorted sound
# - The finale PMS .dmg contains the shipped binary dcrawU, not the compiled dcraw
#
#
# COPYRIGHT
#
# This script is distributed under the Creative Commons Attribution 3.0
# (CC BY) license. This means you are free to copy, distribute, transmit
# and adapt it to suit your needs, as long as you mention the original
# author in your work.
# For more details, see http://creativecommons.org/licenses/by/3.0/
#
#
# CONFIGURATION
#
# Set FIXED_REVISIONS to "no" to check out the latest revisions.
# Default is "yes" to check out the last known working revision.
FIXED_REVISIONS="yes"

# Set TARGET_ARCHITECTURE for building binaries. Choose one of the following:
#
#    native: build for your own computer
#    x86_64: build for 64 bits Intel x86
#    i386: build for Intel 386
#    ppc: build for PowerPC
#
TARGET_ARCHITECTURE="native"

# Set the amount of threads that are used for compiling everything. This
# should generally be the same as the amount of CPU cores in your computer
# (look for Total Number Of Cores in System Profiler if you don't know it).
THREADS="2"


##########################################
# It should not be necessary to change anything below this line


# Binaries
ANT=/usr/bin/ant
CURL=/usr/bin/curl
GCC=/usr/bin/gcc
GIT=/usr/local/git/bin/git
HDID=/usr/bin/hdid
HDIUTIL=/usr/bin/hdiutil
MAKE=/usr/bin/make
SED=/usr/bin/sed
SVN=/usr/bin/svn
TAR=/usr/bin/tar
YASM=/usr/local/bin/yasm
UNZIP=/usr/bin/unzip

##########################################
# Create a directory when it does not exist
#
createdir() {
    if [ ! -d $1 ]; then
        mkdir $1
    fi
}


##########################################
# Check for gcc, make, svn, ant and curl
#
check_xcode() {
    if [ ! -x $GCC -o ! -x $SVN -o ! -x $ANT -o ! -x $CURL -o ! -x $MAKE ]; then
        cat << EOM
It seems you are missing Xcode from Apple, which is required to run this script.

Please go to http://developer.apple.com/technologies/xcode.html, create a free
Apple developer account and download Xcode and install it.
EOM
        exit;
    fi
}


##########################################
# Check for yasm
#
check_yasm() {
    if [ ! -x $YASM ]; then
        cat << EOM
It seems you are missing "yasm", which is required to run this script.
Please run the following commands to install "yasm":

    $SVN checkout http://www.tortall.net/svn/yasm/trunk/yasm yasm
    cd yasm
    ./autogen.sh
    ./configure
    make
    sudo make install
    cd $WORKDIR

EOM
        exit;
    fi
}


##########################################
# Check for git
#
check_git() {
    if [ ! -x $GIT ]; then
        cat << EOM
It seems you are missing "git", which is required to run this script.
Please go to http://code.google.com/p/git-osx-installer/, download git
and install it.
EOM
        exit;
    fi
}


##########################################
# Check for jarbundler
#
check_jarbundler() {
    # See if the jar file exists
    ls /usr/share/ant/lib/jarbundler-*.jar > /dev/null 2>&1

    if [ "$?" == "1" ]; then
        cat << EOM
It seems you are missing "jarbundler", which is required to run this script.
Please go to http://www.informagen.com/JarBundler/ , download the jarbundler
and install it.
EOM
        exit;
    fi
}


##########################################
# Set the compiler flags to determine the architecture to compile for
# Optional parameter: architecture flags string to replace the default,
# e.g. "-arch ppc -faltivec -mcpu=7450"
#
set_flags() {
    # Minimum OS version as target
    export MACOSX_DEPLOYMENT_TARGET=10.5
    export CFLAGS="-mmacosx-version-min=10.5 -isystem /Developer/SDKs/MacOSX10.5.sdk"
    export LDFLAGS="-mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk"
    export CXXFLAGS="-mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk"

    if [ "$1" != "" ]; then
        # Use the supplied parameter string for architecture flags
        export CFLAGS="$CFLAGS $1"
        export LDFLAGS="$LDFLAGS $1"
        export CXXFLAGS="$CXXFLAGS $1"
    else
        # Uncomment for single architecture binary
        export CFLAGS="$CFLAGS -arch $ARCHITECTURE"
        export LDFLAGS="$LDFLAGS -arch $ARCHITECTURE"
        export CXXFLAGS="$CXXFLAGS -arch $ARCHITECTURE"
    fi

    # Paths of the build environment
    export LDFLAGS="$LDFLAGS -L$TARGET/lib -Wl,-search_paths_first"
    export CFLAGS="$CFLAGS -I$TARGET/include"
    export CXXFLAGS="$CXXFLAGS -I$TARGET/include"
}


##########################################
# Initialize building environment
#
initialize() {
    WORKDIR=`pwd`

    # Directories for statically compiled libraries
    TARGET="$WORKDIR/target"
    SRC="$WORKDIR/src"
    createdir "$SRC"
    createdir "$TARGET"

    if [ "$TARGET_ARCHITECTURE" == "native" ]; then
        ARCHITECTURE=`/usr/bin/uname -p`
    else
        ARCHITECTURE=$TARGET_ARCHITECTURE
    fi

    # Set default compiler flags
    set_flags

    # Reset paths for compiling
    export PATH="$TARGET/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
    export PKG_CONFIG_PATH=""
}


##########################################
# Exit if the previous command ended with an error status
#
exit_on_error() {
    if [ "$?" == "1" ]; then
        echo Fatal error occurred, aborting build.
        cd $WORKDIR
        exit
    fi
}


##########################################
# Building start marker to more easily follow the build process
#
start_build() {
    cat << EOM


--------------------------------------------------------------------------------------
Building $1
--------------------------------------------------------------------------------------

EOM
}



##########################################
# DCRAW
# http://www.cybercom.net/~dcoffin/dcraw/
#
build_dcraw() {
    start_build dcraw
    cd $SRC

    if [ ! -d dcraw-9.07 ]; then
        $CURL -L http://www.cybercom.net/~dcoffin/dcraw/archive/dcraw-9.07.tar.gz > dcraw-9.07.tar.gz
        exit_on_error
        $TAR xzf dcraw-9.07.tar.gz -s /dcraw/dcraw-9.07/
    fi

    cd dcraw-9.07
    set_flags
    $GCC -O4 -o dcraw dcraw.c -lm -ljpeg -DNO_LCMS $CFLAGS -L$TARGET/lib
    exit_on_error
    createdir $TARGET/bin
    cp dcraw $TARGET/bin
    cd $WORKDIR
}


##########################################
# EXPAT
# http://expat.sourceforge.net/
#
build_expat() {
    start_build expat
    cd $SRC

    if [ ! -d expat-2.0.1 ]; then
        $CURL -L http://garr.dl.sourceforge.net/project/expat/expat/2.0.1/expat-2.0.1.tar.gz > expat-2.0.1.tar.gz
        exit_on_error
        $TAR xzf expat-2.0.1.tar.gz
    fi

    cd expat-2.0.1
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# FAAD2
# http://www.audiocoding.com/faad2.html
#
build_faad2() {
    start_build faad2
    cd $SRC

    if [ ! -d faad2-2.7 ]; then
        $CURL -L http://mesh.dl.sourceforge.net/project/faac/faad2-src/faad2-2.7/faad2-2.7.tar.gz > faad2-2.7.tar.gz
        exit_on_error
        $TAR xzf faad2-2.7.tar.gz
    fi

    cd faad2-2.7
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# FLAC
# http://flac.sourceforge.net/
#
build_flac() {
    start_build flac
    cd $SRC

    if [ ! -d flac-1.2.1 ]; then
        $CURL -L http://downloads.xiph.org/releases/flac/flac-1.2.1.tar.gz > flac-1.2.1.tar.gz
        exit_on_error
        $TAR xzf flac-1.2.1.tar.gz
    fi

    cd flac-1.2.1
    set_flags

    if [ "$ARCHITECTURE" == "x86_64" ]; then
        ./configure --disable-shared --disable-dependency-tracking --host=x86-apple-darwin10 --prefix=$TARGET
    else
        ./configure --disable-shared --disable-dependency-tracking --disable-asm-optimizations --prefix=$TARGET
    fi

    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# FONTCONFIG
# http://fontconfig.org/wiki/
#
build_fontconfig() {
    start_build fontconfig
    cd $SRC

    if [ ! -d fontconfig-2.8.0 ]; then
        $CURL -L http://www.freedesktop.org/software/fontconfig/release/fontconfig-2.8.0.tar.gz > fontconfig-2.8.0.tar.gz
        exit_on_error
        $TAR xzf fontconfig-2.8.0.tar.gz
    fi

    cd fontconfig-2.8.0
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# FREETYPE
# http://www.freetype.org/
#
build_freetype() {
    start_build freetype
    cd $SRC

    if [ ! -d freetype-2.4.4 ]; then
        $CURL -L http://download.savannah.gnu.org/releases/freetype/freetype-2.4.4.tar.gz > freetype-2.4.4.tar.gz
        exit_on_error
        $TAR xzf freetype-2.4.4.tar.gz
    fi

    cd freetype-2.4.4
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# FRIBIDI
# http://fribidi.org/
#
build_fribidi() {
    start_build fribidi
    cd $SRC

    if [ ! -d fribidi-0.19.2 ]; then
        $CURL -L http://fribidi.org/download/fribidi-0.19.2.tar.gz > fribidi-0.19.2.tar.gz
        exit_on_error
        $TAR xzf fribidi-0.19.2.tar.gz
    fi

    cd fribidi-0.19.2
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# GIFLIB
# http://sourceforge.net/projects/giflib/
#
build_giflib() {
    start_build giflib
    cd $SRC

    if [ ! -d giflib-4.1.6 ]; then
        $CURL -L http://leaseweb.dl.sourceforge.net/project/giflib/giflib%204.x/giflib-4.1.6/giflib-4.1.6.tar.bz2 > giflib-4.1.6.tar.bz2
        exit_on_error
        $TAR xjf giflib-4.1.6.tar.bz2
    fi

    cd giflib-4.1.6
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# ICONV
# http://www.gnu.org/software/libiconv/
#
build_iconv() {
    start_build iconv
    cd $SRC

    if [ ! -d libiconv-1.13.1 ]; then
        $CURL -L http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz > libiconv-1.13.1.tar.gz
        exit_on_error
        $TAR xzf libiconv-1.13.1.tar.gz
    fi

    cd libiconv-1.13.1
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# JPEG
# http://www.ijg.org/
#
build_jpeg() {
    start_build jpeg
    cd $SRC

    if [ ! -d jpeg-8c ]; then
        $CURL -L http://www.ijg.org/files/jpegsrc.v8c.tar.gz > jpegsrc.v8c.tar.gz
        exit_on_error
        $TAR xzf jpegsrc.v8c.tar.gz
    fi

    cd jpeg-8c
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# LAME
# http://lame.sourceforge.net/
#
build_lame() {
    start_build lame
    cd $SRC

    if [ ! -d lame-3.98.4 ]; then
        $CURL -L http://sourceforge.net/projects/lame/files/lame/3.98.4/lame-3.98.4.tar.gz/download > lame-3.98.4.tar.gz
        exit_on_error
        $TAR xzf lame-3.98.4.tar.gz
    fi

    cd lame-3.98.4
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBDCA
# http://www.videolan.org/developers/libdca.html
#
build_libdca() {
    start_build libdca
    cd $SRC

    if [ ! -d libdca-0.0.5 ]; then
        $CURL -L http://download.videolan.org/pub/videolan/libdca/0.0.5/libdca-0.0.5.tar.bz2 > libdca-0.0.5.tar.bz2
        exit_on_error
        $TAR xjf libdca-0.0.5.tar.bz2
    fi

    cd libdca-0.0.5
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBDV
# http://libdv.sourceforge.net/
#
build_libdv() {
    start_build libdv
    cd $SRC

    if [ ! -d libdv-1.0.0 ]; then
        $CURL -L http://puzzle.dl.sourceforge.net/project/libdv/libdv/1.0.0/libdv-1.0.0.tar.gz > libdv-1.0.0.tar.gz
        exit_on_error
        $TAR xzf libdv-1.0.0.tar.gz
    fi

    cd libdv-1.0.0
    set_flags
    export LDFLAGS="$LDFLAGS -flat_namespace -undefined suppress"
    ./configure --disable-shared --disable-dependency-tracking --disable-xv \
        --disable-gtk --disable-sdl --disable-asm --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBDVDCSS
# http://www.videolan.org/developers/libdvdcss.html
#
build_libdvdcss() {
    start_build libdvdcss
    cd $SRC

    if [ ! -d libdvdcss-1.2.9 ]; then
        $CURL -L http://download.videolan.org/pub/libdvdcss/1.2.9/libdvdcss-1.2.9.tar.gz > libdvdcss-1.2.9.tar.gz
        exit_on_error
        $TAR xzf libdvdcss-1.2.9.tar.gz
    fi

    cd libdvdcss-1.2.9
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBDVDNAV
# svn://svn.mplayerhq.hu/dvdnav/trunk/libdvdnav/
#
build_libdvdnav() {
    start_build libdvdnav
    cd $SRC

    if [ "$FIXED_REVISIONS" == "yes" ]; then
        REVISION="-r 1226"
    else
        REVISION=""
    fi

    if [ ! -d libdvdnav ]; then
        $SVN checkout $REVISION svn://svn.mplayerhq.hu/dvdnav/trunk/libdvdnav/ libdvdnav
        exit_on_error
        cd libdvdnav
    else
        cd libdvdnav
        $SVN update $REVISION
        exit_on_error
    fi

    set_flags
    ./autogen.sh --with-dvdread-config=$TARGET/bin/dvdread-config --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}

##########################################
# LIBDVDREAD
# svn://svn.mplayerhq.hu/dvdnav/trunk/libdvdread/
#
build_libdvdread() {
    start_build libdvdread
    cd $SRC

    if [ "$FIXED_REVISIONS" == "yes" ]; then
        REVISION="-r 1226"
    else
        REVISION=""
    fi

    if [ ! -d libdvdread ]; then
        $SVN checkout $REVISION svn://svn.mplayerhq.hu/dvdnav/trunk/libdvdread/ libdvdread
        exit_on_error
        cd libdvdread
    else
        cd libdvdread
        $SVN update $REVISION
        exit_on_error
    fi

    set_flags
    ./autogen.sh --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBMAD
# http://www.underbit.com/products/mad/
#
build_libmad() {
    start_build libmad
    cd $SRC

    if [ ! -d libmad-0.15.1b ]; then
        $CURL -L ftp://ftp.mars.org/pub/mpeg/libmad-0.15.1b.tar.gz > libmad-0.15.1b.tar.gz
        exit_on_error
        $TAR xzf libmad-0.15.1b.tar.gz
    fi

    cd libmad-0.15.1b
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBMEDIAINFO
# http://sourceforge.net/projects/mediainfo/
#
build_libmediainfo() {
    start_build libmediainfo
    cd $SRC

    if [ ! -d libmediainfo_0.7.44 ]; then
        $CURL -L http://freefr.dl.sourceforge.net/project/mediainfo/source/libmediainfo/0.7.44/libmediainfo_0.7.44.tar.bz2 > libmediainfo_0.7.44.tar.bz2
        exit_on_error
        $TAR xjf libmediainfo_0.7.44.tar.bz2 -s /MediaInfoLib/libmediainfo_0.7.44/
    fi

    cd libmediainfo_0.7.44
    cd Project/GNU/Library
    export CFLAGS=
    export LDFLAGS=
    export CXXFLAGS=

    # Note: libmediainfo requires libzen source to compile
    ./autogen
    ./configure --enable-arch-i386 --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBPNG
# http://www.libpng.org/pub/png/libpng.html
#
build_libpng() {
    start_build libpng
    cd $SRC

    if [ ! -d libpng-1.5.2 ]; then
        $CURL -L http://mesh.dl.sourceforge.net/project/libpng/libpng15/1.5.2/libpng-1.5.2.tar.gz > libpng-1.5.2.tar.gz
        exit_on_error
        $TAR xzf libpng-1.5.2.tar.gz
    fi

    cd libpng-1.5.2
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBOGG
# http://xiph.org/downloads/
#
build_libogg() {
    start_build libogg
    cd $SRC

    if [ ! -d libogg-1.2.2 ]; then
        $CURL -L http://downloads.xiph.org/releases/ogg/libogg-1.2.2.tar.gz > libogg-1.2.2.tar.gz
        exit_on_error
        $TAR xzf libogg-1.2.2.tar.gz
    fi

    cd libogg-1.2.2
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBVORBIS
# http://xiph.org/downloads/
#
build_libvorbis() {
    start_build libvorbis
    cd $SRC

    if [ ! -d libvorbis-1.3.2 ]; then
        $CURL -L http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.2.tar.gz > libvorbis-1.3.2.tar.gz
        exit_on_error
        $TAR xzf libvorbis-1.3.2.tar.gz
    fi

    cd libvorbis-1.3.2
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --with-ogg=$TARGET --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBTHEORA
# http://xiph.org/downloads/
#
build_libtheora() {
    start_build libtheora
    cd $SRC

    if [ ! -d libtheora-1.1.1 ]; then
        $CURL -L http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.bz2 > libtheora-1.1.1.tar.bz2
        exit_on_error
        $TAR xjf libtheora-1.1.1.tar.bz2
    fi

    cd libtheora-1.1.1
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --with-ogg=$TARGET \
        --with-vorbis=$TARGET --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBZEN
# http://sourceforge.net/projects/zenlib/
#
build_libzen() {
    start_build libzen
    cd $SRC

    if [ ! -d libzen_0.4.19 ]; then
        $CURL -L http://heanet.dl.sourceforge.net/project/zenlib/ZenLib%20-%20Sources/0.4.19/libzen_0.4.19.tar.bz2 > libzen_0.4.19.tar.bz2
        exit_on_error
        $TAR xjf libzen_0.4.19.tar.bz2 -s /ZenLib/libzen_0.4.19/

        # libmediainfo needs this
        ln -s libzen_0.4.19 ZenLib
    fi

    cd libzen_0.4.19
    cd Project/GNU/Library
    export CFLAGS=
    export LDFLAGS=
    export CXXFLAGS=
    ./autogen
    ./configure --enable-arch-i386 --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# LZO2
# http://www.oberhumer.com/opensource/lzo/
#
build_lzo2() {
    start_build lzo2
    cd $SRC

    if [ ! -d lzo-2.04 ]; then
        $CURL -L http://www.oberhumer.com/opensource/lzo/download/lzo-2.04.tar.gz > lzo-2.04.tar.gz
        exit_on_error
        $TAR xzf lzo-2.04.tar.gz
    fi

    cd lzo-2.04
    set_flags

    if [ "$ARCHITECTURE" == "i386" ] || [ "$ARCHITECTURE" == "x86_64" ] ; then
        ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    else
        ./configure --disable-shared --disable-dependency-tracking --disable-asm --prefix=$TARGET
    fi

    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# NCURSES
# http://www.gnu.org/software/ncurses/
#
build_ncurses() {
    start_build ncurses
    cd $SRC

    if [ ! -d ncurses-5.9 ]; then
        $CURL -L http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz > ncurses-5.9.tar.gz
        exit_on_error
        $TAR xzf ncurses-5.9.tar.gz
    fi

    cd ncurses-5.9
    set_flags
    ./configure --without-shared --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE libs
    exit_on_error
    $MAKE install.libs
    cd $WORKDIR
}


##########################################
# TSMUXER
# http://www.smlabs.net/en/products/tsmuxer/
# http://www.videohelp.com/tools/tsMuxeR
# Interesting Open Source followup project in development: https://github.com/kierank/libmpegts
#
build_tsMuxeR() {
    start_build tsMuxeR
    cd $SRC

    if [ ! -d tsMuxeR_1.10.6 ]; then
        $CURL -H "Referer: http://www.videohelp.com/tools/tsMuxeR" -L http://www.videohelp.com/download/tsMuxeR_1.10.6.dmg > tsMuxeR_1.10.6.dmg
        exit_on_error
        createdir tsMuxeR_1.10.6
    fi

    # Nothing to build. Just open the disk image, copy the binary and detach the disk image
    $HDID tsMuxeR_1.10.6.dmg
    exit_on_error
    cp -f /Volumes/tsMuxeR/tsMuxerGUI.app/Contents/MacOS/tsMuxeR tsMuxeR_1.10.6/tsMuxeR
    cp -f tsMuxeR_1.10.6/tsMuxeR $TARGET/bin
    $HDIUTIL detach /Volumes/tsMuxeR
    cd $WORKDIR
}


##########################################
# X264
# svn://svn.videolan.org/x264/trunk
#
build_x264() {
    start_build x264
    cd $SRC

    if [ -d x264 ]; then
        cd x264
        $GIT pull git://git.videolan.org/x264.git
        exit_on_error
    else
        $GIT clone git://git.videolan.org/x264.git x264
        exit_on_error
        cd x264
    fi

    if [ "$FIXED_REVISIONS" == "yes" ]; then
        $GIT checkout "`$GIT rev-list master -n 1 --first-parent --before=2011-04-24`"
        exit_on_error
    fi

    set_flags

    if [ "$ARCHITECTURE" == "x86_64" ]; then
        ./configure --prefix=$TARGET
    else
        ./configure --prefix=$TARGET --host=x86-apple-darwin10 --disable-asm
    fi

    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# XVID
# http://www.xvid.org/
#
build_xvid() {
    start_build xvid
    cd $SRC

    if [ ! -d xvidcore-1.3.1 ]; then
        $CURL -L http://downloads.xvid.org/downloads/xvidcore-1.3.1.tar.gz > xvidcore-1.3.1.tar.gz
        exit_on_error
        $TAR xzf xvidcore-1.3.1.tar.gz -s /xvidcore/xvidcore-1.3.1/
    fi

    cd xvidcore-1.3.1/build/generic
    set_flags

    if [ "$ARCHITECTURE" == "x86_64" ]; then
        ./configure --prefix=$TARGET --host=x86-apple-darwin10
    else
        ./configure --prefix=$TARGET
    fi

    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# ZLIB
# http://zlib.net/
#
build_zlib() {
    start_build zlib
    cd $SRC

    if [ ! -d zlib-1.2.5 ]; then
        $CURL -L http://zlib.net/zlib-1.2.5.tar.gz > zlib-1.2.5.tar.gz
        exit_on_error
        $TAR xzf zlib-1.2.5.tar.gz
    fi

    cd zlib-1.2.5
    set_flags
    ./configure --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# FFMPEG
# http://www.ffmpeg.org/
#
build_ffmpeg() {
    start_build ffmpeg
    cd $SRC
    if [ -d ffmpeg ]; then
        cd ffmpeg
        $GIT pull git://git.videolan.org/ffmpeg.git
        exit_on_error
    else
        $GIT clone git://git.videolan.org/ffmpeg.git ffmpeg
        exit_on_error
        cd ffmpeg
    fi

    if [ "$FIXED_REVISIONS" == "yes" ]; then
        $GIT checkout "`$GIT rev-list master -n 1 --first-parent --before=2011-05-07`"
        exit_on_error
    fi

    # Fix path to git in "version.sh" to avoid version "UNKNOWN"
    GIT_STR=`echo $GIT | $SED -e "s/\//\\\\\\\\\\\//g"`
    $SED -i -e "s/git /$GIT_STR /g" version.sh

    set_flags

    # Theora/vorbis disabled for mplayer, also disabled here to avoid build errors
    ./configure --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libxvid \
        --disable-libtheora --disable-libvorbis --disable-shared --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}



##########################################
# MPLAYER
# http://www.mplayerhq.hu/design7/news.html
#
build_mplayer() {
    start_build mplayer
    cd $SRC

    if [ "$FIXED_REVISIONS" == "yes" ]; then
        # FIXME: This revision of mencoder gives skewed and distorted sound
        REVISION="-r 33342"
        #REVISION="-r 29241" # Original (working) revision that is shipped with PMS (will not build)
    else
        REVISION=""
    fi

    if [ -d mplayer ]; then
        cd mplayer
        $SVN update $REVISION
        exit_on_error
    else
        $SVN checkout $REVISION svn://svn.mplayerhq.hu/mplayer/trunk mplayer
        exit_on_error
        cd mplayer
    fi

    # Copy ffmpeg source to avoid making another git clone by configure
    cp -rf $SRC/ffmpeg .

    set_flags

    # Extra flags for compiling mplayer
    export CFLAGS="-O4 -fomit-frame-pointer -pipe $CFLAGS"
    export CXXFLAGS="-O4 -fomit-frame-pointer -pipe $CXXFLAGS"

    # Theora/vorbis seems broken in this revision, disable it for now
    ./configure --disable-x11 --disable-gl --disable-qtx --disable-dvdread-internal \
        --disable-theora --disable-libvorbis \
        --with-freetype-config=$TARGET/bin/freetype-config --prefix=$TARGET

    # Somehow -I/usr/X11/include still made it into the config.mak, regardless of the --disable-x11
    $SED -i -e "s/-I\/usr\/X11\/include//g" config.mak

    # Remove the ffmpeg directory and copy the compiled ffmpeg again to avoid "make" rebuilding it
    rm -rf ffmpeg
    cp -rf $SRC/ffmpeg .

    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}

##########################################
# MENCODER_MT (multi-threaded)
# http://www.mplayerhq.hu/design7/news.html
# http://gitorious.org/ffmpeg/ffmpeg-mt
#
build_mencoder_mt() {
    start_build mencoder_mt
    cd $SRC

    if [ "$FIXED_REVISIONS" == "yes" ]; then
        REVISION="-r 33342"
    else
        REVISION=""
    fi

    if [ -d mencoder_mt ]; then
        cd mencoder_mt
        $SVN update $REVISION
        exit_on_error
    else
        $SVN checkout $REVISION svn://svn.mplayerhq.hu/mplayer/trunk mencoder_mt
        exit_on_error
        cd mencoder_mt
    fi

    # Remove the bundled ffmpeg and replace it with ffmpeg-mt
    rm -rf ffmpeg
    $GIT clone git://gitorious.org/~astrange/ffmpeg/ffmpeg-mt.git ffmpeg
    exit_on_error

    if [ "$FIXED_REVISIONS" == "yes" ]; then
        cd ffmpeg
        $GIT checkout "`$GIT rev-list master -n 1 --first-parent --before=2011-04-24`"
        exit_on_error
        cd ..
    fi

    set_flags

    # Extra flags for compiling mplayer
    export CFLAGS="-O4 -fomit-frame-pointer -pipe $CFLAGS"
    export CXXFLAGS="-O4 -fomit-frame-pointer -pipe $CXXFLAGS"

    # Theora/vorbis seems broken in this revision, disable it for now
    ./configure --disable-x11 --disable-gl --disable-qtx --disable-dvdread-internal \
        --disable-theora --disable-libvorbis \
        --with-freetype-config=$TARGET/bin/freetype-config --prefix=$TARGET

    # Somehow -I/usr/X11/include still made it into the config.mak, regardless of the --disable-x11
    $SED -i -e "s/-I\/usr\/X11\/include//g" config.mak

    $MAKE -j$THREADS
    exit_on_error
    cp mencoder $TARGET/bin/mencoder_mt
    cd $WORKDIR
}


##########################################
# PS3MEDIASERVER
# http://code.google.com/p/ps3mediaserver/
#
build_ps3mediaserver() {
    start_build ps3mediaserver
    cd $SRC

    if [ "$FIXED_REVISIONS" == "yes" ]; then
        REVISION="-r 552"
    else
        REVISION=""
    fi

    if [ -d ps3mediaserver ]; then
        cd ps3mediaserver
        $SVN update $REVISION
        exit_on_error
    else
        $SVN checkout $REVISION http://ps3mediaserver.googlecode.com/svn/trunk/ps3mediaserver ps3mediaserver
        exit_on_error
        cd ps3mediaserver
    fi

    cd osx
   
    # Overwrite with the home built tools
    cp $TARGET/bin/dcraw .
    cp $TARGET/bin/ffmpeg .
    cp $TARGET/bin/flac .
    cp $TARGET/bin/mplayer .
    cp $TARGET/bin/mencoder .
    cp $TARGET/bin/mencoder_mt .
    cp $TARGET/bin/tsMuxeR .

    set_flags
    $ANT DMG
    exit_on_error

    # Add the architecture name to the final file
    PMS_FILENAME_ORIG=`ls pms-macosx-*.dmg`
    PMS_FILENAME_NEW=`echo $PMS_FILENAME_ORIG | $SED -e "s/-macosx-/-macosx-$ARCHITECTURE-/"`
    mv $PMS_FILENAME_ORIG $PMS_FILENAME_NEW
    cp $PMS_FILENAME_NEW $WORKDIR
    cd $WORKDIR
}


##########################################
# Finally, execute the script...
#

# Check requirements
check_xcode
check_yasm
check_git
check_jarbundler

# Initialize variables for compiling
initialize

# Build static libraries to link against
build_zlib
build_expat
build_faad2
build_fontconfig
build_freetype
build_fribidi
build_giflib
build_jpeg
build_iconv
build_ncurses
build_lame
build_libdca
build_libdv
build_libdvdcss
build_libdvdread
build_libdvdnav
build_libmad
build_libzen
# Note: libmediainfo requires libzen to build
build_libmediainfo
build_libpng
build_libogg
build_libvorbis
build_libtheora
build_lzo2
build_x264
build_xvid

# Build tools for including with PS3 Media Server
build_flac
build_dcraw
build_tsMuxeR
build_ffmpeg
build_mplayer
build_mencoder_mt

# Build PS3 Media Server itself
build_ps3mediaserver
Raptor399
Project Member
 
Posts: 1916
Joined: Thu Mar 10, 2011 12:06 am

Re: Compiling PS3 Media Server on OSX

Postby Redlum » Mon May 09, 2011 12:19 pm

Raptor399 wrote:I fixed the compilation bug for MPlayer, but that only revealed a much bigger bug. :shock: Revision 33342 of mencoder makes videos play with horribly distorted sound! When viewing a regular Quicktime movie, the audio starts seconds later, sounds robotic and runs about 3x as slow as it should.

Yeah, I noticed this as well after further testing. I think we should try revision 32674 again, the problems I had with it should be fixed by disabling theora.
Redlum
Project Member
 
Posts: 371
Joined: Mon Jan 12, 2009 9:13 pm

Re: Compiling PS3 Media Server on OSX

Postby Raptor399 » Thu May 12, 2011 7:44 am

A quick and dirty solution to build a working PMS is to find the following line in the build script:

Code: Select all
    cp $TARGET/bin/mencoder .

and change it to:

Code: Select all
    # TODO: Latest revision of mencoder gives distorted sound, skip it and use the old revision.
    # cp $TARGET/bin/mencoder .


Hope that helps.
Raptor399
Project Member
 
Posts: 1916
Joined: Thu Mar 10, 2011 12:06 am

Re: Compiling PS3 Media Server on OSX

Postby Raptor399 » Mon May 30, 2011 11:24 pm

Improved the script a bit to cope with the newest versions of dependencies out there:

- Errors now stop the script on all error codes
- Removing dynamic libraries that are being generated
- Newer x264 requires "make install-lib-static" to install the library
- Fixed the "git" replacement in version.sh for FFmpeg so it also works multiple times
- Building latest revision of FFmpeg
- Building revision 33488 of MPlayer (same as latest Sherpya revision)
- Disabled fribidi for MPlayer and mencoder_mt because it breaks compilation
- Building revision 599 of PMS (1.23.0)
- Picking one single PMS_FILENAME_ORIG if there are more binaries.

Known bugs:

- mencoder gives delayed and distorted sound (outcomment "cp $TARGET/bin/mencoder ." to fix that, as outlined in the previous posting).
- PMS packs the shipped binary dcrawU, not the compiled dcraw

Code: Select all
#!/bin/sh
#
# build-pms-osx.sh
#
# Version: 1.8
# Last updated: 2011-05-30
# Author: Patrick Atoon
#
#
# DESCRIPTION
#
# Building a statically linked PS3 Media Server for OSX is not an easy
# task and requires advanced knowledge of building the libraries and
# tools involved.
#
# This script will take care of building all that is required to build
# a statically linked PS3 Media Server for OSX.
# It will attempt to build universal binaries (for Intel and PCC)  where
# possible. However, some libraries do not support this and the script
# will compile for the current architecture.
#
# The script will compile the PS3 Media Server disk image file:
#
#    pms-macosx-arch-x.xx.x.dmg
#
# This script is provided as is. If it works for you, good! If it does
# not, try to figure out why and share your findings on the PS3 Media
# Server forums (http://www.ps3mediaserver.org/forum/)
#
#
# REQUIREMENTS
#
# Some Developer tools need to be installed manually. The script detects
# this and provides help. Other sources will be downloaded automatically.
#
#
# ACKNOWLEDGEMENTS
#
# Many thanks to the PS3 Media Server developers and forum moderators
# for keeping the project alive and the info coming. Special thanks to
# Adrian Stutz for sharing his findings of how to build a statically
# linked MPlayerOSX (http://www.mplayerosx.ch/), without his hard work
# this script would not have been possible. Also thanks to Redlum for
# his assistance in getting this script production ready.
#
#
# TODO
#
# - Clean up dependencies that are not needed for PMS
#
#
# COPYRIGHT
#
# This script is distributed under the Creative Commons Attribution 3.0
# (CC BY) license. This means you are free to copy, distribute, transmit
# and adapt it to suit your needs, as long as you mention the original
# author in your work.
# For more details, see http://creativecommons.org/licenses/by/3.0/
#
#
# CONFIGURATION
#
# Set FIXED_REVISIONS to "no" to check out the latest revisions.
# Default is "yes" to check out the last known working revision.
FIXED_REVISIONS="yes"

# Set TARGET_ARCHITECTURE for building binaries. Choose one of the following:
#
#    native: build for your own computer
#    x86_64: build for 64 bits Intel x86
#    i386: build for Intel 386
#    ppc: build for PowerPC
#
TARGET_ARCHITECTURE="i386"

# Set the amount of threads that are used for compiling everything. This
# should generally be the same as the amount of CPU cores in your computer
# (look for Total Number Of Cores in System Profiler if you don't know it).
THREADS="2"


##########################################
# It should not be necessary to change anything below this line


# Binaries
ANT=/usr/bin/ant
CURL=/usr/bin/curl
GCC=/usr/bin/gcc
GIT=/usr/local/git/bin/git
HDID=/usr/bin/hdid
HDIUTIL=/usr/bin/hdiutil
MAKE=/usr/bin/make
SED=/usr/bin/sed
SVN=/usr/bin/svn
TAR=/usr/bin/tar
YASM=/usr/local/bin/yasm
UNZIP=/usr/bin/unzip

##########################################
# Create a directory when it does not exist
#
createdir() {
    if [ ! -d $1 ]; then
        mkdir $1
    fi
}


##########################################
# Set the compiler flags to determine the architecture to compile for
# Optional parameter: architecture flags string to replace the default,
# e.g. "-arch ppc -faltivec -mcpu=7450"
#
set_flags() {
    # Minimum OS version as target
    export MACOSX_DEPLOYMENT_TARGET=10.5
    export CFLAGS="-mmacosx-version-min=10.5 -isystem /Developer/SDKs/MacOSX10.5.sdk"
    export LDFLAGS="-mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk"
    export CXXFLAGS="-mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk"

    if [ "$1" != "" ]; then
        # Use the supplied parameter string for architecture flags
        export CFLAGS="$CFLAGS $1"
        export LDFLAGS="$LDFLAGS $1"
        export CXXFLAGS="$CXXFLAGS $1"
    else
        # Uncomment for single architecture binary
        export CFLAGS="$CFLAGS -arch $ARCHITECTURE"
        export LDFLAGS="$LDFLAGS -arch $ARCHITECTURE"
        export CXXFLAGS="$CXXFLAGS -arch $ARCHITECTURE"
    fi

    # Paths of the build environment
    export LDFLAGS="$LDFLAGS -L$TARGET/lib -Wl,-search_paths_first"
    export CFLAGS="$CFLAGS -I$TARGET/include"
    export CXXFLAGS="$CXXFLAGS -I$TARGET/include"
}


##########################################
# Initialize building environment
#
initialize() {
    WORKDIR=`pwd`

    # Directories for statically compiled libraries
    TARGET="$WORKDIR/target"
    SRC="$WORKDIR/src"
    createdir "$SRC"
    createdir "$TARGET"

    if [ "$TARGET_ARCHITECTURE" == "native" ]; then
        ARCHITECTURE=`/usr/bin/uname -p`
    else
        ARCHITECTURE=$TARGET_ARCHITECTURE
    fi

    # Set default compiler flags
    set_flags

    # Reset paths for compiling
    export PATH="$TARGET/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
    export PKG_CONFIG_PATH=""
}


##########################################
# Check for gcc, make, svn, ant and curl
#
check_xcode() {
    if [ ! -x $GCC -o ! -x $SVN -o ! -x $ANT -o ! -x $CURL -o ! -x $MAKE ]; then
        cat << EOM
It seems you are missing Xcode from Apple, which is required to run this script.

Please go to http://developer.apple.com/technologies/xcode.html, create a free
Apple developer account and download Xcode and install it.
EOM
        exit;
    fi
}


##########################################
# Check for yasm
#
check_yasm() {
    if [ ! -x $YASM ]; then
        cat << EOM
It seems you are missing "yasm", which is required to run this script.
Please run the following commands to install "yasm":

    $SVN checkout http://www.tortall.net/svn/yasm/trunk/yasm yasm
    cd yasm
    ./autogen.sh
    ./configure
    make
    sudo make install
    cd $WORKDIR

EOM
        exit;
    fi
}


##########################################
# Check for git
#
check_git() {
    if [ ! -x $GIT ]; then
        cat << EOM
It seems you are missing "git", which is required to run this script.
Please go to http://code.google.com/p/git-osx-installer/, download git
and install it.
EOM
        exit;
    fi
}


##########################################
# Check for jarbundler
#
check_jarbundler() {
    # See if the jar file exists
    ls /usr/share/ant/lib/jarbundler-*.jar > /dev/null 2>&1

    if [ "$?" == "1" ]; then
        cat << EOM
It seems you are missing "jarbundler", which is required to run this script.
Please go to http://www.informagen.com/JarBundler/ , download the jarbundler
and install it.
EOM
        exit;
    fi
}


##########################################
# Exit if the previous command ended with an error status
#
exit_on_error() {
    if [ "$?" != "0" ]; then
        echo Fatal error occurred, aborting build.
        cd $WORKDIR
        exit
    fi
}


##########################################
# Building start marker to more easily follow the build process
#
start_build() {
    cat << EOM


--------------------------------------------------------------------------------------
Building $1
--------------------------------------------------------------------------------------

EOM
}



##########################################
# DCRAW
# http://www.cybercom.net/~dcoffin/dcraw/
#
build_dcraw() {
    start_build dcraw
    cd $SRC

    if [ ! -d dcraw-9.07 ]; then
        $CURL -L http://www.cybercom.net/~dcoffin/dcraw/archive/dcraw-9.07.tar.gz > dcraw-9.07.tar.gz
        exit_on_error
        $TAR xzf dcraw-9.07.tar.gz -s /dcraw/dcraw-9.07/
    fi

    cd dcraw-9.07
    set_flags
    $GCC -O4 -o dcraw dcraw.c -lm -ljpeg -DNO_LCMS $CFLAGS -L$TARGET/lib
    exit_on_error
    createdir $TARGET/bin
    cp dcraw $TARGET/bin
    cd $WORKDIR
}


##########################################
# EXPAT
# http://expat.sourceforge.net/
#
build_expat() {
    start_build expat
    cd $SRC

    if [ ! -d expat-2.0.1 ]; then
        $CURL -L http://garr.dl.sourceforge.net/project/expat/expat/2.0.1/expat-2.0.1.tar.gz > expat-2.0.1.tar.gz
        exit_on_error
        $TAR xzf expat-2.0.1.tar.gz
    fi

    cd expat-2.0.1
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# FAAD2
# http://www.audiocoding.com/faad2.html
#
build_faad2() {
    start_build faad2
    cd $SRC

    if [ ! -d faad2-2.7 ]; then
        $CURL -L http://mesh.dl.sourceforge.net/project/faac/faad2-src/faad2-2.7/faad2-2.7.tar.gz > faad2-2.7.tar.gz
        exit_on_error
        $TAR xzf faad2-2.7.tar.gz
    fi

    cd faad2-2.7
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# FLAC
# http://flac.sourceforge.net/
#
build_flac() {
    start_build flac
    cd $SRC

    if [ ! -d flac-1.2.1 ]; then
        $CURL -L http://downloads.xiph.org/releases/flac/flac-1.2.1.tar.gz > flac-1.2.1.tar.gz
        exit_on_error
        $TAR xzf flac-1.2.1.tar.gz
    fi

    cd flac-1.2.1
    set_flags

    if [ "$ARCHITECTURE" == "x86_64" ]; then
        ./configure --disable-shared --disable-dependency-tracking --host=x86-apple-darwin10 --prefix=$TARGET
    else
        ./configure --disable-shared --disable-dependency-tracking --disable-asm-optimizations --prefix=$TARGET
    fi

    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# FONTCONFIG
# http://fontconfig.org/wiki/
#
build_fontconfig() {
    start_build fontconfig
    cd $SRC

    if [ ! -d fontconfig-2.8.0 ]; then
        $CURL -L http://www.freedesktop.org/software/fontconfig/release/fontconfig-2.8.0.tar.gz > fontconfig-2.8.0.tar.gz
        exit_on_error
        $TAR xzf fontconfig-2.8.0.tar.gz
    fi

    cd fontconfig-2.8.0
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# FREETYPE
# http://www.freetype.org/
#
build_freetype() {
    start_build freetype
    cd $SRC

    if [ ! -d freetype-2.4.4 ]; then
        $CURL -L http://download.savannah.gnu.org/releases/freetype/freetype-2.4.4.tar.gz > freetype-2.4.4.tar.gz
        exit_on_error
        $TAR xzf freetype-2.4.4.tar.gz
    fi

    cd freetype-2.4.4
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# FRIBIDI
# http://fribidi.org/
#
build_fribidi() {
    start_build fribidi
    cd $SRC

    if [ ! -d fribidi-0.19.2 ]; then
        $CURL -L http://fribidi.org/download/fribidi-0.19.2.tar.gz > fribidi-0.19.2.tar.gz
        exit_on_error
        $TAR xzf fribidi-0.19.2.tar.gz
    fi

    cd fribidi-0.19.2
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# GIFLIB
# http://sourceforge.net/projects/giflib/
#
build_giflib() {
    start_build giflib
    cd $SRC

    if [ ! -d giflib-4.1.6 ]; then
        $CURL -L http://leaseweb.dl.sourceforge.net/project/giflib/giflib%204.x/giflib-4.1.6/giflib-4.1.6.tar.bz2 > giflib-4.1.6.tar.bz2
        exit_on_error
        $TAR xjf giflib-4.1.6.tar.bz2
    fi

    cd giflib-4.1.6
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# ICONV
# http://www.gnu.org/software/libiconv/
#
build_iconv() {
    start_build iconv
    cd $SRC

    if [ ! -d libiconv-1.13.1 ]; then
        $CURL -L http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz > libiconv-1.13.1.tar.gz
        exit_on_error
        $TAR xzf libiconv-1.13.1.tar.gz
    fi

    cd libiconv-1.13.1
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# JPEG
# http://www.ijg.org/
#
build_jpeg() {
    start_build jpeg
    cd $SRC

    if [ ! -d jpeg-8c ]; then
        $CURL -L http://www.ijg.org/files/jpegsrc.v8c.tar.gz > jpegsrc.v8c.tar.gz
        exit_on_error
        $TAR xzf jpegsrc.v8c.tar.gz
    fi

    cd jpeg-8c
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# LAME
# http://lame.sourceforge.net/
#
build_lame() {
    start_build lame
    cd $SRC

    if [ ! -d lame-3.98.4 ]; then
        $CURL -L http://sourceforge.net/projects/lame/files/lame/3.98.4/lame-3.98.4.tar.gz/download > lame-3.98.4.tar.gz
        exit_on_error
        $TAR xzf lame-3.98.4.tar.gz
    fi

    cd lame-3.98.4
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBDCA
# http://www.videolan.org/developers/libdca.html
#
build_libdca() {
    start_build libdca
    cd $SRC

    if [ ! -d libdca-0.0.5 ]; then
        $CURL -L http://download.videolan.org/pub/videolan/libdca/0.0.5/libdca-0.0.5.tar.bz2 > libdca-0.0.5.tar.bz2
        exit_on_error
        $TAR xjf libdca-0.0.5.tar.bz2
    fi

    cd libdca-0.0.5
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBDV
# http://libdv.sourceforge.net/
#
build_libdv() {
    start_build libdv
    cd $SRC

    if [ ! -d libdv-1.0.0 ]; then
        $CURL -L http://puzzle.dl.sourceforge.net/project/libdv/libdv/1.0.0/libdv-1.0.0.tar.gz > libdv-1.0.0.tar.gz
        exit_on_error
        $TAR xzf libdv-1.0.0.tar.gz
    fi

    cd libdv-1.0.0
    set_flags
    export LDFLAGS="$LDFLAGS -flat_namespace -undefined suppress"
    ./configure --disable-shared --disable-dependency-tracking --disable-xv \
        --disable-gtk --disable-sdl --disable-asm --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBDVDCSS
# http://www.videolan.org/developers/libdvdcss.html
#
build_libdvdcss() {
    start_build libdvdcss
    cd $SRC

    if [ ! -d libdvdcss-1.2.9 ]; then
        $CURL -L http://download.videolan.org/pub/libdvdcss/1.2.9/libdvdcss-1.2.9.tar.gz > libdvdcss-1.2.9.tar.gz
        exit_on_error
        $TAR xzf libdvdcss-1.2.9.tar.gz
    fi

    cd libdvdcss-1.2.9
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBDVDNAV
# svn://svn.mplayerhq.hu/dvdnav/trunk/libdvdnav/
#
build_libdvdnav() {
    start_build libdvdnav
    cd $SRC

    if [ "$FIXED_REVISIONS" == "yes" ]; then
        REVISION="-r 1226"
    else
        REVISION=""
    fi

    if [ ! -d libdvdnav ]; then
        $SVN checkout $REVISION svn://svn.mplayerhq.hu/dvdnav/trunk/libdvdnav/ libdvdnav
        exit_on_error
        cd libdvdnav
    else
        cd libdvdnav
        $SVN update $REVISION
        exit_on_error
    fi

    set_flags
    ./autogen.sh --with-dvdread-config=$TARGET/bin/dvdread-config --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}

##########################################
# LIBDVDREAD
# svn://svn.mplayerhq.hu/dvdnav/trunk/libdvdread/
#
build_libdvdread() {
    start_build libdvdread
    cd $SRC

    if [ "$FIXED_REVISIONS" == "yes" ]; then
        REVISION="-r 1226"
    else
        REVISION=""
    fi

    if [ ! -d libdvdread ]; then
        $SVN checkout $REVISION svn://svn.mplayerhq.hu/dvdnav/trunk/libdvdread/ libdvdread
        exit_on_error
        cd libdvdread
    else
        cd libdvdread
        $SVN update $REVISION
        exit_on_error
    fi

    set_flags
    ./autogen.sh --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBMAD
# http://www.underbit.com/products/mad/
#
build_libmad() {
    start_build libmad
    cd $SRC

    if [ ! -d libmad-0.15.1b ]; then
        $CURL -L ftp://ftp.mars.org/pub/mpeg/libmad-0.15.1b.tar.gz > libmad-0.15.1b.tar.gz
        exit_on_error
        $TAR xzf libmad-0.15.1b.tar.gz
    fi

    cd libmad-0.15.1b
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBMEDIAINFO
# http://sourceforge.net/projects/mediainfo/
#
build_libmediainfo() {
    start_build libmediainfo
    cd $SRC

    if [ ! -d libmediainfo_0.7.44 ]; then
        $CURL -L http://freefr.dl.sourceforge.net/project/mediainfo/source/libmediainfo/0.7.44/libmediainfo_0.7.44.tar.bz2 > libmediainfo_0.7.44.tar.bz2
        exit_on_error
        $TAR xjf libmediainfo_0.7.44.tar.bz2 -s /MediaInfoLib/libmediainfo_0.7.44/
    fi

    cd libmediainfo_0.7.44
    cd Project/GNU/Library
    export CFLAGS=
    export LDFLAGS=
    export CXXFLAGS=

    # Note: libmediainfo requires libzen source to compile
    ./autogen
    ./configure --enable-arch-i386 --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBPNG
# http://www.libpng.org/pub/png/libpng.html
#
build_libpng() {
    start_build libpng
    cd $SRC

    if [ ! -d libpng-1.5.2 ]; then
        $CURL -L http://mesh.dl.sourceforge.net/project/libpng/libpng15/1.5.2/libpng-1.5.2.tar.gz > libpng-1.5.2.tar.gz
        exit_on_error
        $TAR xzf libpng-1.5.2.tar.gz
    fi

    cd libpng-1.5.2
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBOGG
# http://xiph.org/downloads/
#
build_libogg() {
    start_build libogg
    cd $SRC

    if [ ! -d libogg-1.2.2 ]; then
        $CURL -L http://downloads.xiph.org/releases/ogg/libogg-1.2.2.tar.gz > libogg-1.2.2.tar.gz
        exit_on_error
        $TAR xzf libogg-1.2.2.tar.gz
    fi

    cd libogg-1.2.2
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBVORBIS
# http://xiph.org/downloads/
#
build_libvorbis() {
    start_build libvorbis
    cd $SRC

    if [ ! -d libvorbis-1.3.2 ]; then
        $CURL -L http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.2.tar.gz > libvorbis-1.3.2.tar.gz
        exit_on_error
        $TAR xzf libvorbis-1.3.2.tar.gz
    fi

    cd libvorbis-1.3.2
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --with-ogg=$TARGET --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBTHEORA
# http://xiph.org/downloads/
#
build_libtheora() {
    start_build libtheora
    cd $SRC

    if [ ! -d libtheora-1.1.1 ]; then
        $CURL -L http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.bz2 > libtheora-1.1.1.tar.bz2
        exit_on_error
        $TAR xjf libtheora-1.1.1.tar.bz2
    fi

    cd libtheora-1.1.1
    set_flags
    ./configure --disable-shared --disable-dependency-tracking --with-ogg=$TARGET \
        --with-vorbis=$TARGET --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# LIBZEN
# http://sourceforge.net/projects/zenlib/
#
build_libzen() {
    start_build libzen
    cd $SRC

    if [ ! -d libzen_0.4.19 ]; then
        $CURL -L http://heanet.dl.sourceforge.net/project/zenlib/ZenLib%20-%20Sources/0.4.19/libzen_0.4.19.tar.bz2 > libzen_0.4.19.tar.bz2
        exit_on_error
        $TAR xjf libzen_0.4.19.tar.bz2 -s /ZenLib/libzen_0.4.19/

        # libmediainfo needs this
        ln -s libzen_0.4.19 ZenLib
    fi

    cd libzen_0.4.19
    cd Project/GNU/Library
    export CFLAGS=
    export LDFLAGS=
    export CXXFLAGS=
    ./autogen
    ./configure --enable-arch-i386 --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# LZO2
# http://www.oberhumer.com/opensource/lzo/
#
build_lzo2() {
    start_build lzo2
    cd $SRC

    if [ ! -d lzo-2.04 ]; then
        $CURL -L http://www.oberhumer.com/opensource/lzo/download/lzo-2.04.tar.gz > lzo-2.04.tar.gz
        exit_on_error
        $TAR xzf lzo-2.04.tar.gz
    fi

    cd lzo-2.04
    set_flags

    if [ "$ARCHITECTURE" == "i386" ] || [ "$ARCHITECTURE" == "x86_64" ] ; then
        ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET
    else
        ./configure --disable-shared --disable-dependency-tracking --disable-asm --prefix=$TARGET
    fi

    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}


##########################################
# NCURSES
# http://www.gnu.org/software/ncurses/
#
build_ncurses() {
    start_build ncurses
    cd $SRC

    if [ ! -d ncurses-5.9 ]; then
        $CURL -L http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz > ncurses-5.9.tar.gz
        exit_on_error
        $TAR xzf ncurses-5.9.tar.gz
    fi

    cd ncurses-5.9
    set_flags
    ./configure --without-shared --disable-shared --disable-dependency-tracking --prefix=$TARGET
    $MAKE libs
    exit_on_error
    $MAKE install.libs
    cd $WORKDIR
}


##########################################
# TSMUXER
# http://www.smlabs.net/en/products/tsmuxer/
# http://www.videohelp.com/tools/tsMuxeR
# Interesting Open Source followup project in development: https://github.com/kierank/libmpegts
#
build_tsMuxeR() {
    start_build tsMuxeR
    cd $SRC

    if [ ! -d tsMuxeR_1.10.6 ]; then
        $CURL -H "Referer: http://www.videohelp.com/tools/tsMuxeR" -L http://www.videohelp.com/download/tsMuxeR_1.10.6.dmg > tsMuxeR_1.10.6.dmg
        exit_on_error
        createdir tsMuxeR_1.10.6
    fi

    # Nothing to build. Just open the disk image, copy the binary and detach the disk image
    $HDID tsMuxeR_1.10.6.dmg
    exit_on_error
    cp -f /Volumes/tsMuxeR/tsMuxerGUI.app/Contents/MacOS/tsMuxeR tsMuxeR_1.10.6/tsMuxeR
    cp -f tsMuxeR_1.10.6/tsMuxeR $TARGET/bin
    $HDIUTIL detach /Volumes/tsMuxeR
    cd $WORKDIR
}


##########################################
# X264
# svn://svn.videolan.org/x264/trunk
#
build_x264() {
    start_build x264
    cd $SRC

    if [ -d x264 ]; then
        cd x264
        $GIT pull git://git.videolan.org/x264.git
        exit_on_error
    else
        $GIT clone git://git.videolan.org/x264.git x264
        exit_on_error
        cd x264
    fi

    if [ "$FIXED_REVISIONS" == "yes" ]; then
        $GIT checkout "`$GIT rev-list master -n 1 --first-parent --before=2011-04-24`"
        exit_on_error
    fi

    set_flags

    if [ "$ARCHITECTURE" == "x86_64" ]; then
        ./configure --prefix=$TARGET
    else
        ./configure --prefix=$TARGET --host=x86-apple-darwin10 --disable-asm
    fi

    $MAKE -j$THREADS
    exit_on_error
    $MAKE install install-lib-static

    cd $WORKDIR
}


##########################################
# XVID
# http://www.xvid.org/
#
build_xvid() {
    start_build xvid
    cd $SRC

    if [ ! -d xvidcore-1.3.1 ]; then
        $CURL -L http://downloads.xvid.org/downloads/xvidcore-1.3.1.tar.gz > xvidcore-1.3.1.tar.gz
        exit_on_error
        $TAR xzf xvidcore-1.3.1.tar.gz -s /xvidcore/xvidcore-1.3.1/
    fi

    cd xvidcore-1.3.1/build/generic
    set_flags

    if [ "$ARCHITECTURE" == "x86_64" ]; then
        ./configure --prefix=$TARGET --host=x86-apple-darwin10
    else
        ./configure --prefix=$TARGET
    fi

    $MAKE -j$THREADS
    exit_on_error
    $MAKE install

    # Remove dynamic libraries
    rm -f $TARGET/lib/libxvidcore*.dylib

    cd $WORKDIR
}


##########################################
# ZLIB
# http://zlib.net/
#
build_zlib() {
    start_build zlib
    cd $SRC

    if [ ! -d zlib-1.2.5 ]; then
        $CURL -L http://zlib.net/zlib-1.2.5.tar.gz > zlib-1.2.5.tar.gz
        exit_on_error
        $TAR xzf zlib-1.2.5.tar.gz
    fi

    cd zlib-1.2.5
    set_flags
    ./configure --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install

    # Remove dynamic libraries
    rm -f $TARGET/lib/libz*.dylib
    cd $WORKDIR
}


##########################################
# FFMPEG
# http://www.ffmpeg.org/
#
build_ffmpeg() {
    start_build ffmpeg
    cd $SRC
    if [ -d ffmpeg ]; then
        cd ffmpeg
        $GIT pull git://git.videolan.org/ffmpeg.git
        exit_on_error
    else
        $GIT clone git://git.videolan.org/ffmpeg.git ffmpeg
        exit_on_error
        cd ffmpeg
    fi

    if [ "$FIXED_REVISIONS" == "yes" ]; then
        $GIT checkout "`$GIT rev-list master -n 1 --first-parent --before=2011-05-31`"
        exit_on_error
    fi

    # Fix path to git in "version.sh" to avoid version "UNKNOWN"
    GIT_STR=`echo $GIT | $SED -e "s/\//\\\\\\\\\\\//g"`
    $SED -i -e "s/ git / $GIT_STR /g" version.sh

    set_flags

    # Theora/vorbis disabled for mplayer, also disabled here to avoid build errors
    ./configure --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libxvid \
        --disable-libtheora --disable-libvorbis --disable-shared --prefix=$TARGET
    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}



##########################################
# MPLAYER
# http://www.mplayerhq.hu/design7/news.html
#
build_mplayer() {
    start_build mplayer
    cd $SRC

    if [ "$FIXED_REVISIONS" == "yes" ]; then
        REVISION="-r 33488" # Same revision as the latest Sherpya build
        #REVISION="-r 33342" # Same as the Windows distribution, but gives skewed and distorted sound
        #REVISION="-r 29241" # Original (working) revision that is shipped with PMS-1.20.409-BETA (will not build though)
    else
        REVISION=""
    fi

    if [ -d mplayer ]; then
        cd mplayer
        $SVN update $REVISION
        exit_on_error
    else
        $SVN checkout $REVISION svn://svn.mplayerhq.hu/mplayer/trunk mplayer
        exit_on_error
        cd mplayer
    fi

    # Copy ffmpeg source to avoid making another git clone by configure
    rm -rf ffmpeg
    cp -rf $SRC/ffmpeg .

    set_flags

    # Extra flags for compiling mplayer
    export CFLAGS="-O4 -fomit-frame-pointer -pipe $CFLAGS"
    export CXXFLAGS="-O4 -fomit-frame-pointer -pipe $CXXFLAGS"

    # Theora, vorbis and fribidi support seems broken in this revision, disable it for now
    ./configure --disable-x11 --disable-gl --disable-qtx --disable-dvdread-internal \
        --disable-theora --disable-libvorbis --disable-fribidi \
        --with-freetype-config=$TARGET/bin/freetype-config --prefix=$TARGET

    # Somehow -I/usr/X11/include still made it into the config.mak, regardless of the --disable-x11
    $SED -i -e "s/-I\/usr\/X11\/include//g" config.mak

    # Remove the ffmpeg directory and copy the compiled ffmpeg again to avoid "make" rebuilding it
    rm -rf ffmpeg
    cp -rf $SRC/ffmpeg .

    $MAKE -j$THREADS
    exit_on_error
    $MAKE install
    cd $WORKDIR
}

##########################################
# MENCODER_MT (multi-threaded)
# http://www.mplayerhq.hu/design7/news.html
# http://gitorious.org/ffmpeg/ffmpeg-mt
#
build_mencoder_mt() {
    start_build mencoder_mt
    cd $SRC

    if [ "$FIXED_REVISIONS" == "yes" ]; then
        REVISION="-r 33488" # Same revision as the latest Sherpya build
        #REVISION="-r 33342" # Same as the Windows distribution, but gives skewed and distorted sound
    else
        REVISION=""
    fi

    if [ -d mencoder_mt ]; then
        cd mencoder_mt
        $SVN update $REVISION
        exit_on_error
    else
        $SVN checkout $REVISION svn://svn.mplayerhq.hu/mplayer/trunk mencoder_mt
        exit_on_error
        cd mencoder_mt
    fi

    # Remove the bundled ffmpeg and replace it with ffmpeg-mt
    rm -rf ffmpeg
    $GIT clone git://gitorious.org/~astrange/ffmpeg/ffmpeg-mt.git ffmpeg
    exit_on_error

    if [ "$FIXED_REVISIONS" == "yes" ]; then
        cd ffmpeg
        $GIT checkout "`$GIT rev-list master -n 1 --first-parent --before=2011-05-31`"
        exit_on_error
        cd ..
    fi

    set_flags

    # Extra flags for compiling mplayer
    export CFLAGS="-O4 -fomit-frame-pointer -pipe $CFLAGS"
    export CXXFLAGS="-O4 -fomit-frame-pointer -pipe $CXXFLAGS"

    # Theora, vorbis and fribidi support seems broken in this revision, disable it for now
    ./configure --disable-x11 --disable-gl --disable-qtx --disable-dvdread-internal \
        --disable-theora --disable-libvorbis --disable-fribidi \
        --with-freetype-config=$TARGET/bin/freetype-config --prefix=$TARGET

    # Somehow -I/usr/X11/include still made it into the config.mak, regardless of the --disable-x11
    $SED -i -e "s/-I\/usr\/X11\/include//g" config.mak

    $MAKE -j$THREADS
    exit_on_error
    cp mencoder $TARGET/bin/mencoder_mt
    cd $WORKDIR
}


##########################################
# PS3MEDIASERVER
# http://code.google.com/p/ps3mediaserver/
#
build_ps3mediaserver() {
    start_build ps3mediaserver
    cd $SRC

    if [ "$FIXED_REVISIONS" == "yes" ]; then
        REVISION="-r 599"
    else
        REVISION=""
    fi

    if [ -d ps3mediaserver ]; then
        cd ps3mediaserver
        $SVN update $REVISION
        exit_on_error
    else
        $SVN checkout $REVISION http://ps3mediaserver.googlecode.com/svn/trunk/ps3mediaserver ps3mediaserver
        exit_on_error
        cd ps3mediaserver
    fi

    cd osx
   
    # Overwrite with the home built tools
    cp $TARGET/bin/dcraw .
    cp $TARGET/bin/ffmpeg .
    cp $TARGET/bin/flac .
    cp $TARGET/bin/mplayer .
    cp $TARGET/bin/mencoder .
    cp $TARGET/bin/mencoder_mt .
    cp $TARGET/bin/tsMuxeR .

    set_flags
    $ANT DMG
    exit_on_error

    # Add the architecture name to the final file
    PMS_FILENAME_ORIG=`ls pms-macosx-*.dmg | head -1`
    PMS_FILENAME_NEW=`echo $PMS_FILENAME_ORIG | $SED -e "s/-macosx-/-macosx-$ARCHITECTURE-/"`
    mv -f $PMS_FILENAME_ORIG $PMS_FILENAME_NEW
    cp $PMS_FILENAME_NEW $WORKDIR
    cd $WORKDIR
}


##########################################
# Finally, execute the script...
#

# Check requirements
check_xcode
check_yasm
check_git
check_jarbundler

# Initialize variables for compiling
initialize

# Build static libraries to link against
build_zlib
build_expat
build_faad2
build_fontconfig
build_freetype
build_fribidi
build_giflib
build_jpeg
build_iconv
build_ncurses
build_lame
build_libdca
build_libdv
build_libdvdcss
build_libdvdread
build_libdvdnav
build_libmad
build_libzen
# Note: libmediainfo requires libzen to build
build_libmediainfo
build_libpng
build_libogg
build_libvorbis
build_libtheora
build_lzo2
build_x264
build_xvid

# Build tools for including with PS3 Media Server
build_flac
build_dcraw
build_tsMuxeR
build_ffmpeg
build_mplayer
build_mencoder_mt

# Build PS3 Media Server itself
build_ps3mediaserver


Builds tested for the i386 and x86_64 architectures.
Raptor399
Project Member
 
Posts: 1916
Joined: Thu Mar 10, 2011 12:06 am

Re: Compiling PS3 Media Server on OSX

Postby ghgilbert » Tue May 31, 2011 7:05 pm

Great work guys!
ghgilbert
 
Posts: 4
Joined: Tue May 31, 2011 6:24 pm

Re: Compiling PS3 Media Server on OSX

Postby Raptor399 » Wed Jun 01, 2011 11:47 pm

I found the problem with the new mencoder on OSX that causes the distorted and skewed sound! :mrgreen:

Ever since I heard the distorted and skewed sound in the freshest builds, I wondered about the following mencoder notice in the "debug.log":

Code: Select all
Encoder requires input not properly supported.Try using e.g. 'ac3_fixed' instead of 'ac3' as codec


It took me a while to figure out how to test the mencoder / tsMuxeR combo on the command line and generate an output file (1, 2).

The command line tests prove that the mencoder argument "acodec=ac3" is responsible for screwing up the sound in the muxed file.
That setting worked fine for the old MEncoder SVN-r29241-snapshot-4.0.1, but it messes up the new MEncoder SVN-r33488-4.2.1.

And the solution seems to be what the logfile proposes: use "acodec=ac3_fixed" instead. Using that, I end up with perfectly fine muxed files.

I searched for "acodec=ac3" and patched the PMS sources accordingly:

Code: Select all
Index: net/pms/encoders/MEncoderWebVideo.java
===================================================================
--- net/pms/encoders/MEncoderWebVideo.java   (revision 603)
+++ net/pms/encoders/MEncoderWebVideo.java   (working copy)
@@ -60,7 +60,7 @@
    }
 
    protected String[] getDefaultArgs() {
-      return new String [] { "-prefer-ipv4", "-nocache", "-quiet", "-oac", "lavc", "-of", "lavf", "-lavfopts", "format=dvd", "-ovc", "lavc", "-lavcopts", "vcodec=mpeg2video:vbitrate=4096:threads=2:acodec=ac3:abitrate=128", "-vf", "harddup", "-ofps", "24000/1001" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ //$NON-NLS-14$
+      return new String [] { "-prefer-ipv4", "-nocache", "-quiet", "-oac", "lavc", "-of", "lavf", "-lavfopts", "format=dvd", "-ovc", "lavc", "-lavcopts", "vcodec=mpeg2video:vbitrate=4096:threads=2:acodec=ac3_fixed:abitrate=128", "-vf", "harddup", "-ofps", "24000/1001" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ //$NON-NLS-14$
    }
    
    private final PmsConfiguration configuration;
Index: net/pms/encoders/MEncoderVideo.java
===================================================================
--- net/pms/encoders/MEncoderVideo.java   (revision 603)
+++ net/pms/encoders/MEncoderVideo.java   (working copy)
@@ -1169,12 +1169,12 @@
             mainConfig = mainConfig.substring(mainConfig.indexOf("/*")); //$NON-NLS-1$
          }
          // Ditlew - org
-         //String encodeSettings = "-lavcopts autoaspect=1:vcodec=" + vcodec + (wmv?":acodec=wmav2:abitrate=256":(":acodec=ac3:abitrate=" + CodecUtil.getAC3Bitrate(configuration, params.aid))) + ":threads=" + (wmv?1:configuration.getNumberOfCpuCores()) + ":" + mainConfig; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+         //String encodeSettings = "-lavcopts autoaspect=1:vcodec=" + vcodec + (wmv?":acodec=wmav2:abitrate=256":(":acodec=ac3_fixed:abitrate=" + CodecUtil.getAC3Bitrate(configuration, params.aid))) + ":threads=" + (wmv?1:configuration.getNumberOfCpuCores()) + ":" + mainConfig; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
 
          // Ditlew - WDTV Live (+ other byte asking clients), CBR. This probably ought to be placed in addMaximumBitrateConstraints(..)
          int cbr_bitrate = params.mediaRenderer.getCBRVideoBitrate();
          String cbr_settings = (cbr_bitrate > 0) ? ":vrc_buf_size=1835:vrc_minrate=" + cbr_bitrate + ":vrc_maxrate=" + cbr_bitrate + ":vbitrate=" + cbr_bitrate : "";
-         String encodeSettings = "-lavcopts autoaspect=1:vcodec=" + vcodec + (wmv ? ":acodec=wmav2:abitrate=256" : (cbr_settings + ":acodec=ac3:abitrate=" + CodecUtil.getAC3Bitrate(configuration, params.aid))) + ":threads=" + (wmv ? 1 : configuration.getNumberOfCpuCores()) + ":" + mainConfig; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+         String encodeSettings = "-lavcopts autoaspect=1:vcodec=" + vcodec + (wmv ? ":acodec=wmav2:abitrate=256" : (cbr_settings + ":acodec=ac3_fixed:abitrate=" + CodecUtil.getAC3Bitrate(configuration, params.aid))) + ":threads=" + (wmv ? 1 : configuration.getNumberOfCpuCores()) + ":" + mainConfig; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
 
          encodeSettings = addMaximumBitrateConstraints(encodeSettings, media, mainConfig, params.mediaRenderer);
          st = new StringTokenizer(encodeSettings, " "); //$NON-NLS-1$
@@ -1501,7 +1501,7 @@
                } else if (sArgs[s].equals("-quality")) { //$NON-NLS-1$
                   for (int c = 0; c < cmdArray.length; c++) {
                      if (cmdArray[c] != null && cmdArray[c].equals("-lavcopts")) {//$NON-NLS-1$
-                        cmdArray[c + 1] = "autoaspect=1:vcodec=" + vcodec + ":acodec=ac3:abitrate=" + CodecUtil.getAC3Bitrate(configuration, params.aid) + ":threads=" + configuration.getNumberOfCpuCores() + ":" + sArgs[s + 1]; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+                        cmdArray[c + 1] = "autoaspect=1:vcodec=" + vcodec + ":acodec=ac3_fixed:abitrate=" + CodecUtil.getAC3Bitrate(configuration, params.aid) + ":threads=" + configuration.getNumberOfCpuCores() + ":" + sArgs[s + 1]; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
                         addMaximumBitrateConstraints(cmdArray[c + 1], media, cmdArray[c + 1], params.mediaRenderer);
                         sArgs[s + 1] = "-quality"; //$NON-NLS-1$
                         s++;
Index: net/pms/encoders/TSMuxerVideo.java
===================================================================
--- net/pms/encoders/TSMuxerVideo.java   (revision 603)
+++ net/pms/encoders/TSMuxerVideo.java   (working copy)
@@ -239,7 +239,7 @@
                   if (!params.mediaRenderer.isMuxDTSToMpeg())
                      ffAudioPipe[0].setModifier(sm);
                } else
-                  ffmpegLPCMextract = new String [] { mencoderPath, "-ss", "0", fileName, "-quiet", "-quiet", "-really-quiet", "-msglevel", "statusline=2", "-channels", "" + CodecUtil.getAC3ChannelCount(configuration, params.aid), "-ovc", "copy", "-of", "rawaudio", "-mc", "0", "-noskip", "-oac", (params.aid.isAC3() && configuration.isRemuxAC3())?"copy":"lavc", params.aid.isAC3()?"-fafmttag":"-quiet", params.aid.isAC3()?"0x2000":"-quiet", "-lavcopts", "acodec=ac3:abitrate="+CodecUtil.getAC3Bitrate(configuration, params.aid), "-af", "lavcresample=48000", "-srate", "48000", singleMediaAudio?"-quiet":"-aid", singleMediaAudio?"-quiet":("" + params.aid.id), "-o", ffAudioPipe[0].getInputPipe() }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ //$NON-NLS-14$ //$NON-NLS-15$ //$NON-NLS-16$ //$NON-NLS-17$ //$NON-NLS-18$ //$NON-NLS-19$ //$NON-NLS-20$ //$NON-NLS-21$ //$NON-NLS-22$ //$NON-NLS-23$ //$NON-NLS-24$ //$NON-NLS-25$ //$NON-NLS-26$ //$NON-NLS-27$ //$NON-NLS-28$ //$NON-NLS-29$ //$NON-NLS-30$ //$NON-NLS-31$ //$NON-NLS-32$ //$NON-NLS-33$ //$NON-NLS-34$
+                  ffmpegLPCMextract = new String [] { mencoderPath, "-ss", "0", fileName, "-quiet", "-quiet", "-really-quiet", "-msglevel", "statusline=2", "-channels", "" + CodecUtil.getAC3ChannelCount(configuration, params.aid), "-ovc", "copy", "-of", "rawaudio", "-mc", "0", "-noskip", "-oac", (params.aid.isAC3() && configuration.isRemuxAC3())?"copy":"lavc", params.aid.isAC3()?"-fafmttag":"-quiet", params.aid.isAC3()?"0x2000":"-quiet", "-lavcopts", "acodec=ac3_fixed:abitrate="+CodecUtil.getAC3Bitrate(configuration, params.aid), "-af", "lavcresample=48000", "-srate", "48000", singleMediaAudio?"-quiet":"-aid", singleMediaAudio?"-quiet":("" + params.aid.id), "-o", ffAudioPipe[0].getInputPipe() }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ //$NON-NLS-14$ //$NON-NLS-15$ //$NON-NLS-16$ //$NON-NLS-17$ //$NON-NLS-18$ //$NON-NLS-19$ //$NON-NLS-20$ //$NON-NLS-21$ //$NON-NLS-22$ //$NON-NLS-23$ //$NON-NLS-24$ //$NON-NLS-25$ //$NON-NLS-26$ //$NON-NLS-27$ //$NON-NLS-28$ //$NON-NLS-29$ //$NON-NLS-30$ //$NON-NLS-31$ //$NON-NLS-32$ //$NON-NLS-33$ //$NON-NLS-34$
 
                if (fileName.toLowerCase().endsWith(".evo")) { //$NON-NLS-1$
                   ffmpegLPCMextract[4] = "-psprobe"; //$NON-NLS-1$
@@ -275,7 +275,7 @@
                      String mixer = CodecUtil.getMixerOutput(!sm.isDtsembed(), sm.getNbchannels());
                      ffmpegLPCMextract = new String [] { mencoderPath, "-ss", "0", fileName, "-quiet", "-quiet", "-really-quiet", "-msglevel", "statusline=2", "-channels", "" + sm.getNbchannels(), "-ovc", "copy", "-of", "rawaudio", "-mc", sm.isDtsembed()?"0.1":"0", "-noskip", "-oac", sm.isDtsembed()?"copy":"pcm", mixer!=null?"-af":"-quiet", mixer!=null?mixer:"-quiet", singleMediaAudio?"-quiet":"-aid", singleMediaAudio?"-quiet":("" + audio.id), "-srate", "48000", "-o", ffAudioPipe[i].getInputPipe() }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ //$NON-NLS-14$ //$NON-NLS-15$ //$NON-NLS-16$ //$NON-NLS-17$ //$NON-NLS-18$ //$NON-NLS-19$ //$NON-NLS-20$ //$NON-NLS-21$ //$NON-NLS-22$ //$NON-NLS-23$ //$NON-NLS-24$ //$NON-NLS-25$ //$NON-NLS-26$ //$NON-NLS-27$ //$NON-NLS-28$ //$NON-NLS-29$
                   } else {
-                     ffmpegLPCMextract = new String [] { mencoderPath, "-ss", "0", fileName, "-quiet", "-quiet", "-really-quiet", "-msglevel", "statusline=2", "-channels", "" + CodecUtil.getAC3ChannelCount(configuration, audio), "-ovc", "copy", "-of", "rawaudio", "-mc", "0", "-noskip", "-oac", (audio.isAC3() && configuration.isRemuxAC3())?"copy":"lavc", audio.isAC3()?"-fafmttag":"-quiet", audio.isAC3()?"0x2000":"-quiet", "-lavcopts", "acodec=ac3:abitrate="+CodecUtil.getAC3Bitrate(configuration, audio), "-af", "lavcresample=48000", "-srate", "48000", singleMediaAudio?"-quiet":"-aid", singleMediaAudio?"-quiet":("" + audio.id), "-o", ffAudioPipe[i].getInputPipe() }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ //$NON-NLS-14$ //$NON-NLS-15$ //$NON-NLS-16$ //$NON-NLS-17$ //$NON-NLS-18$ //$NON-NLS-19$ //$NON-NLS-20$ //$NON-NLS-21$ //$NON-NLS-22$ //$NON-NLS-23$ //$NON-NLS-24$ //$NON-NLS-25$ //$NON-NLS-26$ //$NON-NLS-27$ //$NON-NLS-28$ //$NON-NLS-29$ //$NON-NLS-30$ //$NON-NLS-31$ //$NON-NLS-32$ //$NON-NLS-33$ //$NON-NLS-34$
+                     ffmpegLPCMextract = new String [] { mencoderPath, "-ss", "0", fileName, "-quiet", "-quiet", "-really-quiet", "-msglevel", "statusline=2", "-channels", "" + CodecUtil.getAC3ChannelCount(configuration, audio), "-ovc", "copy", "-of", "rawaudio", "-mc", "0", "-noskip", "-oac", (audio.isAC3() && configuration.isRemuxAC3())?"copy":"lavc", audio.isAC3()?"-fafmttag":"-quiet", audio.isAC3()?"0x2000":"-quiet", "-lavcopts", "acodec=ac3_fixed:abitrate="+CodecUtil.getAC3Bitrate(configuration, audio), "-af", "lavcresample=48000", "-srate", "48000", singleMediaAudio?"-quiet":"-aid", singleMediaAudio?"-quiet":("" + audio.id), "-o", ffAudioPipe[i].getInputPipe() }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ //$NON-NLS-14$ //$NON-NLS-15$ //$NON-NLS-16$ //$NON-NLS-17$ //$NON-NLS-18$ //$NON-NLS-19$ //$NON-NLS-20$ //$NON-NLS-21$ //$NON-NLS-22$ //$NON-NLS-23$ //$NON-NLS-24$ //$NON-NLS-25$ //$NON-NLS-26$ //$NON-NLS-27$ //$NON-NLS-28$ //$NON-NLS-29$ //$NON-NLS-30$ //$NON-NLS-31$ //$NON-NLS-32$ //$NON-NLS-33$ //$NON-NLS-34$
                   }
 
                   if (fileName.toLowerCase().endsWith(".evo")) { //$NON-NLS-1$


The result is that I now have a working version of PMS with all the latest tools, compiled for OSX (pms-macosx-x86_64-1.23.0.dmg)! :mrgreen:

dcraw: 9.07
ffmpeg: git-N-30425-g3d0424f
flac: 1.2.1
mencoder: SVN-r33488-4.2.1
mencoder_mt: SVN-r33488-4.2.1
mplayer: SVN-r33488-4.2.1
tsMuxeR: 1.10.6

P.S. Note: web video will still get distorted and skewed audio if you use chocolateboy's PMSencoder plugin, because that still calls mencoder with "acodec=ac3" instead of "acodec=ac3_fixed". :|

Soooo...
Please confirm these findings and confirm that changing the acodec for mencoder is a good idea (note that this will also affect Windows and Linux!).
Attachments
ac3_fixed.zip
Added ac3_fixed.zip containing the patch as requested by chocolateboy.
(1.81 KiB) Downloaded 113 times
Last edited by Raptor399 on Thu Jun 02, 2011 12:29 pm, edited 1 time in total.
Raptor399
Project Member
 
Posts: 1916
Joined: Thu Mar 10, 2011 12:06 am

PreviousNext

Return to Mac OS X Support

Who is online

Users browsing this forum: No registered users and 5 guests