Skip to main content

webcodecsController()

Pass webcodecsController() to controller to steer the convertMedia() function.

Use webcodecsController()
tsx
import {webcodecsController, convertMedia} from '@remotion/webcodecs';
 
const controller = webcodecsController();
 
convertMedia({
src: 'https://www.w3schools.com/html/mov_bbb.mp4',
container: 'webm',
controller,
});
 
// Pause
controller.pause();
 
// Resume
controller.resume();
 
// Abort
controller.abort();

API

This function returns an object that can be passed to convertMedia({controller}).

It has the following methods:

pause()

Pauses the conversion.

resume()

Resumes the conversion.

abort()

Aborts the conversion.

addEventListener()

See events below.

removeEventListener()

See events below.

Events

You can attach event listeners to the webcodecsController object.

Use events
tsx
import {webcodecsController, convertMedia} from '@remotion/webcodecs';
 
const controller = webcodecsController();
 
const onPause = () => {
console.log('Paused');
};
 
const onResume = () => {
console.log('Resumed');
};
 
controller.addEventListener('pause', onPause);
controller.addEventListener('resume', onResume);
 
// Make sure to cleanup later:
controller.removeEventListener('pause', onPause);
controller.removeEventListener('resume', onResume);

The webcodecsController object emits the following events:

pause

Emitted when the conversion is paused.

resume

Emitted when the conversion is resumed.

See also