qtmux

qtmux — Muxer for quicktime(.mov) files

Synopsis

                    GstQTMux;

Properties

  "dts-method"               GstQTMuxDtsMethods    : Read / Write / Construct
  "faststart"                gboolean              : Read / Write
  "faststart-file"           gchar*                : Read / Write / Construct
  "fragment-duration"        guint                 : Read / Write / Construct
  "moov-recovery-file"       gchar*                : Read / Write / Construct
  "movie-timescale"          guint                 : Read / Write / Construct
  "presentation-time"        gboolean              : Read / Write / Construct
  "streamable"               gboolean              : Read / Write / Construct
  "trak-timescale"           guint                 : Read / Write / Construct

Description

This element merges streams (audio and video) into QuickTime(.mov) 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 (gppmux). 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).

dts-method allows selecting a method for managing input timestamps (stay tuned for 0.11 to have this automagically settled). The default delta/duration method should handle nice (aka perfect streams) just fine, but may experience problems otherwise (e.g. input stream with re-ordered B-frames and/or with frame dropping). The re-ordering approach re-assigns incoming timestamps in ascending order to incoming buffers and offers an alternative in such cases. In cases where that might fail, the remaining method can be tried, which is exact and according to specs, but might experience playback on not so spec-wise players. Note that this latter approach also requires one to enable presentation-timestamp.

Example pipelines

1
gst-launch v4l2src num-buffers=500 ! video/x-raw-yuv,width=320,height=240 ! ffmpegcolorspace ! qtmux ! filesink location=video.mov
Records a video stream captured from a v4l2 device and muxes it into a qt file.

Last reviewed on 2010-12-03

Details

GstQTMux

typedef struct {
  GstElement element;

  GstPad *srcpad;
  GstCollectPads *collect;
  GSList *sinkpads;

  /* state */
  GstQTMuxState state;

  /* size of header (prefix, atoms (ftyp, mdat)) */
  guint64 header_size;
  /* accumulated size of raw media data (a priori not including mdat header) */
  guint64 mdat_size;
  /* position of mdat atom (for later updating) */
  guint64 mdat_pos;

  /* keep track of the largest chunk to fine-tune brands */
  GstClockTime longest_chunk;

  /* atom helper objects */
  AtomsContext *context;
  AtomFTYP *ftyp;
  AtomMOOV *moov;
  GSList *extra_atoms; /* list of extra top-level atoms (e.g. UUID for xmp)
                        * Stored as AtomInfo structs */

  /* fragmented file index */
  AtomMFRA *mfra;

  /* fast start */
  FILE *fast_start_file;

  /* moov recovery */
  FILE *moov_recov_file;

  /* fragment sequence */
  guint32 fragment_sequence;

  /* properties */
  guint32 timescale;
  guint32 trak_timescale;
  AtomsTreeFlavor flavor;
  gboolean fast_start;
  gboolean guess_pts;
  gint dts_method;
  gchar *fast_start_file_path;
  gchar *moov_recov_file_path;
  guint32 fragment_duration;
  gboolean streamable;

  /* for collect pads event handling function */
  GstPadEventFunction collect_event;

  /* for request pad naming */
  guint video_pads, audio_pads;
} GstQTMux;

Property Details

The "dts-method" property

  "dts-method"               GstQTMuxDtsMethods    : Read / Write / Construct

Method to determine DTS time.

Default value: reorder


The "faststart" property

  "faststart"                gboolean              : Read / Write

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

Default value: FALSE


The "faststart-file" property

  "faststart-file"           gchar*                : Read / Write / Construct

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.

Default value: NULL


The "fragment-duration" property

  "fragment-duration"        guint                 : Read / Write / Construct

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

Default value: 0


The "moov-recovery-file" property

  "moov-recovery-file"       gchar*                : Read / Write / Construct

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).

Default value: NULL


The "movie-timescale" property

  "movie-timescale"          guint                 : Read / Write / Construct

Timescale to use in the movie (units per second).

Allowed values: >= 1

Default value: 1000


The "presentation-time" property

  "presentation-time"        gboolean              : Read / Write / Construct

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

Default value: TRUE


The "streamable" property

  "streamable"               gboolean              : Read / Write / Construct

If set to true, the output should be as if it is to be streamed and hence no indexes written or duration written.

Default value: FALSE


The "trak-timescale" property

  "trak-timescale"           guint                 : Read / Write / Construct

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

Default value: 0