Run MP4Box & GPAC in your browser !

Downloading...
reporting

## Console usage

This page allows running the MP4Box and GPAC applications in web browsers.

The webassembly build is experimental. It tries to uses webcodecs whenever decoding or encoding is involved. If webcodecs can't be used, it falls back to software implementation running in wasm.

Select an example and make edits, or type in your own command. Finally press `Enter` key or click the `Run` button.

Remote DASH and HLS playlists can be used as input, provided that they are hosted with proper CORS configurations.

The console also provides basic shell file system, commands to import media export media files, and support advanced gpac configuration, as described below:

### File import / export

- `imp [-d] [N]`: imports files or directory `-d` to local filesystem file.
- `imp` : imports single file to current dir using its native name
- `imp NAME` : imports single file as `NAME`
- `imp NAME/` : imports one or more files in `NAME` using their native name
- `imp -d` : imports a directory to current dir
- `imp -d NAME` : imports a directory as `NAME`
- `exp NAME`: exports given file `NAME`

IndexedDB is used for persistent storage, mounted at `/idbfs`. Typing any command will synchronize the file system.

#### Handling large files

The variable `$(NAME)` can be used to design a file not on Emscripten's file system. The file will be handled as a stream (not copied). This is the recommended methods for handling large files.

If `NAME` is an absolute URL other than `file://` scheme:

- if used for an input, it will be pulled progressively using Fetch API.
- if used for an output, it will be pushed progressively using Fetch API. If writable streams fail, the file will be stored in memory until final PUT or canceled.

Otherwise, `NAME` designs a file to be picked on the user's file system

- if used for an input, a file picker will be shown and status text will indicate the corresponding `NAME`
- if used for an output, a file saver will be shown with the given `NAME`. If writable stream failure, the file will be stored in memory until final write or canceled.

For output files, the extension will be used to derive the output format, e.g. `($file.ts)` will use MPEG-2 TS. Use `$(file):ext=ts` to override format if desired. This syntax CANNOT work when editing files (MP4Box, dasher context, etc...).

### Shell commands

- `↑``↓` : Use up & down arrows can be used for command history.
- `ls [N]`: list files in `N` or in current directory if `N` not set or print file N info - use 'ls -l N' for details.
- `cd [NAME]`: changes current working directory, use Emscripten home if `NAME` not provided
- `cwd`: prints current working directory
- `clear`: clears console output
- `mkdir NAME`: creates directory `NAME`
- `rm NAME`: removes file or empty directory `NAME`
- `mv N1 N2`: moves file `N1` to `N2`
- `cp N1 N2`: copies file `N1` to `N2` (no recursive copy support)
- `show NAME`: shows content of file `NAME`
- `edit NAME`: edits content of file `NAME`, use `save` to save and close, `close` to discard and close

### Configuration commands

- `worker`: toggles worker mode on or off (off)
- `threads`: views number of pre-allocated workers
- `stack`: prints available size in stack
- `clearh [N]`: clears command history. If `N` is set, only keeps last `N` items, otherwise clears everything
- `fetch`: toggles fetch support in libgpac
- `bsize`: sets block size used to read from local disk (default 10000)
- `eval`: evaluates JS code

#### Performances

The default behaviour for gpac app is to run on the browser/worker main loop in non-blocking mode, running the session at most 100 times before returning control.

This can be configured when calling gpac (see `gpac -hx`), for example:

- `-step=-1` will block the main browser/worker thread (WILL DEADLOCK if some filters use JS promises or other async tools)
- `-step=0` will use browser defaults for requestAnimationFrame frequency
- `-step=100` will request callback every 10 ms
- `-step=100:1000` will request callback every 10 ms, calling at most 1000 times the session

When running without worker, internal threading of filters (e.g. ffmpeg & co) will be disabled if the session runs only on the main thread.

Use `-threads=N` with `N` > 0 (typically `-threads=1`) to enable threading in these filters.