# SeekableMuxerOutput

Artifact: [androidx.media3:media3-muxer](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/muxer/SeekableMuxerOutput.java+class:androidx.media3.muxer.SeekableMuxerOutput)

*** ** * ** ***


```
@UnstableApi
public interface SeekableMuxerOutput extends WritableByteChannel
```

<br />

Known direct subclasses [FileOutputStreamSeekableMuxerOutput](https://developer.android.com/reference/androidx/media3/muxer/FileOutputStreamSeekableMuxerOutput)

|---|---|
| `https://developer.android.com/reference/androidx/media3/muxer/FileOutputStreamSeekableMuxerOutput` | An implementation of `https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput` that writes to a `https://developer.android.com/reference/java/io/FileOutputStream.html`. |

*** ** * ** ***

A seekable target for `https://developer.android.com/reference/androidx/media3/muxer/Muxer` output.

## Summary

| ### Public methods |
|---|---|
| `abstract long` | `https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput#getPosition()()` Returns the current position in the output. |
| `abstract long` | `https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput#getSize()()` Returns the total size of the output. |
| `default static https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput` | `https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput#of(java.io.FileOutputStream)(https://developer.android.com/reference/java/io/FileOutputStream.html fileOutputStream)` Creates a `https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput` from the given `https://developer.android.com/reference/java/io/FileOutputStream.html`. |
| `default static https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput` | `https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput#of(java.lang.String)(https://developer.android.com/reference/java/lang/String.html filePath)` Creates a `https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput` from the given file path. |
| `default static https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput` | `https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput#of(android.os.ParcelFileDescriptor)(https://developer.android.com/reference/android/os/ParcelFileDescriptor.html pfd)` Creates a `https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput` from the given `https://developer.android.com/reference/android/os/ParcelFileDescriptor.html`. |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput#setPosition(long)(long position)` Sets the current position in the output for subsequent `https://developer.android.com/reference/java/nio/channels/WritableByteChannel.html#write(java.nio.ByteBuffer)` operations. |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput#truncate(long)(long size)` Truncates the output to the specified size. |

### Inherited methods

From [java.nio.channels.Channel](https://developer.android.com/reference/java/nio/channels/Channel.html) `abstract void` `https://developer.android.com/reference/java/nio/channels/Channel.html#close()()` `abstract boolean` `https://developer.android.com/reference/java/nio/channels/Channel.html#isOpen()()` From [java.nio.channels.WritableByteChannel](https://developer.android.com/reference/java/nio/channels/WritableByteChannel.html) `abstract int` `https://developer.android.com/reference/java/nio/channels/WritableByteChannel.html#write(java.nio.ByteBuffer)(https://developer.android.com/reference/java/nio/ByteBuffer.html p)`

## Public methods

### getPosition

```
abstract long getPosition()
```

Returns the current position in the output.

This refers to the byte offset at which bytes will be written on the next `https://developer.android.com/reference/java/nio/channels/WritableByteChannel.html#write(java.nio.ByteBuffer)` call.

| Returns |
|---|---|
| `long` | The current position in bytes from the beginning of the output. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurs while getting the position. |

### getSize

```
abstract long getSize()
```

Returns the total size of the output.

| Returns |
|---|---|
| `long` | The total size of the output in bytes. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurs while getting the size. |

### of

```
default static SeekableMuxerOutput of(FileOutputStream fileOutputStream)
```

Creates a `https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput` from the given `https://developer.android.com/reference/java/io/FileOutputStream.html`.

### of

```
default static SeekableMuxerOutput of(String filePath)
```

Creates a `https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput` from the given file path.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/FileNotFoundException.html` |   |

### of

```
default static SeekableMuxerOutput of(ParcelFileDescriptor pfd)
```

Creates a `https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput` from the given `https://developer.android.com/reference/android/os/ParcelFileDescriptor.html`.

The caller transfers ownership of the `https://developer.android.com/reference/android/os/ParcelFileDescriptor.html` to the returned `https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput`. The descriptor is automatically closed when `https://developer.android.com/reference/java/nio/channels/Channel.html#close()` is called.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/os/ParcelFileDescriptor.html pfd` | the `https://developer.android.com/reference/android/os/ParcelFileDescriptor.html` to write output to |

### setPosition

```
abstract void setPosition(long position)
```

Sets the current position in the output for subsequent `https://developer.android.com/reference/java/nio/channels/WritableByteChannel.html#write(java.nio.ByteBuffer)` operations.

| Parameters |
|---|---|
| `long position` | The new position in bytes from the beginning of the output. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurs while setting the position. |

### truncate

```
abstract 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 |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurs while truncating the output. |