## mp4mux mp4mux — Muxer for ISO MPEG-4 (.mp4) files |

## Properties

GstQTMuxDtsMethods | dts-method | Read / Write / Construct
gboolean | faststart | Read / Write
gchar * | faststart-file | Read / Write / Construct
guint | fragment-duration | Read / Write / Construct
gchar * | moov-recovery-file | Read / Write / Construct
guint | movie-timescale | Read / Write / Construct
gboolean | presentation-time | Read / Write / Construct
gboolean | streamable | Read / Write / Construct
guint | trak-timescale | Read / Write / Construct
guint | reserved-bytes-per-sec | Read / Write / Construct
guint64 | reserved-duration-remaining | Read
guint64 | reserved-max-duration | Read / Write
guint64 | reserved-moov-update-period | Read / Write
guint64 | interleave-bytes | Read / Write
guint64 | interleave-time | Read / Write
guint64 | max-raw-audio-drift | Read / Write
gboolean | reserved-prefill | Read / Write / Construct

## Types and Values

| GstMP4Mux

## Object Hierarchy

        GObject
        ╰── GInitiallyUnowned
            ╰── GstObject
                ╰── GstElement
                    ╰── GstMP4Mux

## Implemented Interfaces

GstMP4Mux implements GstTagSetter, GstTagXmpWriter and GstPreset.

## Description

This element merges streams (audio and video) into ISO MPEG-4 (.mp4) files.

The following background intends to explain why various similar muxers are present in this plugin.

The QuickTime file format specification served as basis for the MP4 file format specification (mp4mux), and as such the QuickTime file structure is nearly identical to the so-called ISO Base Media file format defined in ISO 14496-12 (except for some media specific parts). In turn, the latter ISO Base Media format was further specialized as a Motion JPEG-2000 file format in ISO 15444-3 (mj2mux) and in various 3GPP(2) specs (3gppmux). The fragmented file features defined (only) in ISO Base Media are used by ISMV files making up (a.o.) Smooth Streaming (ismlmux).

A few properties (“movie-timescale”, “trak-timescale”) allow adjusting some technical parameters, which might be useful in (rare) cases to resolve compatibility issues in some situations.

Some other properties influence the result more fundamentally. A typical mov/mp4 file's metadata (aka moov) is located at the end of the file, somewhat contrary to this usually being called "the header". However, a “faststart” file will (with some effort) arrange this to be located near start of the file, which then allows it e.g. to be played while downloading. Alternatively, rather than having one chunk of metadata at start (or end), there can be some metadata at start and most of the other data can be spread out into fragments of “fragment-duration”. If such fragmented layout is intended for streaming purposes, then “streamable” allows foregoing to add index metadata (at the end of file).

### Example pipelines

    1
    gst-launch-1.0 gst-launch-1.0 v4l2src num-buffers=50 ! queue ! x264enc ! mp4mux ! filesink location=video.mp4

Records a video stream captured from a v4l2 device, encodes it into H.264 and muxes it into an mp4 file.

## Synopsis

### Element Information

plugin | isomp4
author | Thiago Sousa Santos <thiagoss@embedded.ufcg.edu.br>
class | Codec/Muxer

### Element Pads

name | audio_%u
direction | sink
presence | request
details | audio/mpeg, mpegversion=(int)1, layer=(int)[ 1, 3 ], channels=(int)[ 1, 2 ], rate=(int)[ 1, 2147483647 ]
| audio/mpeg, mpegversion=(int)4, stream-format=(string)raw, channels=(int)[ 1, 8 ], rate=(int)[ 1, 2147483647 ]
| audio/x-ac3, channels=(int)[ 1, 6 ], rate=(int)[ 1, 2147483647 ]
| audio/x-alac, channels=(int)[ 1, 2 ], rate=(int)[ 1, 2147483647 ]
| audio/x-opus, channel-mapping-family=(int)[ 0, 255 ], channels=(int)[ 1, 8 ], rate=(int)[ 1, 2147483647 ]

name | subtitle_%u
direction | sink
presence | request
details | text/x-raw, format=(string)utf8

