public final class

Mp4Muxer.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.media3.muxer.Mp4Muxer.Builder

Overview

A builder for Mp4Muxer instances.

Summary

Constructors
publicBuilder(java.io.FileOutputStream outputStream)

Creates a Mp4Muxer.Builder instance with default values.

Methods
public Mp4Muxerbuild()

Builds an Mp4Muxer instance.

public Mp4Muxer.BuildersetAnnexBToAvccConverter(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).

public Mp4Muxer.BuildersetAttemptStreamableOutputEnabled(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.

public Mp4Muxer.BuildersetEditableVideoParameters(Mp4Muxer.EditableVideoParameters editableVideoParameters)

Sets the Mp4Muxer.EditableVideoParameters.

public Mp4Muxer.BuildersetLastSampleDurationBehavior(int lastSampleDurationBehavior)

Sets the Mp4Muxer.LastSampleDurationBehavior.

public Mp4Muxer.BuildersetOutputFileFormat(int fileFormat)

Sets the specific MP4 file format.

public Mp4Muxer.BuildersetSampleCopyEnabled(boolean enabled)

Sets whether to enable the sample copy.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder(java.io.FileOutputStream outputStream)

Creates a Mp4Muxer.Builder instance with default values.

Parameters:

outputStream: The java.io.FileOutputStream to write the media data to.

Methods

public Mp4Muxer.Builder setLastSampleDurationBehavior(int lastSampleDurationBehavior)

Sets the Mp4Muxer.LastSampleDurationBehavior.

The default value is Mp4Muxer.LAST_SAMPLE_DURATION_BEHAVIOR_INSERT_SHORT_SAMPLE.

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 AnnexBToAvccConverter.DEFAULT.

public Mp4Muxer.Builder setSampleCopyEnabled(boolean enabled)

Sets whether to enable the sample copy.

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

The default value is true.

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.

public Mp4Muxer.Builder setOutputFileFormat(int fileFormat)

Sets the specific MP4 file format.

The default value is Mp4Muxer.FILE_FORMAT_DEFAULT.

For Mp4Muxer.FILE_FORMAT_EDITABLE_VIDEO, Mp4Muxer.EditableVideoParameters must also be Mp4Muxer.Builder set}.

public Mp4Muxer.Builder setEditableVideoParameters(Mp4Muxer.EditableVideoParameters editableVideoParameters)

Sets the Mp4Muxer.EditableVideoParameters.

public Mp4Muxer build()

Builds an Mp4Muxer instance.