demo · v138
Active Orientation Lock: change rotation mid-stream
The Chrome 138 spec requires VideoEncoder to throw a DataError if a frame's rotation or flip differs from the first encoded frame in the stream. Once you encode frame 1 with rotation: 90, the encoder "locks in" that orientation — all subsequent frames in the same session must match, or encoding is aborted. This is the constraint that ensures codec streams have consistent display dimensions.
VideoFrame orientation (Chrome 138+) not detected. The DataError behaviour may not fire. The demo will still run but the lock may not be enforced in this browser version.
ChromeStatus
Frame 1 — anchors the lock
—
Frame 2 — attempt to change orientation
—
[ Waiting — encode frame 1 to set the orientation lock. ]\n
// Chrome 138+ — VideoEncoder orientation lock behaviour
const encoder = new VideoEncoder({
output: (chunk, meta) => { /* receive encoded chunk */ },
error: (e) => {
console.error('Encoder error:', e.name, e.message);
// DataError thrown when orientation changes mid-stream
}
});
encoder.configure({
codec: 'vp8', width: 320, height: 240,
bitrate: 500_000, framerate: 30
});
// Frame 1: sets the lock to { rotation: 90, flip: false }
const frame1 = new VideoFrame(canvas1, { timestamp: 0, rotation: 90, flip: false });
encoder.encode(frame1);
frame1.close();
// Frame 2: different rotation → DataError
const frame2 = new VideoFrame(canvas2, { timestamp: 33_333, rotation: 0, flip: false });
encoder.encode(frame2); // ← throws DataError: orientation changed mid-stream
frame2.close();