FileOutputStreamSeekableMuxerOutput


@UnstableApi
public final class FileOutputStreamSeekableMuxerOutput implements SeekableMuxerOutput


An implementation of SeekableMuxerOutput that writes to a FileOutputStream.

Summary

Public constructors

Creates an instance.

Public methods

void
long

Returns the current position in the output.

long

Returns the total size of the output.

boolean
void
setPosition(long position)

Sets the current position in the output for subsequent write operations.

void
truncate(long size)

Truncates the output to the specified size.

int

Inherited methods

From androidx.media3.muxer.SeekableMuxerOutput
static SeekableMuxerOutput
of(FileOutputStream fileOutputStream)

Creates a SeekableMuxerOutput from the given FileOutputStream.

static SeekableMuxerOutput
of(String filePath)

Creates a SeekableMuxerOutput from the given file path.

Public constructors

FileOutputStreamSeekableMuxerOutput

public FileOutputStreamSeekableMuxerOutput(FileOutputStream fileOutputStream)

Creates an instance.

Parameters
FileOutputStream fileOutputStream

The FileOutputStream to write output to.

Public methods

close

public void close()

getPosition

public long getPosition()

Returns the current position in the output.

This refers to the byte offset at which bytes will be written on the next write call.

Returns
long

The current position in bytes from the beginning of the output.

Throws
java.io.IOException

If an error occurs while getting the position.

getSize

public long getSize()

Returns the total size of the output.

Returns
long

The total size of the output in bytes.

Throws
java.io.IOException

If an error occurs while getting the size.

isOpen

public boolean isOpen()

setPosition

public void setPosition(long position)

Sets the current position in the output for subsequent write operations.

Parameters
long position

The new position in bytes from the beginning of the output.

Throws
java.io.IOException

If an error occurs while setting the position.

truncate

public void truncate(long size)

Truncates the output to the specified size.

If the current position (for writing) is beyond the new size, it is set to the new size.

Parameters
long size

The new size of the output in bytes.

Throws
java.io.IOException

If an error occurs while truncating the output.

write

public int write(ByteBuffer src)