packages/docs/docs/webcodecs/buffer-writer.mdx
:::warning We are phasing out Remotion WebCodecs and are moving to Mediabunny! :::
import {LicenseDisclaimer} from './LicenseDisclaimer'; import {UnstableDisclaimer} from './UnstableDisclaimer';
<details> <summary>💼 Important License Disclaimer</summary> <LicenseDisclaimer /> </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.
import {convertMedia} from '@remotion/webcodecs';
import {bufferWriter} from '@remotion/webcodecs/buffer';
const result = await convertMedia({
src: 'https://remotion.media/BigBuckBunny.mp4',
container: 'webm',
writer: bufferWriter,
});
const blob = await result.save();
The bufferWriter uses a resizable ArrayBuffer with a maximum size of 2GB. If your output file would exceed this limit, the conversion will fail.
import {convertMedia} from '@remotion/webcodecs';
import {bufferWriter} from '@remotion/webcodecs/buffer';
try {
const result = await convertMedia({
src: 'very-large-video.mp4',
container: 'webm',
writer: bufferWriter,
});
} catch (error) {
if ((error as Error).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');
}
}
webFsWriter - Alternative file system writerconvertMedia()