gaspard7/wiki_gpac huggingface dataset:
Use an image

You can either use your own image if you built it (see section above), or use pre-built images from Docker Hub. 

To get a pre-build image, use: 

```bash
docker pull gpac/ubuntu
```

You can use the gpac image a number of way. 

### Get the build artifacts

The image contains binaries for: 
- a minimal statically linked executable for MP4Box and gpac CLI tools
- deb packages for the OS used in the image (currently Ubuntu 22.04)

You can use these binaries on your host OS if it is relevant.

You can extract these binaries with 

```bash
$ docker create --name dummy gpac/ubuntu
$ docker cp dummy:/gpac/binaries .
$ docker rm dummy

$ ls -1 binaries/

gpac
gpac_2.3-DEV-rev351-gba47abf5a-docker_amd64.deb
libgpac-dev_2.3-DEV-rev351-gba47abf5a-docker_amd64.deb
libgpac_static.a
MP4Box


$ ./binaries/gpac

Refreshing all options registry, this may take some time ... done
gpac - GPAC command line filter engine - version 2.3-DEV-rev351-gba47abf5a-docker
(c) 2000-2023 Telecom Paris distributed under LGPL v2.1+ - http://gpac.io
        MINI build (encoders, decoders, audio and video output disabled)

Please cite our work in your research:
        GPAC Filters: https://doi.org/10.1145/3339825.3394929
        GPAC: https://doi.org/10.1145/1291233.1291452

```


### Run gpac inside of container

Once you have a gpac image, you can run commands directly inside of a container. 

Examples: 

```bash
$ docker run --rm gpac/ubuntu MP4Box -version

[core] Creating default credential key in /root/.gpac/creds.key, use -cred=PATH/TO_FILE to overwrite
MP4Box - GPAC version 2.3-DEV-rev345-gc7c404d8f-master
(c) 2000-2023 Telecom Paris distributed under LGPL v2.1+ - http://gpac.io

Please cite our work in your research:
        GPAC Filters: https://doi.org/10.1145/3339825.3394929
        GPAC: https://doi.org/10.1145/1291233.1291452

GPAC Configuration: --host=x86_64-linux-gnu --prefix=/usr --build=x86_64-linux-gnu --extra-cflags=-Wall -g -fPIC -DPIC --cc=ccache cc CXX=ccache g++
Features: GPAC_CONFIG_LINUX GPAC_64_BITS GPAC_HAS_IPV6 GPAC_HAS_SSL GPAC_HAS_SOCK_UN GPAC_MINIMAL_ODF GPAC_HAS_QJS GPAC_HAS_FAAD GPAC_HAS_MAD GPAC_HAS_LIBA52 GPAC_HAS_JPEG GPAC_HAS_PNG GPAC_HAS_FFMPEG GPAC_HAS_OPENSVC GPAC_HAS_OPENHEVC GPAC_HAS_THEORA GPAC_HAS_VORBIS GPAC_HAS_LINUX_DVB  


$ docker run --rm gpac/ubuntu gpac -i http://download.tsi.telecom-paristech.fr/gpac/gpac_test_suite/mp4/counter_video_360.mp4 inspect

[core] Creating default credential key in /root/.gpac/creds.key, use -cred=PATH/TO_FILE to overwrite
Refreshing all options registry, this may take some time ... done
PID 1 video duration 10:00.000 timescale 25000 640x360 fps 25 SAR 1/1 193 kbps 15000 frames codec avc1.42C01E AVC|H264 PL Baseline@3 YUV 4:2:0 8 bpp
map a local folder to the container to read/write

$ docker run --rm -v ./vids:/vids gpac/ubuntu gpac -i /vids/counter_video_360.mp4 -o /vids/test.mpd
$ cat vids/test.mpd

<?xml version="1.0"?>
<!-- MPD file Generated with GPAC version 2.3-DEV-rev345-gc7c404d8f-master at 2023-06-14T14:22:59.640Z -->
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" minBufferTime="PT1.000S" type="static" mediaPresentationDuration="PT0H10M0.000S" maxSegmentDuration="PT0H0M1.000S" profiles="urn:mpeg:dash:profile:full:2011">
 <ProgramInformation moreInformationURL="http://gpac.io">
  <Title>test.mpd generated by GPAC</Title>
 </ProgramInformation>

 <Period duration="PT0H10M0.000S">
  <AdaptationSet segmentAlignment="true" maxWidth="640" maxHeight="360" maxFrameRate="25" par="16:9" startWithSAP="1">
   <SegmentTemplate media="counter_video_360_dash$Number$.m4s" initialization="counter_video_360_dashinit.mp4" timescale="25000" startNumber="1" duration="25000"/>
   <Representation id="1" mimeType="video/mp4" codecs="avc1.42C01E" width="640" height="360" frameRate="25" sar="1:1" bandwidth="193112">
   </Representation>
  </AdaptationSet>
 </Period>
</MPD>
```



