Skip to main content

bufferWriter

πŸ’Ό Important License Disclaimer
This package is licensed under the Remotion License.
We consider a team of 4 or more people a "company".

For "companies": A Remotion Company license needs to be obtained to use this package.
In a future version of @remotion/webcodecs, this package will also require the purchase of a newly created "WebCodecs Conversion Seat". Get in touch with us if you are planning to use this package.

For individuals and teams up to 3: You can use this package for free.

This is a short, non-binding explanation of our license. See the License itself for more details.
warning

Unstable API: The writer interface is experimental. The API may change in the future.

A writer for @remotion/webcodecs that writes to an in-memory resizable ArrayBuffer.

Can be used for convertMedia() to write the converted output to memory as a buffer.

Example​

Using bufferWriter
tsx
import {convertMedia} from'@remotion/webcodecs';
import {bufferWriter} from'@remotion/webcodecs/buffer';
constresult=awaitconvertMedia({
src: 'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',
container: 'webm',
writer: bufferWriter,
});
constblob=await result.save();

Memory limitations​

The bufferWriter uses a resizable ArrayBuffer with a maximum size of 2GB. If your output file would exceed this limit, the conversion will fail.

Error handling for large files
tsx
import {convertMedia} from'@remotion/webcodecs';
import {bufferWriter} from'@remotion/webcodecs/buffer';
try {
constresult=awaitconvertMedia({
src: 'very-large-video.mp4',
container: 'webm',
writer: bufferWriter,
});
} catch (error) {
if ((error asError).message.includes('Could not create buffer writer')) {
// Handle case where ArrayBuffer cannot be resized further
console.log('File too large for buffer writer, consider using webFsWriter');
}
}

See also​

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /