Category Archives: Tutorial

GPAC: build MP4Box only (all platforms)

⚠ 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/Build-Introduction 

For each platform you’ll find instructions for building MP4Box only or the whole GPAC suite.

 

Dear readers,

As many of you know, GPAC is a full framework providing authoring tools, packagers, streamers, a player and now some js stuff. This can make GPAC cumbersome to build.

However many of you are mainly interested in MP4Box which is easy to build. Whether you are on Linux, Windows or MacOS, here is the definite guide to build MP4Box easily 🙂

Edit 2015/11/03: added MSVC MP4Box minimal build.

Build MP4Box with Visual Studio

We published a minimal solution to build MP4Box.exe only, with zero dependency. No DLL to distribute.

You need Visual Studio 2010 or more recent (a pop-up will ask you to upgrade your projects, just accept). Open build/msvc10/gpac_mp4box_mini.sln and build (Debug or Release).

That’s all!

Build MP4Box with Make

On your system, you need the following tools installed on your system:

  • git
  • gcc
  • make
  • libpthread-dev (should be available on any development system)

In your favorite terminal, type:

git clone https://github.com/gpac/gpac.git
cd gpac
./configure --static-mp4box --use-zlib=no
make -j4

To execute MP4Box, assuming you are still in the same directory (i.e. the root of the GPAC repository), you will find the MP4Box executable at:

bin/gcc/MP4Box

To install MP4Box on your system:

sudo make install

Check installation

now when you type

$ which MP4Box

you should see

/usr/local/bin/MP4Box

which is the default install folder for the version we have just built. You can tweak this with the ‘-prefix=’ configure option.

If you see /usr/bin/MP4Box (no “local/” in here), uninstall GPAC from your local packager. On MacOS, go to Finder and unmount the app on the left panel, or uninstall it from your package manager (‘port’ or ‘homebrew’ or ‘fink’).

Update to a newer revision

Of course you want to keep updated with the latest build without having to download the full repository again or re-execute the configuration when not necessary (it may be necessary sometimes, see below “Clean your build” if things go unexpectedly):

cd gpac
git pull
make -j4
sudo make install

That’s all!

Clean your build

If things go wrong and you suspect there is an issue in your configuration, the fastest way to restart a clean build is:

cd gpac
make distclean
./configure --static-mp4box --use-zlib=no
make -j4

Cross-compilation

Cross-compiling GPAC is quite standard, and requires only a modification at the ‘configure’ step. Use ‘–extra-cflags=’ and ‘–extra-ldflags=’ to add your environmment flags:

cd gpac
./configure --target-os=$OS --cross-prefix="$crossPrefix" --extra-cflags="-I$PREFIX/$host/include" --extra-ldflags="-L$PREFIX/$host/lib" --prefix=$PREFIX/$host --static-mp4box --use-zlib=no
make -j4

For example, to use the ‘x86_64-w64-mingw32’ toolchain to cross-build from Linux to Windows:

cd gpac
./configure --target-os=mingw32 --cross-prefix=x86_64-w64-mingw32- --prefix=build/x86_64-w64-mingw32 --static-mp4box --use-zlib=no --extra-cflags="-Ibuild/x86_64-w64-mingw32/include" --extra-ldflags="-Lbuild/x86_64-w64-mingw32/lib"
make -j4

You can find more examples in our TravisCI script.

Next Step

We have started a multimedia component-level build system called Zenbuild. Zenbuild builds FFmpeg/libav, VLC or GPAC with most of their features enabled (librtmp, jack, openHEVC, etc.). You can start using Zenbuild, it is fully operational!

Using GDB in Visual Studio

Dear followers,

One of the target platform for GPAC is Windows. Developing for Windows in a comfortable manner requires Visual Studio, in particular for debugging. Microsoft recently announced great changes that will make Visual Studio users (including the GPAC developers) happy:

Edit: update from Microsoft on 2015/11/18.

Setup for local debugging

Install software:

  • Install Visual Studio 2015. Install the “Tools for Visual C++ Mobile Development” in a sub-menu (disabled by default).
  • Install gdb/gdbserver. Use MinGW-w64 binaries and put them in your PATH (you can rely on the excellent MSYS2 for a full development environment).
    /!\ Legacy MinGW and Cygwin gdb binaries are known to fail /!\

Build:

  • Use your usual build system and gcc or clang compiler. Don’t forget to enable debugging!

