Mp4Muxer.Builder
public final class Mp4Muxer.Builder
A builder for Mp4Muxer instances.
Summary
Public constructors |
|---|
This method is deprecated. Use |
Builder(SeekableMuxerOutput seekableMuxerOutput)Creates an instance. |
Public methods |
|
|---|---|
Mp4Muxer |
build()Builds an |
Mp4Muxer.Builder |
Sets the amount of free space (in bytes) to be reserved immediately after the |
Mp4Muxer.Builder |
@CanIgnoreReturnValueSets the |
Mp4Muxer.Builder |
@CanIgnoreReturnValueSets 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 |
@CanIgnoreReturnValueSets a |
Mp4Muxer.Builder |
@CanIgnoreReturnValueSets the |
Mp4Muxer.Builder |
@CanIgnoreReturnValueSets the |
Mp4Muxer.Builder |
@CanIgnoreReturnValueSets the specific MP4 file format. |
Mp4Muxer.Builder |
@CanIgnoreReturnValueSets whether to enable sample batching. |
Mp4Muxer.Builder |
@CanIgnoreReturnValueSets whether to enable the sample copy. |
Public constructors
Builder
public Builder(SeekableMuxerOutput seekableMuxerOutput)
Creates an instance.
| Parameters | |
|---|---|
SeekableMuxerOutput seekableMuxerOutput |
A |
Public methods
experimentalSetFreeSpaceAfterFileTypeBox
@CanIgnoreReturnValue
public Mp4Muxer.Builder experimentalSetFreeSpaceAfterFileTypeBox(int bytes)
Sets the amount of free space (in bytes) to be reserved immediately after the ftyp box (File Type box) in the MP4 file.
The moov box (Movie Box) is written in the reserved space if setAttemptStreamableOutputEnabled is set to true, and the size of the moov box is not greater than bytes. Otherwise, a free box of the requested size is written.
By default 400_000 bytes are reserved if setAttemptStreamableOutputEnabled is set to true.
This method is experimental and will be renamed or removed in a future release.
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.
setCacheFileSupplier
@CanIgnoreReturnValue
public Mp4Muxer.Builder setCacheFileSupplier(Supplier<String> cacheFileSupplier)
Sets a Supplier that provides an absolute path of a cache file.
Every call to get must return a new cache file path.
This must be set when shouldInterleaveSamples is set to
false.
The app is responsible for deleting the cache file after closing the muxer.
setLastSampleDurationBehavior
@CanIgnoreReturnValue
public Mp4Muxer.Builder setLastSampleDurationBehavior(
@Mp4Muxer.LastSampleDurationBehavior int lastSampleDurationBehavior
)
Sets the LastSampleDurationBehavior.
The default value is LAST_SAMPLE_DURATION_BEHAVIOR_SET_FROM_END_OF_STREAM_BUFFER_OR_DUPLICATE_PREVIOUS.
setMp4AtFileParameters
@CanIgnoreReturnValue
public Mp4Muxer.Builder setMp4AtFileParameters(
Mp4Muxer.Mp4AtFileParameters mp4AtFileParameters
)
Sets the Mp4AtFileParameters.
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_MP4_WITH_AUXILIARY_TRACKS_EXTENSION, Mp4AtFileParameters must also be setMp4AtFileParameters set}.
setSampleBatchingEnabled
@CanIgnoreReturnValue
public Mp4Muxer.Builder setSampleBatchingEnabled(boolean enabled)
Sets whether to enable sample batching.
If sample batching is enabled, samples are written in batches for each track, otherwise samples are written as they arrive.
When sample batching is enabled, and sample copying is disabled the ByteBuffer and BufferInfo provided to writeSampleData must not be modified. Otherwise, if sample batching is disabled or sample copying is enabled, the ByteBuffer and BufferInfo can be modified after calling writeSampleData.
The default value is false.
setSampleCopyingEnabled
@CanIgnoreReturnValue
public Mp4Muxer.Builder setSampleCopyingEnabled(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 ByteBuffer and the BufferInfo and the caller must not modify them.
Note: Sample copying is only effective when sample batching is also enabled. If sample batching is disabled, samples are written immediately upon arrival, and copying is not performed, regardless of this setting.
The default value is false.