DefaultMuxer.Factory


public final class DefaultMuxer.Factory implements Muxer.Factory


A Muxer.Factory for DefaultMuxer.

Summary

Public constructors

Creates an instance.

Factory(long videoDurationMs)

This method is deprecated.

Use setVideoDurationUs instead.

Public methods

Muxer
create(String path)

Returns a new Muxer.

Muxer

Returns a new Muxer.

ImmutableList<String>

Returns the supported sample MIME types for the given C.TrackType.

DefaultMuxer.Factory

Sets the duration of the video track (in microseconds) to enforce in the output.

boolean

Whether the muxer supports writing negative timestamps into an edit list to instruct players to ignore these samples.

Public constructors

Factory

public Factory()

Creates an instance.

Factory

public Factory(long videoDurationMs)

Public methods

create

public Muxer create(String path)

Returns a new Muxer.

Parameters
String path

The path to the output file.

Throws
androidx.media3.muxer.MuxerException

If an error occurs opening the output file for writing.

create

public Muxer create(ParcelFileDescriptor pfd)

Returns a new Muxer.

The caller transfers ownership of the ParcelFileDescriptor to the Factory. If this method returns successfully, the created Muxer is responsible for closing the descriptor when close is called. If an error occurs and a MuxerException is thrown, the descriptor is closed before the exception is thrown.

Whether the provided ParcelFileDescriptor must be seekable depends on the container format and Muxer implementation. For example, standard MP4 muxers require seekable descriptors (such as those opened with "rwt" or "rw"), whereas streaming muxers (such as fragmented MP4 muxers) also accept non-seekable streams like pipes.

Parameters
ParcelFileDescriptor pfd

the ParcelFileDescriptor to write output to

Throws
androidx.media3.muxer.MuxerException

if an error occurs opening the output for writing or if the descriptor does not satisfy the seekability requirements of the muxer

getSupportedSampleMimeTypes

public ImmutableList<String> getSupportedSampleMimeTypes(@C.TrackType int trackType)

Returns the supported sample MIME types for the given C.TrackType.

setVideoDurationUs

@CanIgnoreReturnValue
public DefaultMuxer.Factory setVideoDurationUs(long videoDurationUs)

Sets the duration of the video track (in microseconds) to enforce in the output.

The default is TIME_UNSET.

Parameters
long videoDurationUs

The duration of the video track (in microseconds) to enforce in the output, or TIME_UNSET to not enforce. Only applicable when a video track is added.

Returns
DefaultMuxer.Factory

This factory.

supportsWritingNegativeTimestampsInEditList

public boolean supportsWritingNegativeTimestampsInEditList()

Whether the muxer supports writing negative timestamps into an edit list to instruct players to ignore these samples.