跳到正文
QuaLix

QuaLix

面向游戏过场动画与透明动效的视频编解码器

需要精确保留透明像素时,可选无损 RGBA。片头和过场动画可按目标码率编码,支持 SDR 与 10-bit PQ/HLG HDR。同一套解码器适用于网页、原生应用、Cocos、Godot 和 Unity。

蓝色胶片折成的 Q,中央镂空形成播放三角

同一条 QLX 码流,在浏览器 WASM 实时解码

切换左侧源码语言或右侧的无损 q0、自适应 VBR 与严格 CBR 档位,点击解码播放即可现场查看像素与耗时。

示例源码语言
import { inspectQuaLix, openQuaLix, QLX_MIME_TYPE } from '@quajs/qualix'
import { QuaLixCanvasPlayer } from '@quajs/qualix/web'

export async function mountClip(canvas: HTMLCanvasElement, url: string) {
  const bytes = new Uint8Array(await (await fetch(url)).arrayBuffer())
  const header = inspectQuaLix(bytes)
  console.log(`${QLX_MIME_TYPE} ${header.width}x${header.height} @ ${header.fps.toFixed(2)} fps`)

  const clip = await openQuaLix(bytes)
  const first = clip.decode(0)
  console.log(`frame 0 rows [${first.firstRow}, ${first.endRow}) (${first.pixels.byteLength} bytes)`)
  clip.close()

  return await QuaLixCanvasPlayer.create(canvas, bytes, {
    loop: true,
    pauseWhenHidden: true,
  })
}
use qualix::{ClipInfo, Color, DEFAULT_BUDGET, Decoder};
use std::fs::File;
use std::io::BufReader;

fn main() -> std::io::Result<()> {
    let file = BufReader::with_capacity(64 * 1024, File::open("opening.qlx")?);
    let mut decoder = Decoder::open(file, DEFAULT_BUDGET)?;
    let info: ClipInfo = decoder.info();

    let mut hash: u64 = 14695981039346656037;
    for index in 0..info.frames {
        let frame = decoder.decode(index)?;
        if info.color == Color::Srgb8 {
            for &byte in &frame.pixels[frame.dirty_rows.start as usize * info.width as usize * 4
                ..frame.dirty_rows.end as usize * info.width as usize * 4]
            {
                hash = (hash ^ u64::from(byte)).wrapping_mul(1099511628211);
            }
        }
    }
    println!(
        "{}x{} frames={} key_interval={} dirty_hash={:016x}",
        info.width, info.height, info.frames, info.key_interval, hash
    );
    Ok(())
}
WebAssembly 解码与画布预览
编码模式
QLX · 1,382,400 B → 99,325 B 13.9× · Exact RGBA
QLX · 1,382,400 B → 19,939 B 69.3× · Adaptive VBR
QLX · 1,382,400 B → 35,000 B 39.5× · Fixed Packet CBR
浏览器实时解码需要启用 JavaScript。 等待启动 WASM 解码