### Use a container as a dev or runtime environement

Finally you can simply run a container and use it as an environement where you can run gpac commands, modify and build gpac, or develop programs built again libgpac. 


```bash
$ docker run -it gpac/ubuntu bash

root@6610e278322e:/gpac/gpac_public# make distclean && ./configure --enable-debug && make -j && make install
root@6610e278322e:/gpac/gpac_public# MP4Box -version

MP4Box - GPAC version 2.3-DEV-rev351-gba47abf5a-docker
(c) 2000-2023 Telecom Paris distributed under LGPL v2.1+ - http://gpac.io

Please cite our work in your research:
        GPAC Filters: https://doi.org/10.1145/3339825.3394929
        GPAC: https://doi.org/10.1145/1291233.1291452

GPAC Configuration: --enable-debug
Features: GPAC_CONFIG_LINUX GPAC_64_BITS GPAC_HAS_IPV6 GPAC_HAS_SSL GPAC_HAS_SOCK_UN GPAC_MINIMAL_ODF GPAC_HAS_QJS GPAC_HAS_FAAD GPAC_HAS_MAD GPAC_HAS_LIBA52 GPAC_HAS_JPEG GPAC_HAS_PNG GPAC_HAS_FFMPEG GPAC_HAS_OPENSVC GPAC_HAS_OPENHEVC GPAC_HAS_THEORA GPAC_HAS_VORBIS GPAC_HAS_LINUX_DVB   
```
Set up

