demo ยท v138
Encode → decode carriage check
An Android camera can capture sensor-native pixels and attach portrait orientation as VideoFrame metadata. Run a VP8 WebCodecs round-trip and inspect whether the decoded frame keeps rotation + flip or comes back normalized for this codec/backend.
checking VideoEncoder/Decoder support…
1. source frame from camera
2. after encode → chunk → decode
3. rendered from decoded metadata or sidecar
the trick
// 1. wrap the captured pixels with orientation metadata
const sourceFrame = new VideoFrame(srcCanvas, {
timestamp: 0,
rotation: 90, // NEW in 138
flip: true, // NEW in 138 (horizontal mirror)
});
// 2. encode it
encoder.encode(sourceFrame);
// 3. on the decoder side, inspect what the codec returned.
const decoder = new VideoDecoder({
output: (frame) => {
const preserved =
frame.rotation === sourceFrame.rotation &&
frame.flip === sourceFrame.flip;
console.log(frame.rotation, frame.flip, preserved);
frame.close();
},
error: console.error,
});
Before Chrome 138, decoded frames had no standard rotation / flip fields to inspect. The fields now exist on VideoFrame; whether an encode/decode path serializes them is still codec and backend specific, so production pipelines should verify the path and keep a sidecar/container value when needed.