name | video_%u
direction | sink
presence | request
details | video/mpeg, mpegversion=(int)4, systemstream=(boolean)false, width=(int)[ 16, 2147483647 ], height=(int)[ 16, 2147483647 ]
| video/x-divx, divxversion=(int)5, width=(int)[ 16, 2147483647 ], height=(int)[ 16, 2147483647 ]
| video/x-h264, stream-format=(string)avc, alignment=(string)au, width=(int)[ 16, 2147483647 ], height=(int)[ 16, 2147483647 ]
| video/x-h265, stream-format=(string){ hvc1, hev1 }, alignment=(string)au, width=(int)[ 16, 2147483647 ], height=(int)[ 16, 2147483647 ]
| video/x-mp4-part, width=(int)[ 16, 2147483647 ], height=(int)[ 16, 2147483647 ]

name | src
direction | source
presence | always
details | video/quicktime, variant=(string)iso

## Functions

## Types and Values

### GstMP4Mux

    typedef struct _GstMP4Mux GstMP4Mux;

## Property Details

### The `“dts-method”` property

      “dts-method”               GstQTMuxDtsMethods

Method to determine DTS time (DEPRECATED).

Flags: Read / Write / Construct

Default value: reorder

### The `“faststart”` property

      “faststart”                gboolean

If the file should be formatted for faststart (headers first).

Flags: Read / Write

Default value: FALSE

### The `“faststart-file”` property

      “faststart-file”           gchar *

File that will be used temporarily to store data from the stream when creating a faststart file. If null a filepath will be created automatically.

Flags: Read / Write / Construct

Default value: NULL

### The `“fragment-duration”` property

      “fragment-duration”        guint

Fragment durations in ms (produce a fragmented file if > 0).

Flags: Read / Write / Construct

Default value: 0

### The `“moov-recovery-file”` property

      “moov-recovery-file”       gchar *

File to be used to store data for moov atom making movie file recovery possible in case of a crash during muxing. Null for disabled. (Experimental).

Flags: Read / Write / Construct

Default value: NULL

### The `“movie-timescale”` property

      “movie-timescale”          guint

Timescale to use in the movie (units per second, 0 == default).

Flags: Read / Write / Construct

Default value: 0

### The `“presentation-time”` property

      “presentation-time”        gboolean

Calculate and include presentation/composition time (in addition to decoding time).

Flags: Read / Write / Construct

Default value: TRUE

### The `“streamable”` property

      “streamable”               gboolean

If set to true, the output should be as if it is to be streamed and hence no indexes written or duration written. (DEPRECATED, only valid for fragmented MP4).

Flags: Read / Write / Construct

Default value: FALSE

### The `“trak-timescale”` property

      “trak-timescale”           guint

Timescale to use for the tracks (units per second, 0 is automatic).

Flags: Read / Write / Construct

Default value: 0

### The `“reserved-bytes-per-sec”` property

      “reserved-bytes-per-sec”   guint

Multiplier for converting reserved-max-duration into bytes of header to reserve, per second, per track.

Flags: Read / Write / Construct

Allowed values: <= 10000

Default value: 550

### The `“reserved-duration-remaining”` property

      “reserved-duration-remaining” guint64

Reports the approximate amount of remaining moov header space reserved using reserved-max-duration.

Flags: Read

Default value: 0

### The `“reserved-max-duration”` property

      “reserved-max-duration”    guint64

When set to a value > 0, reserves space for index tables at the beginning of the file.

Flags: Read / Write

Default value: 18446744073709551615

### The `“reserved-moov-update-period”` property

      “reserved-moov-update-period” guint64

When used with reserved-max-duration, periodically updates the index tables with information muxed so far.

Flags: Read / Write

Default value: 18446744073709551615

### The `“interleave-bytes”` property

      “interleave-bytes”         guint64

Interleave between streams in bytes.

Flags: Read / Write

Default value: 0

### The `“interleave-time”` property

      “interleave-time”          guint64

Interleave between streams in nanoseconds.

Flags: Read / Write

Default value: 250000000

### The `“max-raw-audio-drift”` property

      “max-raw-audio-drift”      guint64

Maximum allowed drift of raw audio samples vs. timestamps in nanoseconds.

Flags: Read / Write

Default value: 40000000

### The `“reserved-prefill”` property

      “reserved-prefill”         gboolean

Prefill samples table of reserved duration.

Flags: Read / Write / Construct

Default value: FALSE