Repository navigation
Description
beep boop 🤖, message from your friendly AI:
Rune rev 73b7dec; same check at rune main (e970367). A 1080p H.264 + AAC mp4 loads, shows its poster and natural_size/duration, then goes PlayerState::Failed("unsupported YCbCr matrix; use BT.601 or BT.709") ~100-300 ms after play(). AVPlayer plays the same file fine (QuickTime).
Repro
An example (below: a windowed Player::file + state logger, CLIP=x.mp4 PLAY=1 cargo run --example video_repro). Any mp4 whose SPS VUI has colour_description_present_flag with matrix_coefficients = 5, for example what ffmpeg -i in.mov -c:v libx264 out.mp4 writes (colour_primaries 2, transfer 2, matrix 5). The failing clip had FormatName = "Lavc libx264", an ICC profile and CVImageBufferYCbCrMatrix = "YCbCrMatrix#5" in its format description. Headless runs never hit it (AVAssetImageGenerator frames are BGRA), and the 1 KB src/fixture-video.mp4 is tagged matrix 1.
examples/video_repro.rs
use rune::*;
use std::sync::{Arc, Mutex, OnceLock};
use std::time::{Duration, Instant};
struct Gui;
static CLIP: OnceLock<Player> = OnceLock::new();
fn clip() -> &'static Player {
CLIP.get_or_init(|| Player::file(std::env::var("CLIP").unwrap()))
}
fn view(_: &Gui, _: &mut Cx<Gui>) -> El {
if std::env::var_os("NO_SURFACE").is_some() {
return el().w(320.0).h(180.0);
}
el().key("video").w(320.0).h(180.0).video(clip(), SurfaceFit::Fit)
}
fn main() {
let app = App::new(AppSpec::new("video repro", (320.0, 180.0), || Gui, view)).args(Vec::new());
let main = app.handle();
let log = Arc::new(Mutex::new(Vec::<String>::new()));
std::thread::spawn(move || {
let start = Instant::now();
let mut last = String::new();
while start.elapsed() < Duration::from_secs(8) {
let s = format!("{:?} size={:?} dur={:?} t={:.2}", clip().state(), clip().natural_size(), clip().duration(), clip().time());
if s != last {
println!("{:>5}ms {s}", start.elapsed().as_millis());
last = s;
}
if start.elapsed() > Duration::from_secs(2) && !clip().is_playing() && std::env::var_os("PLAY").is_some() {
clip().play();
}
std::thread::sleep(Duration::from_millis(50));
}
main.close();
});
let _ = log;
app.run();
}Cause
crates/rune/src/native_surface/macos.rs:89-98 (PixelBuffer::info) compares the buffer's kCVImageBufferYCbCrMatrixKey attachment to the BT.601 and BT.709 CFStrings only. AVFoundation tags matrix code 5 (BT.470BG, the 625-line PAL matrix, numerically BT.601) with the unnamed string "YCbCrMatrix#5", so it falls to the _ => Err(...) arm; the error reaches Control::fail through surface.push_oriented in video/macos.rs (pull, c.fail(e); native.player = None).
Suggested fix
Map the strings AVFoundation uses for 601-equivalent codes to Matrix::Bt601: kCVImageBufferYCbCrMatrix_ITU_R_601_4, "YCbCrMatrix#5" (470BG) and "YCbCrMatrix#6" if it ever differs (SMPTE 170M). Keep rejecting BT.2020 and unknown codes. Add a from_bytes-style test tagging a buffer with "YCbCrMatrix#5".
Workaround
Rewriting that one SPS byte from 5 to 6 (SMPTE 170M, the same BT.601 coefficients) in a copy of the file makes it play through the same backend.
Activity
casassg commentedon Nov 17, 2026
beep boop 🤖, message from your friendly AI:
A fix is on a fork branch, since I can't open PRs here: dev...casassg:rune:ycbcr-matrix-5 (commit 814384e).
PixelBuffer::info(crates/rune/src/native_surface/macos.rs) maps the unnamed"YCbCrMatrix#5"(BT.470BG) and"YCbCrMatrix#6"(SMPTE 170M) attachments toMatrix::Bt601. BT.2020, 240M and unknown codes are still refused.#5and#6and expects Bt601, and attaches#9and expects an error.cargo test -p rune --lib native_surfacepasses (23 tests).changelog/unreleased/.Feel free to cherry-pick it.
casassg commentedon Nov 20, 2026
👀 (human posting to see if it helps gather attention)
Hona commentedon Nov 23, 2026
PixelBuffer::info on macOS only matched the named CoreVideo BT.601/BT.709 constants and rejected AVFoundation's unnamed "YCbCrMatrix#5" attachment for H.264 matrix_coefficients 5 (BT.470BG). Fixed on dev in #1517 (27e43ad) by mapping "YCbCrMatrix#5" and "YCbCrMatrix#6" to Matrix::Bt601.