remotion-dev/remotion · warning · ErrorWithBacktrace

Invalid side data

Error message

Invalid side data

What it means

Thrown by get_from_side_data when the display-matrix side data does not parse into exactly 9 little-endian i32 values. The display matrix is a 3x3 affine transform, so any other length indicates corrupt or non-rotation side data.

Source

Thrown at packages/compositor/rust/rotation.rs:14

use std::{f64::consts::PI, io::ErrorKind};

use crate::errors::ErrorWithBacktrace;

pub fn get_from_side_data(value: &[u8]) -> Result<f64, ErrorWithBacktrace> {
    let mut i32_values: Vec<i32> = Vec::new();

    for bytes in value.chunks(4) {
        let i32_value = i32::from_le_bytes(bytes.try_into().unwrap());
        i32_values.push(i32_value);
    }

    if i32_values.len() != 9 {
        Err(std::io::Error::new(ErrorKind::Other, "Invalid side data"))?;
    }
    return get_rotation(&i32_values);
}

pub fn get_rotation(displaymatrix: &[i32]) -> Result<f64, ErrorWithBacktrace> {
    let mut theta = -(rotation_get(displaymatrix))?.round();

    theta -= 360.0 * (theta / 360.0 + 0.9 / 360.0).floor();

    if (theta - 90.0 * (theta / 90.0).round()).abs() > 2.0 {
        Err(std::io::Error::new(ErrorKind::Other, "Odd rotation angle"))?;
    }

    return Ok(theta);
}

pub fn rotation_get(matrix: &[i32]) -> Result<f64, ErrorWithBacktrace> {
    let scale0 = (matrix[0] as f64).hypot(matrix[3] as f64);

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Validate side_data.len() >= 36 and is a multiple of 4 before calling, and skip rotation parsing otherwise (treat as 0 degrees).
  2. Re-mux the source so the display matrix is written correctly, or strip rotation metadata with `-metadata:s:v:0 rotate=` if it is spurious.
  3. Only pass display-matrix side data (AV_FRAME_DATA_DISPLAYMATRIX / AV_PKT_DATA_DISPLAYMATRIX) to this function.

Example fix

// before
let rot = get_from_side_data(&side_data)?;

// after
if side_data.len() < 36 || side_data.len() % 4 != 0 {
    return Ok(0.0); // no usable rotation metadata
}
let rot = get_from_side_data(&side_data).unwrap_or(0.0);
Defensive patterns

Strategy: validation

Validate before calling

fn valid_display_matrix(data: &[u8]) -> bool {
    data.len() >= 36 && data.len() % 4 == 0 && data.len() / 4 == 9
}
if !valid_display_matrix(&side_data) { return Ok(0.0); }

Type guard

null

Try / catch

let rot = match get_from_side_data(&side_data) {
    Ok(r) => r,
    Err(_) => 0.0, // tolerate non-matrix side data
};

Prevention

When it happens

Trigger: Reading AVPacket/AVFrame side data whose length is not a multiple of 4, or whose i32 count is not 9; passing arbitrary side-data blobs (e.g. non-display-matrix metadata) into get_from_side_data.

Common situations: Containers that attach unrelated side data that the rotation reader does not recognize; partially-written media where side-data is truncated; an ffmpeg version that changes the side-data payload format.

Related errors


AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12). Data as JSON: /api/errors/a768adbcb8c351c0. Report an issue: GitHub.