Category Archives: Tutorial

Compiling GPAC for MacOS X

⚠ The content of this page may be outdated.
Please refer to this page for more up to date information: https://github.com/gpac/gpac/wiki/GPAC-Build-Guide-for-OSX

 


This page describes how to setup a complete build environment for GPAC using Macports (update: Brew command-line below tested on Mac OS 10.11) in order to generate DMG installer images for both 10.5 and 10.6 versions of MacOS X.

Getting GPAC source code

Using a git client, checkout GPAC from the repository:

git clone https://github.com/gpac/gpac.git

Configuring macports

(Re-)Installing

If macports is installed, uninstall it:

sudo port -f uninstall installed
sudo rm -rf /opt/local /Applications/DarwinPorts /Applications/MacPorts /Library/LaunchDaemons/org.macports.* /Library/Receipts/DarwinPorts*.pkg /Library/Receipts/MacPorts*.pkg Library/StartupItems/DarwinPortsStartup /Library/Tcl/darwinports1.0 /Library/Tcl/macports1.0 ~/.macports

Install macport. You MUST install a version >=1.9.x

Custom flags for OSX 10.5 and 10.6 compatibility

If you plan to generate GPAC binaries compatible with 10.5, add the following lines at the end of /opt/local/etc/macports/macports.conf:

macosx_deployment_target 10.4
sdkroot /Developer/SDKs/MacOSX10.5.sdk

This allows compiling a 10.5 binary with a 10.4 compatible dyld (dyn. loader). Furthermore, you will need to install the 10.5 development SDK. Such binaries should work on any 32 bits x86 versions of OS X.

Custom flags for OSX 10.6 32 bits only

If you are on a 10.6 platform with default targetting to x86_64 (ie x86_64 compatible cpu, whatever is your kernel configuration), you still may want to generate i386 binaries. Uncomment the build_arch i386 line of /opt/local/etc/macports/macports.conf. Also comment the universal_archs feature as MacPorts may end up in an unpredictable state and you won’t be able to compile GPAC with most features:

build_arch i386
# CPU architectures to use for Universal Binaries (+universal variant)
#universal_archs i386

Installing GPAC extra libs

MacPorts packages

To install a package, type:

sudo port install my_package_name

The command-line to install all the packages (compulsory and optional) can be found below in this chapter.
The zlib package is required to build GPAC.

To install all required packages, type:

sudo port install pkgconfig freetype libpng jpeg spidermonkey185 libsdl-devel ffmpeg faad2 libmad xvid libogg libvorbis libtheora a52dec openjpeg

WARNING: it is possible that some ports are not working for your system. In this case, you should get  the latest version of the source code of the package, and recompile it locally.

If you have configured macports to generate binaries compatible with 10.5, you must edit /opt/local/bin/sdl-config and replace the line below --cflags with the following:

echo -I${prefix}/include/SDL -D_THREAD_SAFE -arch i386

If you want to cross-compile from a 64 bits environment to a 32 bits target, you may encounter this bug with the ffmpeg package (old versions), or this bug with newer ffmpeg versions.

Brew packages

Alternately to Ports, you may want to use Brew:

brew install jpeg libpng faad2 sdl pkgconfig freetype libvorbis theora openjpeg libmad xvid libogg spidermonkey ffmpeg

Setting up UPnP (Optional)

Install Java developer package if your OSX version is > 10.6.3.

Install the Scons build system:

sudo port install scons

Get the platinum source code patched for gpac here: gpac.sourceforge.net/downloads/platinum_sdk_0.4.5.zip, and extract it.
Edit file Platinum/Platinum/Build/Targets/universal-apple-macosx/Config.scons as follows:

If building for 10.6 64bits, keep the following flags:

universal_flags = [('-arch', 'x86_64'), ('-isysroot', '/Developer/SDKs/MacOSX10.6.sdk'), '-mmacosx-version-min=10.6']

Otherwise, set the flags to:

universal_flags = [('-arch', 'i386'), ('-isysroot', '/Developer/SDKs/MacOSX10.5.sdk'), '-mmacosx-version-min=10.5']

Depending on your GCC version, you may need to edit the file Platinum/Platinum/Build/Boot.scons and replace the line

BoolVariable?('stop_on_warning', 'Stop the build on warnings', True),

with the following:

BoolVariable?('stop_on_warning', 'Stop the build on warnings', False),

then go to Platinum/Platinum and type:

