Mp4Muxer.Builder


public final class Mp4Muxer.Builder


A builder for Mp4Muxer instances.

Summary

Public constructors

Builder(FileOutputStream outputStream)

Creates a Builder instance with default values.

Public methods

Mp4Muxer

Builds an Mp4Muxer instance.

Mp4Muxer.Builder

Sets the AnnexBToAvccConverter to be used by the muxer to convert H.264 and H.265 NAL units from the Annex-B format (using start codes to delineate NAL units) to the AVCC format (which uses length prefixes).

Mp4Muxer.Builder
@CanIgnoreReturnValue
setAttemptStreamableOutputEnabled(
    boolean attemptStreamableOutputEnabled
)

Sets whether to attempt to write a file where the metadata is stored at the start, which can make the file more efficient to read sequentially.

Mp4Muxer.Builder

Sets the EditableVideoParameters.

Mp4Muxer.Builder

Sets the LastSampleDurationBehavior.

Mp4Muxer.Builder

Sets the specific MP4 file format.

Mp4Muxer.Builder

Sets whether to enable the sample copy.

Public constructors

Builder

public Builder(FileOutputStream outputStream)

Creates a Builder instance with default values.

Parameters
FileOutputStream outputStream

The FileOutputStream to write the media data to.

Public methods

build

public Mp4Muxer build()

Builds an Mp4Muxer instance.

setAnnexBToAvccConverter

@CanIgnoreReturnValue
public Mp4Muxer.Builder setAnnexBToAvccConverter(AnnexBToAvccConverter annexBToAvccConverter)

Sets the AnnexBToAvccConverter to be used by the muxer to convert H.264 and H.265 NAL units from the Annex-B format (using start codes to delineate NAL units) to the AVCC format (which uses length prefixes).

The default value is DEFAULT.

setAttemptStreamableOutputEnabled

@CanIgnoreReturnValue
public Mp4Muxer.Builder setAttemptStreamableOutputEnabled(
    boolean attemptStreamableOutputEnabled
)

Sets whether to attempt to write a file where the metadata is stored at the start, which can make the file more efficient to read sequentially.

Setting to true does not guarantee a streamable MP4 output.

The default value is true.

setEditableVideoParameters

@CanIgnoreReturnValue
public Mp4Muxer.Builder setEditableVideoParameters(
    Mp4Muxer.EditableVideoParameters editableVideoParameters
)

Sets the EditableVideoParameters.

setLastSampleDurationBehavior

@CanIgnoreReturnValue
public Mp4Muxer.Builder setLastSampleDurationBehavior(
    @Mp4Muxer.LastSampleDurationBehavior int lastSampleDurationBehavior
)

Sets the LastSampleDurationBehavior.

The default value is LAST_SAMPLE_DURATION_BEHAVIOR_INSERT_SHORT_SAMPLE.

setOutputFileFormat

@CanIgnoreReturnValue
public Mp4Muxer.Builder setOutputFileFormat(@Mp4Muxer.FileFormat int fileFormat)

Sets the specific MP4 file format.

The default value is FILE_FORMAT_DEFAULT.

For FILE_FORMAT_EDITABLE_VIDEO, EditableVideoParameters must also be setEditableVideoParameters set}.

setSampleCopyEnabled

@CanIgnoreReturnValue
public Mp4Muxer.Builder setSampleCopyEnabled(boolean enabled)

Sets whether to enable the sample copy.

If the sample copy is enabled, writeSampleData copies the input ByteBuffer and BufferInfo before it returns, so it is safe to reuse them immediately. Otherwise, the muxer takes ownership of the and the BufferInfo and the caller must not modify them.

The default value is true.