1. Install [Homebrew](https://brew.sh/)

2. Install tools

```bash
brew install cmake scons coreutils gettext yasm git wget pkg-config
```

3. Install dependencies

```bash
brew install freetype jpeg libpng openjpeg mad faad2 libogg libvorbis theora a52dec ffmpeg x264 aom xvid openssl@1.1 sdl2
```


<hr>

***For older MacOS versions***: if Homebrew is unavailable, the same can be achieved with [MacPorts](https://www.macports.org/) with the following packages

```bash
Build dependencies

```bash
deps_unix$ ./build_all.sh osx
```

If all went well, you should see something like this in the main repository: 

```bash
mojave:deps_unix adavid$ ll ../gpac_public/extra_lib/lib/gcc/
total 42784
-rw-r--r--  1 adavid  staff   2.9M Apr  2 14:43 libNeptune.a
-rw-r--r--  1 adavid  staff   890K Apr  2 15:47 libOpenSVCDec.a
-rw-r--r--  1 adavid  staff   4.1M Apr  2 14:43 libPlatinum.a
-rw-r--r--  1 adavid  staff   383K Apr  2 14:43 libPltMediaConnect.a
-rw-r--r--  1 adavid  staff   530K Apr  2 14:43 libPltMediaRenderer.a
-rw-r--r--  1 adavid  staff   1.5M Apr  2 14:43 libPltMediaServer.a
-rw-r--r--  1 adavid  staff   192K Apr  2 14:43 libZlib.a
-rw-r--r--  1 adavid  staff   259K Apr  2 14:43 libaxTLS.a
-rw-r--r--  1 adavid  staff   3.3M Apr  2 15:15 libjs.a
-rw-r--r--  1 adavid  staff   4.3M Apr  2 15:50 libopenhevc.a
-rw-r--r--  1 adavid  staff   166K Apr  2 15:50 libopenjpeg.a
```

_(contents and versions may differ depending on updates and deprecated features)_
if you built the threaded version of the deps

export PKG_CONFIG_PATH=/path/to/deps_wasm/wasm_thread/lib/pkgconfig

```

Then we can build GPAC with emscripten:

```bash
git clone https://github.com/gpac/gpac.git
cd gpac

#for gpac unthreaded
./configure --emscripten --disable-threads --extra-cflags='-Wno-pointer-sign -Wno-implicit-const-int-float-conversion'

#for gpac threaded
./configure --emscripten --extra-cflags='-Wno-pointer-sign -Wno-implicit-const-int-float-conversion'

make -j4
```

You can then find the built files in the `bin/gcc/` folder.
you can use an existing cert, or generate one with letsencrypt, or here we generate a self-signed certificate:

openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -sha256 -days 3650 -nodes -subj "/C=XX/ST=StateName/L=CityName/O=CompanyName/OU=CompanySectionName/CN=CommonNameOrHostname"
Apache example

For Apache, you need to add some settings for the webserver, either in a `.htaccess` file, or in the apache config:

```
    DirectoryIndex gpac.html
    Options FollowSymLinks Indexes
    AllowOverride All

    Header set Access-Control-Allow-Origin "*"
    Header set Access-Control-Expose-Headers "*"
    Header set Cross-Origin-Embedder-Policy "require-corp"
    Header set Cross-Origin-Opener-Policy "same-origin"

    AddType application/wasm wasm
    AddType application/javascript js
```

You can then access the gpac.html through the web server to use GPAC WASM.

For the threaded version you'll have to serve through https for it to work properly.
Resources

For more info, you can check how the official gpac wasm builder runs at [https://buildbot.gpac.io/#/builders/27](https://buildbot.gpac.io/#/builders/27)

And you can check the official live gpac wasm build at [https://wasm.gpac.io](https://wasm.gpac.io)

For issues and support, go to [https://github.com/gpac/gpac/labels/wasm](https://github.com/gpac/gpac/labels/wasm)
Copy dependencies

Then continuing from the `build/xcode_ios` folder:

```bash
cd ../..
./CopyLibs2Public4iOS.sh
```

If all went well, the extra_lib directory of the main repository should now look something like this: 

```bash
mojave:deps_ios adavid$ ll ../gpac_public/extra_lib/lib/iOS/
total 358808
-rw-r--r--  1 adavid  staff   6.3M Apr  2 16:16 libSDL2.a
-rw-r--r--  1 adavid  staff    27M Apr  2 16:16 libaom.a
-rw-r--r--  1 adavid  staff    54M Apr  2 16:16 libavcodec.a
-rw-r--r--  1 adavid  staff   199K Apr  2 16:16 libavdevice.a
-rw-r--r--  1 adavid  staff    10M Apr  2 16:16 libavfilter.a
-rw-r--r--  1 adavid  staff    12M Apr  2 16:16 libavformat.a
-rw-r--r--  1 adavid  staff   1.8M Apr  2 16:16 libavutil.a
-rw-r--r--  1 adavid  staff    35M Apr  2 16:16 libcrypto.a
-rw-r--r--  1 adavid  staff   1.5M Apr  2 16:16 libfaad.a
-rw-r--r--  1 adavid  staff   4.6M Apr  2 16:16 libfreetype.a
-rw-r--r--  1 adavid  staff   596K Apr  2 16:16 libglues.a
-rw-r--r--  1 adavid  staff   1.8M Apr  2 16:16 libjpeg.a
-rw-r--r--  1 adavid  staff   8.1M Apr  2 16:16 libjs.a
-rw-r--r--  1 adavid  staff   428K Apr  2 16:16 libmad.a
-rw-r--r--  1 adavid  staff   1.1M Apr  2 16:16 libpng.a
-rw-r--r--  1 adavid  staff   7.3M Apr  2 16:16 libssl.a
-rw-r--r--  1 adavid  staff   526K Apr  2 16:16 libswresample.a
-rw-r--r--  1 adavid  staff   2.4M Apr  2 16:16 libswscale.a
```
Build GPAC

First we need to set up the code signing process in Xcode. 

Open `<GPAC_ROOT_DIR>/gpac_public/build/xcode/gpac4ios.xcodeproj` in Xcode.

On the `osmo4ios` _General_ properties page, in the _Signing_ section, you'll need to assign a _Provisioning Profile_ and/or maybe change the _Bundle identifier_ in the identity section.

See the Xcode documentation about Provisioning Profiles and code signing. 

Close `gpac4ios.xcodeproj` project in Xcode.

Once this is done, you can run:

```bash
<GPAC_ROOT_DIR>/gpac_public/build/xcode$ ./generate_ios.sh
```

If successful, you should see an `.ipa` file in `<GPAC_ROOT_DIR>/gpac_public/bin/iOS`.

```bash
mojave:iOS adavid$ ll
total 42536
-rw-r--r--  1 adavid  staff    21M Apr  2 16:48 osmo4-0.7.2-DEV-rev1049-g51dadae6c-master-ios.ipa
```
Build MP4Box only

To build only the MP4Box command line utility, you will need to:

1. Get the source

```batch
git clone https://github.com/gpac/gpac.git gpac_public
```

2. Open the "Developer Command Prompt for VS 2015" (or equivalent)

It might be called something else depending on your version of Visual Studio. The goal is to be able to run the `msbuild.exe` command.

3. Run 

```batch
> cd gpac_public\build\msvc14
> msbuild.exe gpac.sln /maxcpucount /t:Rebuild /p:Configuration="Release - MP4Box_only" /p:Platform=x64 /p:PlatformToolset=v140 /p:WindowsTargetPlatformVersion=8.1
```

<a name="toolset"></a>
You can adjust the parameters: 
 - `/p:Platform=x64`: Change to `/p:Platform=Win32` to get a 32 bits build
 - `/p:PlatformToolset=v140` and `/p:WindowsTargetPlatformVersion=8.1`: Change this depending on your Visual Studio version and the Windows SDK version you have installed.
 -  (e.g.: `/p:PlatformToolset=v143 /p:WindowsTargetPlatformVersion=10.0` for VS 2022 on Windows 10)
 
 You can find out what versions you have by opening the gpac.sln solution in Visual Studio, opening the property page of one the project, and checking the "Platform Toolset" and "Windows SDK Version" fields. 

 Alternatively, you can build with the Visual Studio GUI. If needed, use the "Retarget Solution" function (by right-clicking on the solution in the Solution Explorer) to adjust the Windows SDK version. 

4. The binary `MP4Box.exe` will be `bin\x64\Release - MP4Box_only`

You can add this directory to your `PATH` environment variable. Or move the binary to a destination in your `PATH`. Or just use it locally.
get dependencies

<GPAC_ROOT_DIR> > git clone https://github.com/gpac/deps_windows
<GPAC_ROOT_DIR> > cd deps_windows
<GPAC_ROOT_DIR>\deps_windows > git submodule update --init --recursive --force --checkout
```

Naming the main gpac source repository `gpac_public` is important because some subsequent scripts will have this name hard-coded. (If you don't want to do that, you can find instances of "gpac_public" in the deps_windows repository and replace them with whatever your set up is.)
Building dependencies

If you plan on compiling the xvid dependency, make sure you have [NASM](https://nasm.us/) installed.

Open the "Developer Command Prompt for VS 2015" (or equivalent in your install). 

Run:

```batch
<GPAC_ROOT_DIR>\deps_windows > cd build\msvc
<GPAC_ROOT_DIR>\deps_windows\build\msvc > msbuild.exe BuildAll_vc10.sln /maxcpucount /t:Build /p:Configuration=Release /p:Platform=x64 /p:PlatformToolset=v140 /p:WindowsTargetPlatformVersion=8.1
```

See the [remarks above to adjust the parameters](#toolset).
Building GPAC

Now that all dependencies have been set up, we can be build GPAC proper by simply running, inside a Developer Command Prompt:

```batch
<GPAC_ROOT_DIR>\gpac_public\build\msvc14 > msbuild.exe gpac.sln /maxcpucount /t:Rebuild /p:Configuration=Release /p:Platform=x64 /p:PlatformToolset=v140 /p:WindowsTargetPlatformVersion=8.1
```

See the [previous remarks about how to adjust the toolset options](#toolset).

Of course you can also open the `gpac.sln` solution in the Visual Studio GUI and build/debug from there. In Visual Studio you can use right-click on the gpac solution > "Retarget Solution" to adjust the SDK and toolset parameters according to your system. 

The binaries will be in 
```batch
<GPAC_ROOT_DIR>\gpac_public\bin\<PLATFORM>\<CONFIGURATION>
```

(e.g. `<GPAC_ROOT_DIR>\gpac_public\bin\x64\Release`)

You can add this to your `PATH` to run it from anywhere.
Packaging GPAC (optional)

If you want to generate your own GPAC installer, you will first need to install [NSIS](https://nsis.sourceforge.io/Download).

You can then run:

```batch
<GPAC_ROOT_DIR>\gpac_public > generate_installer.bat x64
```

If you want to generate an installer from not committed/pushed changes, you might have to edit the script to remove this check.
JVM and tools

We first install the JAVA runtime and development environment, and some useful libs for later: 

```bash
sudo apt-get install openjdk-8-jdk openjdk-8-jre-headless ant libncurses5 libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386 autoconf automake libtool 
```
Android SDK

We start by downloading the latest Android Tools from https://developer.android.com/studio#downloads. 

We then use the `sdkmanager` included to install the right version of the SDK. 

Then we create a symbolic link to `/opt/android-sdk` for ease of use later. 

```bash
<GPAC_ROOT_DIR>$ mkdir sdk
<GPAC_ROOT_DIR>$ cd sdk
<GPAC_ROOT_DIR>/sdk$ wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
<GPAC_ROOT_DIR>/sdk$ unzip sdk-tools-linux-4333796.zip
<GPAC_ROOT_DIR>/sdk$ cd tools
<GPAC_ROOT_DIR>/sdk/tools$ bin/sdkmanager "platforms;android-23"
<GPAC_ROOT_DIR>/sdk/tools$ bin/sdkmanager "build-tools;23.0.3"
<GPAC_ROOT_DIR>/sdk/tools$ bin/sdkmanager "extras;android;m2repository"
<GPAC_ROOT_DIR>/sdk/tools$ cd ../..
<GPAC_ROOT_DIR>$ sudo ln -sf $(readlink -f ./sdk) /opt/android-sdk
```
Android NDK

The version here is important. 

```bash
<GPAC_ROOT_DIR>$ mkdir ndk
<GPAC_ROOT_DIR>$ cd ndk
<GPAC_ROOT_DIR>/ndk$ wget https://dl.google.com/android/repository/android-ndk-r22b-linux-x86_64.zip
<GPAC_ROOT_DIR>/ndk$ unzip android-ndk-r22b-linux-x86_64.zip
<GPAC_ROOT_DIR>/ndk$ sudo ln -sf $(readlink -f ./android-ndk-r22b) /opt/android-ndk
```

We should now have something like this in `/opt`:

```bash
adavid@ubuntu1810:~/gpac-android$ ll /opt/
total 8
lrwxrwxrwx  1 root root   41 avril  1 16:14 android-ndk -> /home/adavid/gpac-android/ndk/android-ndk-r13b/
lrwxrwxrwx  1 root root   24 avril  1 16:15 android-sdk -> /home/adavid/gpac-android/sdk/
```
Get the source

```bash
##get src
<GPAC_ROOT_DIR>$ git clone https://github.com/gpac/gpac.git gpac_public

##get deps
<GPAC_ROOT_DIR>$ git clone https://github.com/gpac/deps_android
<GPAC_ROOT_DIR>$ cd deps_android
<GPAC_ROOT_DIR>/deps_android$ git submodule update --init --recursive --force --checkout
```

Note that keeping the name `gpac_public` for the main source repository is important for scripts to run smoothly.
Build GPAC

We are now ready to build GPAC proper. 

```bash 
<GPAC_ROOT_DIR>/deps_android$ cd ../gpac_public/build/android/jni
<GPAC_ROOT_DIR>/gpac_public/build/android/jni$ ./gpac_build_android -ndk=/opt/android-ndk -sdk=/opt/android-sdk -jdk=/usr/lib/jvm/java-8-openjdk-amd64 -force_rebuild
```

If it succeeds, you should see the apk in `<GPAC_ROOT_DIR>/gpac_public`:

```
adavid@ubuntu1810:~/gpac-android/gpac_public$ ll *.apk
-rw-rw-r-- 1 adavid adavid 30745262 avril  2 14:53 osmo4-0.7.2-DEV-rev1048-g38ab344d4-master.apk
```

You can now install the apk on your device!
Introduction

Assume you have one or several sources dispatching data in a non real-time fashion, such as a local file, an HTTP download or a pipe input. You may want to produce data in real-time, for DASH, HLS, MPEG-2 TS or HTTP delivery. 
GPAC comes with the [reframer](reframer) filter, in charge of forcing a de-multiplexing of input data. This filter supports several features including:

- discarding frames based on their SAP type (e.g. build a stream containing only I-frames of the input stream)
- force decoding of media data
- and real-time regulation
Foreword

The reframer usually produces output PIDs with the same configuration as input PIDs. This means that you must take care of graph connection when setting up your filter chain.
This is true for GPAC prior to 2.0 or when using complete mode linking [-cl](gpac_general#cl), see [linking documentation](filters_general#filter-linking-link).
```
gpac [-cl] -i source.mp4 reframer -o dest.mp4 -graph
```

In this example, the `source.mp4` input will produce a PID of type `FILE`, which will be directly connected to the `dest.mp4` output, and the reframer will simply not be connected:

```
Filters connected:
fin (src=source.mp4) (0x7f87e640c360)
-(PID source.mp4) fout (dst=dest.mp4) (0x7f87e640cc20)
Filters not connected:
reframer (0x7f87e640c640)
```

Before GPAC 2.0 you needed to specify a link between reframer and output, so that the output does not accept PIDs coming directly from the source:

```
gpac [-cl] -i source.mp4 reframer @ -o dest.mp4 -graph
gpac [-cl] -i source.mp4 reframer:FID=1 -o dest.mp4:SID=1 -graph
```


This is no longer needed for implicit linking mode (default one) of GPAC 2.0:
```
gpac -i source.mp4 reframer -o dest.mp4 -graph
```

The graph is now properly loaded:
```
Filters connected:
fin (src=source.mp4) (0x7f9662509340)
-(PID source.mp4) mp4dmx (0x7f966250ac00)
--(PID PID1) reframer (_0x7f9662509620_)
---(PID PID1) mp4mx (0x7f9662406860)
----(PID PID1) fout (dst=dest.mp4) (0x7f9662509bd0)
```


The reframer real-time mode is enabled by the [rt](reframer#rt) option.
Sync regulation

In this example, we regulate the session with a single real-time clock for all PIDs handled by the reframer:

```
gpac -i source.mp4 reframer:rt=sync -o dest.mp4
```

The PIDs share a single time base: the first frame of each PID will be first be probed, the first frame with the earliest time will be dispatched as soon as received, and all other frames will be delivered according to their timestamp and the system clock at first dispatched frame.
DASH Low Latency example

In this example, we use a local source to generate a low-latency DASH session. Since in low-latency mode, a segment is divided in several subsegments (e.g. CMAF chunks), not using a real-time regulation would produce all these subsegments way too early. Injecting the reframer allows the subsegments to be dispatched only when the last frame of the subsegment is produced.

```
gpac -i source.mp4 reframer:rt=sync -o live.mpd:dur=2:cdur=0.1:dmode=dynamic:profile=live
```

If we now want to simulate a forever running session, we just need to change the source to use the [file list](flist) filter:

```
gpac flist:srcs=source.mp4:floop=-1 reframer:rt=sync -o live.mpd:dur=2:cdur=0.1:dmode=dynamic:profile=live
```
Icecast-like server

In this example, we use a local playlist to generate an icecast server. If we don't inject a real-time regulation, the server will:

- drop all packets way too fast when no client is connected
- send all packets way too fast when clients are connected

```
gpac -i playlist.m3u:floop=-1 reframer:rt=on -o http://localhost:8080/
```

Note that in this example we loop the playlist, but as discussed [here](flist#playlist-mode), we could also override the playlist with new content on regular basis.
When Real-time reframer is NOT needed

Some output formats may perform their own real-time regulation, without needing the [reframer](reframer) filter: 
- [RTP](rtpout) and [RTSP](rtspout) always stream in real-time.
- [MPEG-2 TS multiplexer](m2tsmx) will perform real-time regulation when invoked with [realtime](m2tsmx#realtime) option.
- [DASHing](dasher) in [dynamic mode](dasher#dmode) [sreg](dasher#sreg) option set will perform regulation of segments, so no reframer is needed if you don't want low latency DASH.
- [socket](sockout) output may regulate its throughput using the [rate](sockout#rate) option.
Overview {: data-level="all" }

We discuss here how to use the [MP4Box](MP4Box-introduction) together with filters in GPAC.

As discussed [here](Rearchitecture), the following features of MP4Box are now using the GPAC filter engine:

- Media importing
- Media exporting
- DASHing
- Encryption
- File splitting

At the time being, only media importing and DASHing operations can be extended to use other filters.
Customizing source and mux parameters {: data-level="beginner" }

It is possible to provide additional parameters to both source and destination during an import operations. Most MP4Box parameters are mapped to the filter engine and they have roughly the same names, but the opposite is not true (i.e. most options of the various filters in GPAC are not mapped as MP4Box options). 
- source options are declared using `:sopt:` separator
- multiplexer options are declared using `:dopt:` separator
 
All regular MP4Box options must be given before any `sopt` or `dopt`.

```
MP4Box -add source.264:sopt:blocksize=20k:dopt:maxchunk=1M -new file.mp4
```

The above command will instruct the [source](fin) to use a block size of 20k and the [destination](mp4mx) to limit the chunk size of the imported track to 1M.

As discussed [here](core_config#global-filter-options), you can pass these options as global parameters if you import a single source or if you want the option to apply to all sources:
```
MP4Box -add source.264 --blocksize=20k --maxchunk=1M -new file.mp4
```


__Discussion__   
Any option for sources can be used, see the general [filter documentation](filters_general). The importer works by using the [mp4 multiplexer](mp4mx) filter in sink mode using the file specified as output for MP4Box.
The filter graph can be seen by using the `fgraph` option:

```
MP4Box -add source.aac:fgraph -new file.mp4

Filters connected:
fin (src=source.aac:gpac:importer:index_dur=0:FID=1) (1)
-(PID source.aac) rfadts (0x7fca97d0e430)
--(PID source.aac) mp4mx (importer:file=0x7fca97e03cb0:SID=1#PID=1) (0x7fca97d080d0)
```

The filter statistics can be seen by using the `fstat` option:

```
MP4Box -add source.aac:fstat -new file.mp4
```