Debugging:

  • In your command-line, launch:
    gdbserver host:port path/to/executable
  • In Visual Studio:
    • Open the “command window” (either press CTRL+ALT+A or click: View menu -> Other Windows -> Command Window)
    • Launch:
      Debug.GDBLaunch /Executable:path\to\executable /GDBPath:path\to\gdb.exe /GDBServerAddress:host:port /TargetArchitecture:x64

That’s all! Once Debug.GDBLaunch is attached your program will run. Breakpoints are effective. And you can enjoy the Visual Studio debugging experience:

20150610_msvs_gdb

Setup for remote debugging

This is an extension of the gdbserver we used above.  It allows to debug mobile (android/iOS) or any platform (linux, …) executables from a remote

For specific remote parameters, see:

Use MP4Box to dump and analyze broadcast TS streams

⚠ 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/Use-MP4Box-to-dump-and-analyze-broadcast-TS-streams

 

Today I want to share with you a few tips regarding MP4Box. MP4Box can manipulate MP4 files, but it has also capabilities regarding broadcast streams.

Dump a broadcast TS in a file

Command syntax:

MP4Box -grab-ts udp://ip_adress:port dump.ts

For example:

MP4Box -grab-ts udp://239.0.0.1:8000 dump.ts

Dump from a specific network interface

MP4Box (and also other GPAC tools such as the MP4Client player) provides a ‘-ifce’ option:

MP4Box -grab-ts udp://ip_adress:port -ifce ip_address dump.ts

Use ‘ifconfig’ (Unix) or ‘ipconfig’ (Windows) to retrieve your IP address on the interface of your choice. Example:

MP4Box -grab-ts udp://239.0.0.1:8000 -ifce 192.168.1.1 dump.ts

Troubleshoot Windows: MP4Box (or any tool) cannot dump my multicast

1) Clicking the Start button and then click on Control Panel. In the search box, type firewall, and then click Windows Firewall.

2) On the left panel, click on “Allow a program or feature through the Windows Firewall”.

3) Make sure all columns are checked for your MP4Box programs.

Enjoy 🙂

How to file a bug properly

Please note, this page has been updated. The latest info can be found here.

GPAC is becoming quite a large piece of software and, unfortunately despite our care, is not bug-free… This is where you, as GPAC users, can help. If you discover a problem, you can report it using our GitHub bug tracker (old bugs were in our Sourceforge bug tracker ) .

Filing a bug, if this is done well, is the best way to ensure that the problem will be fixed. However, if the bug is not filed correctly, it is the best way to ensure that it won’t get fixed. This post gives guidelines on how to file a bug, properly. Continue reading How to file a bug properly

JPEG support for Android: resolving libjpeg.so conflicts

When porting GPAC to Android (2.3 as of today), we’ve been facing a very strange and annoying problem: JPEG images didn’t load, and libjpeg was outputing the following message:

JPEG parameter struct mismatch: library thinks size is 480,
 caller expects 520

We couldn’t find any relevant help on the Web. Discussions always ended up with no response or even some “you don’t understand what you’re doing”. The thing is we have understood and solved the problem.

First, the GPAC Android package (generated as mentionned in the README.txt file) does contain its own libjpeg.so file. The libjpeg.so file is generated from the extra_libs package. When running the Android Osmo4 player within the Eclipse debugger, the Dalvik console prints the following message:

INFO/LibrariesLoader(294): Loading library jpeg...
DEBUG/dalvikvm(294): No JNI_OnLoad found in
  /data/data/com.gpac.Osmo4/lib/libjpeg.so 0x44ede8f0, skipping init
DEBUG/dalvikvm(294): Added shared lib
  /data/data/com.gpac.Osmo4/lib/libjpeg.so 0x44ede8f0

Don’t trust it.

There is a conflict between your local libraries and the ones provided by Android. Google’s dynamic libraries are always loaded first as of Android 2.3. This is annoying because this affects numerous programs and also other dynamic libraries (such as zlib, libpng, …). We could confirm our hypothesis by changing the error messages printed by our own libjpeg.so: it didn’t match the error message showing in the Dalvik console.

The best solution we found is to rename the dynamic library to a non-usual name. libjpeg.so is now named libjpegdroid.so for the GPAC package.

You can find more info on GPAC running on Android from here or watch the following video:

[youtube]http://www.youtube.com/watch?v=himalbWpga4[/youtube]

Romain Bouqueau, Stephane Thomas