scons
cp Build/Targets/universal-apple-macosx/Debug/*.a gpac/extra_lib/lib/gcc

The Platinum version used in GPAC is 0-4-5 patched for compilation under various platforms, and is unstable on Mac OS X. It may cause GPAC to crash from time to time, and will likely hang out the player upon exit. By default, UPnP module will be disabled on OS X when starting the client for the first time. You can enable it by setting the following key:

[UPnP]
Enabled=yes

or at prompt with MP4Client:
MP4Client -opt UPnP:Enabled=yes

Setting up OpenSVCDecoder (Optional)

Get the latest GPAC extra libs package.
Unzip and go to ./opensvcdecoder
Build using
cmake .
then copy the library to /opt/local/lib (or any place included in your link settings):
sudo cp ./CommonFiles/src/libOpenSVCDec.dylib /opt/local/lib

The OpenSVCDecoder in gpac_extra_libs package is version 1.11 (latest) patched for MSVC and OS X compilation.

Building gpac

Configure gpac

If you plan to generate GPAC binaries compatible with 10.5, type the following configure:

./configure --extra-cflags="-arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk" --extra-ldflags="-mmacosx-version-min=10.4 -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk"

This allows compiling a 10.5 binary with a 10.4 compatible dyld (dynamic loader).

If you don’t plan to generate GPAC binaries compatible with 10.5, type the following configure:

./configure

Build GPAC by typing

make

If you have setup UPnP, type

make -C modules/platinum

If you have setup OpenSVC decoder, type

make -C modules/opensvc_dec

Installing gpac

If you want to generate a DMG package for GPAC, regardless of 10.5 compatibility, type

./mkdmg

or

make dmg

This will produce a file called GPAC-$VERSION-r$REVISION.dmg

If you want to install GPAC directly on your system, type

sudo make install

NOTE: DO NOT RUN ./mkdmg AFTER make install, THE BINARIES WON’T BE USEABLE THROUGH THE DMG ARCHIVE. INSTEAD USE make dmg

Now you deserve a coffee, enjoy it 🙂

Compiling GPAC on Debian and Ubuntu (and other Unix distros)

⚠ The content of this page may be outdated.
Please refer to this page for more up to date information: https://github.com/gpac/gpac/wiki/GPAC-Build-Guide-for-Linux

 

Updated May 13th 2016

Introduction

Starting from a fresh Ubuntu 10.10, Ubuntu 12.04 or Debian testing 6 (Wheezy), the following steps will provide you with a fully working GPAC.

Get the source code

sudo apt-get install git
git clone https://github.com/gpac/gpac.git

Deprecated (not updated since 2014):

sudo apt-get install subversion
svn co svn://svn.code.sf.net/p/gpac/code/trunk/gpac gpac

Get the dependencies

The instructions differ depending on the linux distribution.

Ubuntu 10.10

sudo apt-get install zlib1g-dev xulrunner-1.9.2-dev libfreetype6-dev libjpeg62-dev libpng12-dev libopenjpeg-dev libmad0-dev libfaad-dev libogg-dev libvorbis-dev libtheora-dev liba52-0.7.4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libxv-dev x11proto-video-dev libgl1-mesa-dev x11proto-gl-dev linux-sound-base libxvidcore-dev libwxbase2.8-dev libwxgtk2.8-dev wx2.8-headers libssl-dev libjack-dev libasound2-dev libpulse-dev libsdl1.2-dev dvb-apps libavcodec-extra-53 libavdevice-dev

Modify the file /etc/ld.so.conf (you must be in the sudoers list), to help GPAC find Mozilla JavaScript dynamic library, by adding the line at the beginning of the file:

/usr/lib/xulrunner-1.9.2.16/

Note:Inserting the line at the end of the file may result in broken libxul dependencies since firefox 11 and the introduction of libssl3 in mozilla’s build.
Note:Ubuntu may update the xulrunner packages. Replace 1.9.2.16 by whatever your xulrunner version is.

Ubuntu 11.10

Compared to Ubuntu 10.10, the xulrunner-dev package must be replaced by firefox-dev.
Modify the file /etc/ld.so.conf setting

/usr/lib/firefox-7.0.1

The firefox version must be the same as installed on your system (it is possible that no version is included in the path, e.g. only /usr/lib/firefox/ is present) and run ldconfig to update the libraries:

sudo ldconfig

Ubuntu 12.04

sudo apt-get install make pkg-config g++ zlib1g-dev libfreetype6-dev libjpeg62-dev libpng12-dev libopenjpeg-dev libmad0-dev libfaad-dev libogg-dev libvorbis-dev libtheora-dev liba52-0.7.4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libxv-dev x11proto-video-dev libgl1-mesa-dev x11proto-gl-dev linux-sound-base libxvidcore-dev libssl-dev libjack-dev libasound2-dev libpulse-dev libsdl1.2-dev dvb-apps libavcodec-extra-53 libavdevice-dev libmozjs185-dev

Ubuntu 14.04

sudo apt-get install subversion make pkg-config g++ zlib1g-dev libfreetype6-dev libjpeg62-dev libpng12-dev libopenjpeg-dev libmad0-dev libfaad-dev libogg-dev libvorbis-dev libtheora-dev liba52-0.7.4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libavresample-dev libxv-dev x11proto-video-dev libgl1-mesa-dev x11proto-gl-dev linux-sound-base libxvidcore-dev libssl-dev libjack-dev libasound2-dev libpulse-dev libsdl1.2-dev dvb-apps libavcodec-extra libavdevice-dev libmozjs185-dev

Debian testing 6 (Wheezy)

apt-get install pkg-config g++ zlib1g-dev xulrunner-dev libfreetype6-dev libjpeg8-dev libpng12-dev libopenjpeg-dev libmad0-dev libfaad-dev libogg-dev libvorbis-dev libtheora-dev liba52-0.7.4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libxv-dev x11proto-video-dev libgl1-mesa-dev x11proto-gl-dev linux-sound-base libxvidcore-dev libssl-dev libjack-dev libasound2-dev libpulse-dev libsdl1.2-dev dvb-apps libavcodec-extra-53 libavdevice-dev

Other Unix distros

Note: we provide specific build instructions to build on MacOS X.

If the FFmpeg packages lead to errors, consider rebuilding with Zenbuild or other scripts.

We provide the extra libs as an zip package. Download it and run the compile.sh script. If you encounter an issue, please report a bug.

Compilation

cd gpac
./configure
make
sudo make install

Now you should be able to run MP4Box, MP4Client and all other apps.

Command-line GPAC compiling on Windows (x86) using free Microsoft Visual C++

⚠ The content of this page may be outdated.
Please refer to this page for more up to date information: https://github.com/gpac/gpac/wiki/GPAC-Build-Guide-for-Windows

 

Table of contents

Continue reading Command-line GPAC compiling on Windows (x86) using free Microsoft Visual C++

MP4Box: fragmentation, segmentation, splitting and interleaving

⚠ The content of this page may be outdated.
Please refer to this page for more up to date information: https://github.com/gpac/gpac/wiki/Fragmentation,-segmentation,-splitting-and-interleaving

 

NOTE: The latest documentation describing MP4Box Support for DASH is given here.

With our work on Dynamic Adaptive Streaming over HTTP (DASH), in the current version of GPAC (revision 2642 on SVN), we now have many options for interleaving, fragmenting and segmenting … which may be confusing. It is time to clarify their usage in MP4Box. Some related aspects using MPEG-2 TS instead of MP4 can be seen in this previous post.

The options are:
-inter time_in_ms (with possibly -tight) or -flat (no interleaving)
-frag time_in_ms
-dash dur_in_ms
-split time_sec (or -split-size)

Interleaving (-inter) is when (groups of ) samples of different tracks are stored alternatively in the file: e.g. N milliseconds of video samples, followed by N milliseconds of audio samples, followed by N milliseconds of video samples … Typically, interleaved samples are grouped within an interleaving window. Interleaving reduces disk accesses, playback buffer requirements and enables progressive download and playback.

Fragmentation (-frag) is an optional process applicable to the MP4 file format. By default, MP4 files generated with MP4Box are not fragmented. This process consists in using Movie Fragments (moof). Movie Fragments is a tool introduced in the ISO spec to improve recording of long-running sequences and that is now used for HTTP streaming. Even if it is possible, according to the ISO spec, to do interleaving on fragments, MP4Box currently does not support it, because we don’t see important use cases for it. For instance, all audio samples within a fragment are contiguously stored and similarly for the video samples. The only way to ‘interleave’ tracks is to have small fragments. There may be some overhead for big files, we welcome comments on this.

Segmentation (-dash) is the process of creating segments, parts of an original file meant for individual/separate HTTP download (not necessarily for individual playback). A segment can be a part of a big file or a separate file. It is not specific to the MP4 file format (in particular it may apply to MPEG-2 TS) but a segment may imply specific ISO signaling (styp and sidx boxes, for instance). A segment is what is refered to by the XML file used to drive the HTTP Streaming and segment boundaries can be convenient places for bitstream switching. Segmentation often implies fragmentation but not necessarily.

Last, MP4Box can split (-split) a file and create individual playable files from an original one. It does not use segmentation in the above sense, it removes fragmentation and can use interleaving.

Some examples of MP4Box usages:
– Rewrites a file with an interleaving window of 1 sec.
MP4Box -inter 1000 file.mp4

– Rewrites a file with 10 sec. fragments
MP4Box -frag 10000 file.mp4

– Rewrites a file (and creates the associated XML) with 10 sec. fragments and 30 sec. segments
MP4Box -frag 10000 -dash 30000 file.mp4

– Segmentation of a file into 30 sec. segment files with 10 sec. fragments (and creation of the associated XML file.mpd)
MP4Box -frag 10000 -dash 30000 -segment-name segment_file file.mp4

Interested readers can find more details about the ISO Base Media File Format specification, here.