# multifilesink

Write incoming data to a series of sequentially-named files.

This element is usually used with data where each buffer is an independent unit of data in its own right (e.g. raw video buffers or encoded JPEG or PNG images) or with streamable container formats such as MPEG-TS or MPEG-PS.

It is not possible to use this element to create independently playable mp4 files, use the splitmuxsink element for that instead.

The filename property should contain a string with a %d placeholder that will be substituted with the index for each filename.

If the property is TRUE, it sends an application message named `GstMultiFileSink` after writing each buffer.

The message's structure contains these fields:

- gchararray `filename`: the filename where the buffer was written.
- gint `index`: index of the buffer.
- GstClockTime `timestamp`: the timestamp of the buffer.
- GstClockTime `stream-time`: the stream time of the buffer.
- GstClockTime running-time`: the running_time of the buffer.
- GstClockTime `duration`: the duration of the buffer.
- guint64 `offset`: the offset of the buffer that triggered the message.
- guint64 `offset-end`: the offset-end of the buffer that triggered the message.

## Example launch line

     gst-launch-1.0 audiotestsrc ! multifilesink
     gst-launch-1.0 videotestsrc ! multifilesink post-messages=true location="frame%d"

## Hierarchy

    GObject
        ╰──GInitiallyUnowned
            ╰──GstObject
                ╰──GstElement
                    ╰──GstBaseSink
                        ╰──multifilesink

## Factory details

Authors: – David Schleef

Classification: – `Sink/File`

Rank – none

Plugin – multifile

Package – GStreamer Good Plug-ins

## Pad Templates

### `sink`

    ANY

Presence – always

Direction – sink

Object type – GstPad

## Properties

### aggregate-gops

    “aggregate-gops” gboolean

Whether to aggregate complete GOPs before doing any processing. Set this to TRUE to make sure each new file starts with a keyframe. This requires the upstream element to flag buffers containing key units and delta units correctly. At least the MPEG-PS and MPEG-TS muxers should be doing this.

Flags : Read / Write

Default value : false

### index

    “index” gint

Index to use with location property to create file names. The index is incremented by one for each buffer written.

Flags : Read / Write

Default value : 0

### location

    “location” gchararray

Location of the file to write

Flags : Read / Write

Default value : %%05d

### max-file-duration

    “max-file-duration” guint64

Maximum file size before starting a new file in max-size mode.

Flags : Read / Write

Default value : 18446744073709551615

### max-file-size

    “max-file-size” guint64

Maximum file size before starting a new file in max-size mode.

Flags : Read / Write

Default value : 2147483648

### max-files

    “max-files” guint

Maximum number of files to keep on disk. Once the maximum is reached, old files start to be deleted to make room for new ones.

Flags : Read / Write

Default value : 0

### next-file

    “next-file” Multi-file-sink-next *

When to start a new file.

Flags : Read / Write

Default value : buffer (0)

### post-messages

    “post-messages” gboolean

Post a message on the GstBus for each file.

Flags : Read / Write

Default value : false

## Named constants

### Multi-file-sink-next

File splitting modes.

#### Members

`buffer` (0) – New file for each buffer
`discont` (1) – New file after each discontinuity
`key-frame` (2) – New file at each key frame (Useful for MPEG-TS segmenting)
`key-unit-event` (3) – New file after a force key unit event
`max-size` (4) – New file when the configured maximum file size would be exceeded with the next buffer or buffer list
`max-duration` (5) – New file when the configured maximum file duration would be exceeded with the next buffer or buffer list

The results of the search are