Skip to content

The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.

feat: advanced export settings - VBR/CBR and target bitrate

Domicafefa6da1159e
diff --git a/src/crates/concat-api/src/lib.rs b/src/crates/concat-api/src/lib.rs
index d09f58d3..3e2f4a2a 100644
--- a/src/crates/concat-api/src/lib.rs
+++ b/src/crates/concat-api/src/lib.rs
@@ -375,6 +375,8 @@ impl Api {
.unwrap_or_else(|| DEFAULT_PRESET.to_owned()),
codec,
ten_bit: spec.ten_bit.unwrap_or(false),
+ rate_mode: export::RateMode::Vbr,
+ bitrate_kbps: 0,
};
let project_path = session.path().to_owned();
diff --git a/src/crates/concat-export/src/lib.rs b/src/crates/concat-export/src/lib.rs
index b1b58235..b8c60af7 100644
--- a/src/crates/concat-export/src/lib.rs
+++ b/src/crates/concat-export/src/lib.rs
@@ -39,7 +39,7 @@ use concat_core::timeline::{Clip, ClipId, MediaRef, Timeline, Track, TrackKind,
use concat_effects::Catalogue;
use concat_media::audio::{self, AudioClip};
use concat_media::{
- DecodeOptions, Decoder, EncodeOptions, Encoder, FrameSink, FrameSource, VideoCodec,
+ DecodeOptions, Decoder, EncodeOptions, Encoder, FrameSink, FrameSource, RateMode, VideoCodec,
};
use concat_project::model::{AppliedFilter, Cutout};
use concat_render::{
@@ -334,6 +334,14 @@ pub struct ExportRequest {
/// Ten bits a channel rather than eight.
#[serde(default)]
pub ten_bit: bool,
+ /// VBR (the CRF carries the quality) or CBR (the bitrate is the
+ /// target). VBR when a request does not say.
+ #[serde(default, deserialize_with = "rate_mode_by_name")]
+ pub rate_mode: RateMode,
+ /// Target bitrate in kbps, used when `rate_mode` is CBR. Zero means
+ /// "not set" and the encoder falls back to VBR.
+ #[serde(default)]
+ pub bitrate_kbps: u32,
/// The flattened clip list to render.
pub clips: Vec<ExportClip>,
}
@@ -349,6 +357,19 @@ fn codec_by_name<'de, D: serde::Deserializer<'de>>(
})
}
+/// A rate mode named the way [`RateMode::name`] names it, refusing a name
+/// the engine does not know rather than quietly falling back to VBR.
+fn rate_mode_by_name<'de, D: serde::Deserializer<'de>>(
+ deserializer: D,
+) -> Result<RateMode, D::Error> {
+ let name = String::deserialize(deserializer)?;
+ RateMode::ALL
+ .iter()
+ .find(|mode| mode.name() == name)
+ .copied()
+ .ok_or_else(|| serde::de::Error::custom(format!("unknown rate mode {name:?}: vbr or cbr")))
+}
+
/// What the export loop calls to report and to ask "should I stop?".
pub struct Reporter<'a> {
/// Called with (frame, total, stage).
@@ -973,6 +994,8 @@ fn render_picture(
crf: request.crf,
preset: request.preset.clone(),
codec: request.codec,
+ rate_mode: request.rate_mode,
+ bitrate_kbps: request.bitrate_kbps,
ten_bit: request.ten_bit,
hardware: true,
},
@@ -1568,6 +1591,8 @@ pub fn preview_plan(
preset: String::new(),
codec: VideoCodec::H264,
ten_bit: false,
+ rate_mode: RateMode::Vbr,
+ bitrate_kbps: 0,
clips: Vec::new(),
};
PreviewPlan {
diff --git a/src/crates/concat-host/src/export.rs b/src/crates/concat-host/src/export.rs
index ab7d2f63..19fdf851 100644
--- a/src/crates/concat-host/src/export.rs
+++ b/src/crates/concat-host/src/export.rs
@@ -12,7 +12,7 @@ use std::sync::Arc;
use std::sync::atomic::AtomicBool;
use concat_export::{ExportClip, ExportRequest, Reporter, render};
-pub use concat_media::VideoCodec;
+pub use concat_media::{RateMode, VideoCodec};
use crate::jobs::{Job, SingleFlight};
use crate::session::Session;
@@ -31,6 +31,12 @@ pub struct ExportSpec {
pub codec: VideoCodec,
/// Ten bits a channel rather than eight.
pub ten_bit: bool,
+ /// VBR (the CRF carries the quality) or CBR (the bitrate is the
+ /// target). VBR by default, so the sheet's Advanced section being off
+ /// means the file is what it always was.
+ pub rate_mode: concat_media::RateMode,
+ /// Target bitrate in kbps, used when `rate_mode` is CBR.
+ pub bitrate_kbps: u32,
}
/// One progress report: which frame of how many, in which stage.
@@ -59,6 +65,8 @@ pub fn request(session: &Session, spec: &ExportSpec, titles: Vec<ExportClip>) ->
preset: spec.preset.clone(),
codec: spec.codec,
ten_bit: spec.ten_bit,
+ rate_mode: spec.rate_mode,
+ bitrate_kbps: spec.bitrate_kbps,
clips,
}
}
diff --git a/src/crates/concat-host/tests/export.rs b/src/crates/concat-host/tests/export.rs
index 3aefa22f..2f2715e9 100644
--- a/src/crates/concat-host/tests/export.rs
+++ b/src/crates/concat-host/tests/export.rs
@@ -41,7 +41,7 @@ use concat_host::{media, projects};
use concat_media::audio::{self as sound, AudioClip};
use concat_media::{
AudioDecoder, AudioOptions, DecodeOptions, Decoder, EncodeOptions, Encoder,
- Error as MediaError, FrameSink, FrameSource, HwDevice, SampleFormat, VideoCodec,
+ Error as MediaError, FrameSink, FrameSource, HwDevice, RateMode, SampleFormat, VideoCodec,
};
use concat_project::animation;
use concat_project::commands::{ClipMove, ClipPatch, Command, TrackFlag, TrimEdge};
@@ -89,6 +89,8 @@ fn picture(path: &Path, rate: FrameRate, seconds: u32) {
codec: VideoCodec::H264,
preset: "ultrafast".to_owned(),
crf: 16,
+ rate_mode: RateMode::Vbr,
+ bitrate_kbps: 0,
ten_bit: false,
hardware: false,
};
@@ -496,6 +498,8 @@ impl Studio {
preset: "ultrafast".to_owned(),
codec: VideoCodec::H264,
ten_bit: false,
+ rate_mode: RateMode::Vbr,
+ bitrate_kbps: 0,
};
let titles = self
.titles
diff --git a/src/crates/concat-media/src/decode.rs b/src/crates/concat-media/src/decode.rs
index fc310a48..0bf34fe3 100644
--- a/src/crates/concat-media/src/decode.rs
+++ b/src/crates/concat-media/src/decode.rs
@@ -847,6 +847,7 @@ impl SeekableSource for Decoder {
#[cfg(test)]
mod tests {
use super::*;
+ use crate::encode::RateMode;
#[test]
fn options_build_up() {
@@ -933,6 +934,8 @@ mod tests {
codec: VideoCodec::Hevc,
preset: "ultrafast".to_owned(),
crf: 20,
+ rate_mode: RateMode::Vbr,
+ bitrate_kbps: 0,
ten_bit: true,
hardware: false,
};
diff --git a/src/crates/concat-media/src/encode.rs b/src/crates/concat-media/src/encode.rs
index 8aab0818..3b97ea7d 100644
--- a/src/crates/concat-media/src/encode.rs
+++ b/src/crates/concat-media/src/encode.rs
@@ -116,6 +116,35 @@ impl VideoCodec {
}
}
+/// How the encoder is told what rate to hold. VBR leaves the bitrate free
+/// and asks for a quality (the CRF); CBR pins one target, at the cost of
+/// some quality in the busy seconds. VBR is what every export used to be,
+/// and stays the default.
+#[derive(Clone, Copy, PartialEq, Eq, Debug, Default)]
+pub enum RateMode {
+ /// Quality first: the encoder picks a bitrate per frame. `bitrate_kbps`
+ /// is unused.
+ #[default]
+ Vbr,
+ /// Size first: `bitrate_kbps` is the target and the encoder keeps to it.
+ /// Only the soft encoders support it; hardware encoders fall back to
+ /// VBR because their rate control differs.
+ Cbr,
+}
+
+impl RateMode {
+ /// The name a document or a request stores.
+ pub fn name(self) -> &'static str {
+ match self {
+ RateMode::Vbr => "vbr",
+ RateMode::Cbr => "cbr",
+ }
+ }
+
+ /// Every mode, in the order a menu lists them.
+ pub const ALL: [RateMode; 2] = [RateMode::Vbr, RateMode::Cbr];
+}
+
/// Encoder settings.
#[derive(Clone, Debug)]
pub struct EncodeOptions {
@@ -128,6 +157,13 @@ pub struct EncodeOptions {
/// and a bigger file; the other encoders are handed their own
/// equivalent.
pub crf: u8,
+ /// VBR (the CRF carries the quality) or CBR (the bitrate is the
+ /// target). Default VBR, so an unchanged export means an unchanged
+ /// file.
+ pub rate_mode: RateMode,
+ /// Target bitrate in kilobits per second, used when `rate_mode` is
+ /// CBR. Zero means "not set" and the encoder falls back to VBR.
+ pub bitrate_kbps: u32,
/// Ten bits a channel rather than eight: no banding in a sky or a
/// gradient, at a few percent more file. H.264 at ten bits plays on
/// less than HEVC or AV1 at ten bits do.
@@ -143,6 +179,8 @@ impl Default for EncodeOptions {
codec: VideoCodec::H264,
preset: "medium".to_owned(),
crf: 18,
+ rate_mode: RateMode::Vbr,
+ bitrate_kbps: 0,
ten_bit: false,
hardware: true,
}
@@ -307,7 +345,37 @@ impl Encoder {
}
let crf = options.crf.to_string();
+ let cbr = options.rate_mode == RateMode::Cbr && options.bitrate_kbps > 0;
+ let bitrate = format!("{}k", options.bitrate_kbps);
+ // One second of VBV, not two. With a looser buffer x264 can stay
+ // well under b:v on calm content and never emit the padding that
+ // makes a CBR a CBR; `bufsize == bitrate` is where it starts
+ // holding the target.
+ let bufsize = format!("{}k", options.bitrate_kbps);
let settings = match encoder_name {
+ // libx264 / libx265 both take -b:v, -minrate and -maxrate for
+ // CBR; VBR is the CRF that already shipped.
+ // Real CBR needs `nal-hrd=cbr` on x264, and `strict-cbr=1` on
+ // libx265. Without it x264 caps at maxrate but does not pad the
+ // output to b:v on content that does not need the bitrate, so an
+ // "8000k CBR" export of a calm clip comes out at whatever the
+ // content costs, not 8000k.
+ "libx264" if cbr => ffmpeg::dict! {
+ "preset" => options.preset.as_str(),
+ "b:v" => bitrate.as_str(),
+ "minrate" => bitrate.as_str(),
+ "maxrate" => bitrate.as_str(),
+ "bufsize" => bufsize.as_str(),
+ "x264-params" => "nal-hrd=cbr:force-cfr=1",
+ },
+ "libx265" if cbr => ffmpeg::dict! {
+ "preset" => options.preset.as_str(),
+ "b:v" => bitrate.as_str(),
+ "minrate" => bitrate.as_str(),
+ "maxrate" => bitrate.as_str(),
+ "bufsize" => bufsize.as_str(),
+ "x265-params" => "strict-cbr=1",
+ },
"libx264" | "libx265" => ffmpeg::dict! {
"preset" => options.preset.as_str(),
"crf" => crf.as_str(),
@@ -643,6 +711,8 @@ mod tests {
codec,
preset: "ultrafast".to_owned(),
crf: 24,
+ rate_mode: RateMode::Vbr,
+ bitrate_kbps: 0,
ten_bit,
hardware: true,
};
diff --git a/src/crates/concat-media/src/lib.rs b/src/crates/concat-media/src/lib.rs
index c64842ce..33560e71 100644
--- a/src/crates/concat-media/src/lib.rs
+++ b/src/crates/concat-media/src/lib.rs
@@ -26,7 +26,7 @@ pub mod samples;
pub mod treat;
pub use decode::{ColorSignal, DecodeOptions, Decoder, FrameSource, SeekableSource};
-pub use encode::{EncodeOptions, Encoder, FrameSink, VideoCodec, jpeg};
+pub use encode::{EncodeOptions, Encoder, FrameSink, RateMode, VideoCodec, jpeg};
pub use error::{Error, Result};
pub use ffi::{init, linked_version};
pub use hardware::{HwDevice, HwPolicy, hardware_decode, set_hardware_decode};
diff --git a/src/crates/concat/locales/de.json b/src/crates/concat/locales/de.json
index eee381f7..0dc60a3e 100644
--- a/src/crates/concat/locales/de.json
+++ b/src/crates/concat/locales/de.json
@@ -25,6 +25,7 @@
"Add track": "Spur hinzufügen",
"Added {0} captions": "{0} Untertitel hinzugefügt",
"Adjust": "Anpassen",
+ "Advanced": "Advanced",
"Air and presence: a lift above six kilohertz.": "Luft und Präsenz: eine Anhebung über sechs Kilohertz.",
"All media": "Alle Medien",
"almost done": "fast fertig",
@@ -47,6 +48,7 @@
"Basic": "Grundlagen",
"Bass": "Bass",
"Big square pixels.": "Große quadratische Pixel.",
+ "Bitrate": "Bitrate",
"Bits": "Bits",
"Black & White": "Schwarz-Weiß",
"Blacks": "Schwarztöne",
@@ -74,6 +76,7 @@
"Caption": "Untertitel",
"Captions": "Untertitel",
"Cathedral": "Kathedrale",
+ "CBR": "CBR",
"Center": "Zentriert",
"Centre": "Mitte",
"Centre X": "Mitte X",
@@ -100,6 +103,8 @@
"CONTENTS": "INHALT",
"Contents": "Inhalt",
"Pan tool": "Pan tool",
+ "Show advanced options": "Show advanced options",
+ "Target bitrate": "Target bitrate",
"Timeline shortcuts": "Timeline shortcuts",
"Contrast": "Kontrast",
"Contrast Pop": "Kontrast-Pop",
@@ -138,6 +143,7 @@
"Original source": "Ursprüngliche Quelle",
"Custom URL": "Eigene URL",
"For mainland China": "Für Festlandchina",
+ "VBR": "VBR",
"Where each model came from": "Wo jedes Modell herkommt",
"A mirror of your own": "Ein eigener Spiegel",
"Models are fetched the first time a feature needs one. This is where the download looks first; every other source is still tried after it.": "Modelle werden geladen, wenn eine Funktion sie zum ersten Mal braucht. Hier sucht der Download zuerst; alle anderen Quellen werden danach trotzdem versucht.",
diff --git a/src/crates/concat/locales/en.json b/src/crates/concat/locales/en.json
index 5121c2c6..4a2a35f0 100644
--- a/src/crates/concat/locales/en.json
+++ b/src/crates/concat/locales/en.json
@@ -34,6 +34,7 @@
"Added {0} captions": "Added {0} captions",
"Address": "Address",
"Adjust": "Adjust",
+ "Advanced": "Advanced",
"Age": "Age",
"Air and presence: a lift above six kilohertz.": "Air and presence: a lift above six kilohertz.",
"All media": "All media",
@@ -62,6 +63,7 @@
"Basic": "Basic",
"Bass": "Bass",
"Big square pixels.": "Big square pixels.",
+ "Bitrate": "Bitrate",
"Bits": "Bits",
"Black & White": "Black & White",
"Black and white through a coloured filter: red darkens skies and lightens skin, green does the reverse. A little grain if you want it.": "Black and white through a coloured filter: red darkens skies and lightens skin, green does the reverse. A little grain if you want it.",
@@ -97,6 +99,7 @@
"Caption": "Caption",
"Captions": "Captions",
"Cathedral": "Cathedral",
+ "CBR": "CBR",
"Center": "Center",
"Centre": "Centre",
"Centre X": "Centre X",
@@ -559,6 +562,7 @@
"Shift": "Shift",
"Shifts the picture towards candlelight.": "Shifts the picture towards candlelight.",
"Shifts the picture towards daylight shade.": "Shifts the picture towards daylight shade.",
+ "Show advanced options": "Show advanced options",
"Show in folder": "Show in folder",
"Show lane": "Show lane",
"Show the log": "Show the log",
@@ -615,6 +619,7 @@
"Takes the hum and hiss out from under the voice.": "Takes the hum and hiss out from under the voice.",
"Takes the room's hiss and hum out from under the voice.": "Takes the room's hiss and hum out from under the voice.",
"Target": "Target",
+ "Target bitrate": "Target bitrate",
"Teal & Orange": "Teal & Orange",
"Teal in the shadows, orange in the highlights, skin held as skin, a film curve over it. The blockbuster grade, and the most requested look there is.": "Teal in the shadows, orange in the highlights, skin held as skin, a film curve over it. The blockbuster grade, and the most requested look there is.",
"Tear": "Tear",
@@ -676,6 +681,7 @@
"Unpacking…": "Unpacking…",
"Untitled project": "Untitled project",
"Up or down by semitones, the length untouched.": "Up or down by semitones, the length untouched.",
+ "VBR": "VBR",
"Vertical": "Vertical",
"VHS": "VHS",
"Vibrance": "Vibrance",
diff --git a/src/crates/concat/locales/es.json b/src/crates/concat/locales/es.json
index 872f55c8..ed3ae29e 100644
--- a/src/crates/concat/locales/es.json
+++ b/src/crates/concat/locales/es.json
@@ -25,6 +25,7 @@
"Add track": "Añadir pista",
"Added {0} captions": "{0} subtítulos añadidos",
"Adjust": "Ajustar",
+ "Advanced": "Advanced",
"Air and presence: a lift above six kilohertz.": "Aire y presencia: un realce por encima de seis kilohercios.",
"All media": "Todos los medios",
"almost done": "casi listo",
@@ -47,6 +48,7 @@
"Basic": "Básico",
"Bass": "Graves",
"Big square pixels.": "Píxeles grandes y cuadrados.",
+ "Bitrate": "Bitrate",
"Bits": "Bits",
"Black & White": "Blanco y negro",
"Blacks": "Negros",
@@ -74,6 +76,7 @@
"Caption": "Subtítulo",
"Captions": "Subtítulos",
"Cathedral": "Catedral",
+ "CBR": "CBR",
"Center": "Centro",
"Centre": "Centro",
"Centre X": "Centro X",
@@ -100,6 +103,8 @@
"CONTENTS": "CONTENIDO",
"Contents": "Contenido",
"Pan tool": "Pan tool",
+ "Show advanced options": "Show advanced options",
+ "Target bitrate": "Target bitrate",
"Timeline shortcuts": "Timeline shortcuts",
"Contrast": "Contraste",
"Contrast Pop": "Contraste vivo",
@@ -138,6 +143,7 @@
"Original source": "Fuente original",
"Custom URL": "URL personalizada",
"For mainland China": "Para China continental",
+ "VBR": "VBR",
"Where each model came from": "De donde salió cada modelo",
"A mirror of your own": "Un espejo propio",
"Models are fetched the first time a feature needs one. This is where the download looks first; every other source is still tried after it.": "Los modelos se descargan la primera vez que una función los necesita. Aquí busca primero la descarga; el resto de fuentes se prueban después.",
diff --git a/src/crates/concat/locales/fr.json b/src/crates/concat/locales/fr.json
index 103fc6e9..e958ea34 100644
--- a/src/crates/concat/locales/fr.json
+++ b/src/crates/concat/locales/fr.json
@@ -25,6 +25,7 @@
"Add track": "Ajouter une piste",
"Added {0} captions": "{0} sous-titres ajoutés",
"Adjust": "Réglages",
+ "Advanced": "Advanced",
"Air and presence: a lift above six kilohertz.": "Air et présence : un relèvement au-dessus de six kilohertz.",
"All media": "Tous les médias",
"almost done": "presque fini",
@@ -47,6 +48,7 @@
"Basic": "Base",
"Bass": "Basses",
"Big square pixels.": "De gros pixels carrés.",
+ "Bitrate": "Bitrate",
"Bits": "Bits",
"Black & White": "Noir et blanc",
"Blacks": "Noirs",
@@ -74,6 +76,7 @@
"Caption": "Sous-titre",
"Captions": "Sous-titres",
"Cathedral": "Cathédrale",
+ "CBR": "CBR",
"Center": "Centré",
"Centre": "Centre",
"Centre X": "Centre X",
@@ -100,6 +103,8 @@
"CONTENTS": "CONTENU",
"Contents": "Contenu",
"Pan tool": "Pan tool",
+ "Show advanced options": "Show advanced options",
+ "Target bitrate": "Target bitrate",
"Timeline shortcuts": "Timeline shortcuts",
"Contrast": "Contraste",
"Contrast Pop": "Contraste vif",
@@ -138,6 +143,7 @@
"Original source": "Source d'origine",
"Custom URL": "URL personnalisée",
"For mainland China": "Pour la Chine continentale",
+ "VBR": "VBR",
"Where each model came from": "D'où vient chaque modèle",
"A mirror of your own": "Un miroir à vous",
"Models are fetched the first time a feature needs one. This is where the download looks first; every other source is still tried after it.": "Les modèles sont téléchargés la première fois qu'une fonction en a besoin. C'est ici que le téléchargement cherche d'abord ; les autres sources sont essayées ensuite.",
diff --git a/src/crates/concat/locales/hr.json b/src/crates/concat/locales/hr.json
index 72a67500..86871c74 100644
--- a/src/crates/concat/locales/hr.json
+++ b/src/crates/concat/locales/hr.json
@@ -30,6 +30,7 @@
"Add track": "Dodaj traku",
"Added {0} captions": "Dodano {0} titlova",
"Adjust": "Prilagodi",
+ "Advanced": "Advanced",
"Age": "Dob",
"Air and presence: a lift above six kilohertz.": "Zrak i prisutnost: podizanje iznad šest kiloherca.",
"All media": "Svi mediji",
@@ -57,6 +58,7 @@
"Basic": "Osnovno",
"Bass": "Bas",
"Big square pixels.": "Veliki kvadratni pikseli.",
+ "Bitrate": "Bitrate",
"Bits": "Bitovi",
"Black & White": "Crno-bijelo",
"Black and white through a coloured filter: red darkens skies and lightens skin, green does the reverse. A little grain if you want it.": "Crno-bijelo kroz obojeni filtar: crvena tamni nebesa i svijetli kožu, zelena radi obrnuto. Malo zrna ako želite.",
@@ -92,6 +94,7 @@
"Caption": "Titl",
"Captions": "Titlovi",
"Cathedral": "Katedrala",
+ "CBR": "CBR",
"Center": "Sredina",
"Centre": "Sredina",
"Centre X": "Sredina X",
@@ -126,6 +129,8 @@
"CONTENTS": "SADRŽAJ",
"Contents": "Sadržaj",
"Pan tool": "Pan tool",
+ "Show advanced options": "Show advanced options",
+ "Target bitrate": "Target bitrate",
"Timeline shortcuts": "Prečaci na traci",
"Contrast": "Kontrast",
"Contrast Pop": "Kontrastni pop",
@@ -171,6 +176,7 @@
"Original source": "Izvorni izvor",
"Custom URL": "Vlastiti URL",
"For mainland China": "Za kontinentalnu Kinu",
+ "VBR": "VBR",
"Where each model came from": "Odakle svaki model dolazi",
"A mirror of your own": "Vlastito zrcalo",
"Models are fetched the first time a feature needs one. This is where the download looks first; every other source is still tried after it.": "Modeli se preuzimaju kad ih neka značajka prvi put zatreba. Ovdje preuzimanje traži prvo; ostali izvori se ipak isprobaju nakon toga.",
diff --git a/src/crates/concat/locales/it.json b/src/crates/concat/locales/it.json
index 02952dc6..20a3429f 100644
--- a/src/crates/concat/locales/it.json
+++ b/src/crates/concat/locales/it.json
@@ -25,6 +25,7 @@
"Add track": "Aggiungi traccia",
"Added {0} captions": "{0} sottotitoli aggiunti",
"Adjust": "Regola",
+ "Advanced": "Advanced",
"Air and presence: a lift above six kilohertz.": "Aria e presenza: un'enfasi sopra i sei kilohertz.",
"All media": "Tutti i media",
"almost done": "quasi fatto",
@@ -47,6 +48,7 @@
"Basic": "Base",
"Bass": "Bassi",
"Big square pixels.": "Grandi pixel quadrati.",
+ "Bitrate": "Bitrate",
"Bits": "Bit",
"Black & White": "Bianco e nero",
"Blacks": "Neri",
@@ -74,6 +76,7 @@
"Caption": "Sottotitolo",
"Captions": "Sottotitoli",
"Cathedral": "Cattedrale",
+ "CBR": "CBR",
"Center": "Centro",
"Centre": "Centro",
"Centre X": "Centro X",
@@ -100,6 +103,8 @@
"CONTENTS": "CONTENUTO",
"Contents": "Contenuto",
"Pan tool": "Pan tool",
+ "Show advanced options": "Show advanced options",
+ "Target bitrate": "Target bitrate",
"Timeline shortcuts": "Timeline shortcuts",
"Contrast": "Contrasto",
"Contrast Pop": "Contrasto vivo",
@@ -138,6 +143,7 @@
"Original source": "Fonte originale",
"Custom URL": "URL personalizzato",
"For mainland China": "Per la Cina continentale",
+ "VBR": "VBR",
"Where each model came from": "Da dove viene ogni modello",
"A mirror of your own": "Un mirror tuo",
"Models are fetched the first time a feature needs one. This is where the download looks first; every other source is still tried after it.": "I modelli vengono scaricati la prima volta che una funzione ne ha bisogno. Qui il download cerca per primo; le altre fonti vengono comunque provate dopo.",
diff --git a/src/crates/concat/locales/ja.json b/src/crates/concat/locales/ja.json
index 3dbe4f3a..8f303422 100644
--- a/src/crates/concat/locales/ja.json
+++ b/src/crates/concat/locales/ja.json
@@ -25,6 +25,7 @@
"Add track": "トラックを追加",
"Added {0} captions": "{0} 件の字幕を追加しました",
"Adjust": "調整",
+ "Advanced": "Advanced",
"Air and presence: a lift above six kilohertz.": "空気感と存在感:6 kHz 以上を持ち上げます。",
"All media": "すべてのメディア",
"almost done": "まもなく完了",
@@ -47,6 +48,7 @@
"Basic": "基本",
"Bass": "低音",
"Big square pixels.": "大きな正方形のピクセル。",
+ "Bitrate": "Bitrate",
"Bits": "ビット",
"Black & White": "白黒",
"Blacks": "黒レベル",
@@ -74,6 +76,7 @@
"Caption": "字幕",
"Captions": "字幕",
"Cathedral": "大聖堂",
+ "CBR": "CBR",
"Center": "中央",
"Centre": "中央",
"Centre X": "中心 X",
@@ -100,6 +103,8 @@
"CONTENTS": "内容",
"Contents": "内容",
"Pan tool": "Pan tool",
+ "Show advanced options": "Show advanced options",
+ "Target bitrate": "Target bitrate",
"Timeline shortcuts": "Timeline shortcuts",
"Contrast": "コントラスト",
"Contrast Pop": "コントラストポップ",
@@ -138,6 +143,7 @@
"Original source": "元の配布元",
"Custom URL": "カスタム URL",
"For mainland China": "中国本土向け",
+ "VBR": "VBR",
"Where each model came from": "各モデルの元の場所",
"A mirror of your own": "自分のミラー",
"Models are fetched the first time a feature needs one. This is where the download looks first; every other source is still tried after it.": "モデルは機能が初めて必要とした時に取得されます。ここで指定した場所を最初に探し、その後も他の配布元をすべて試します。",
diff --git a/src/crates/concat/locales/ko.json b/src/crates/concat/locales/ko.json
index 0f23732a..0787ffb7 100644
--- a/src/crates/concat/locales/ko.json
+++ b/src/crates/concat/locales/ko.json
@@ -25,6 +25,7 @@
"Add track": "트랙 추가",
"Added {0} captions": "자막 {0}개를 추가했습니다",
"Adjust": "조정",
+ "Advanced": "Advanced",
"Air and presence: a lift above six kilohertz.": "공기감과 존재감: 6kHz 이상을 올립니다.",
"All media": "모든 미디어",
"almost done": "거의 완료",
@@ -47,6 +48,7 @@
"Basic": "기본",
"Bass": "저음",
"Big square pixels.": "큰 정사각형 픽셀.",
+ "Bitrate": "Bitrate",
"Bits": "비트",
"Black & White": "흑백",
"Blacks": "검정 계열",
@@ -74,6 +76,7 @@
"Caption": "자막",
"Captions": "자막",
"Cathedral": "대성당",
+ "CBR": "CBR",
"Center": "가운데",
"Centre": "가운데",
"Centre X": "중심 X",
@@ -100,6 +103,8 @@
"CONTENTS": "내용",
"Contents": "내용",
"Pan tool": "Pan tool",
+ "Show advanced options": "Show advanced options",
+ "Target bitrate": "Target bitrate",
"Timeline shortcuts": "Timeline shortcuts",
"Contrast": "대비",
"Contrast Pop": "선명한 대비",
@@ -138,6 +143,7 @@
"Original source": "원본 출처",
"Custom URL": "사용자 지정 URL",
"For mainland China": "중국 본토용",
+ "VBR": "VBR",
"Where each model came from": "각 모델의 원래 출처",
"A mirror of your own": "직접 운영하는 미러",
"Models are fetched the first time a feature needs one. This is where the download looks first; every other source is still tried after it.": "모델은 기능이 처음 필요로 할 때 내려받습니다. 여기서 먼저 찾고, 그다음에도 다른 출처를 모두 시도합니다.",
diff --git a/src/crates/concat/locales/pt-BR.json b/src/crates/concat/locales/pt-BR.json
index f220a2c6..b7f2a349 100644
--- a/src/crates/concat/locales/pt-BR.json
+++ b/src/crates/concat/locales/pt-BR.json
@@ -25,6 +25,7 @@
"Add track": "Adicionar faixa",
"Added {0} captions": "{0} legendas adicionadas",
"Adjust": "Ajustar",
+ "Advanced": "Advanced",
"Air and presence: a lift above six kilohertz.": "Ar e presença: um realce acima de seis quilohertz.",
"All media": "Todas as mídias",
"almost done": "quase pronto",
@@ -47,6 +48,7 @@
"Basic": "Básico",
"Bass": "Graves",
"Big square pixels.": "Pixels grandes e quadrados.",
+ "Bitrate": "Bitrate",
"Bits": "Bits",
"Black & White": "Preto e branco",
"Blacks": "Pretos",
@@ -74,6 +76,7 @@
"Caption": "Legenda",
"Captions": "Legendas",
"Cathedral": "Catedral",
+ "CBR": "CBR",
"Center": "Centro",
"Centre": "Centro",
"Centre X": "Centro X",
@@ -100,6 +103,8 @@
"CONTENTS": "CONTEÚDO",
"Contents": "Conteúdo",
"Pan tool": "Pan tool",
+ "Show advanced options": "Show advanced options",
+ "Target bitrate": "Target bitrate",
"Timeline shortcuts": "Timeline shortcuts",
"Contrast": "Contraste",
"Contrast Pop": "Contraste vivo",
@@ -138,6 +143,7 @@
"Original source": "Fonte original",
"Custom URL": "URL personalizada",
"For mainland China": "Para a China continental",
+ "VBR": "VBR",
"Where each model came from": "De onde cada modelo veio",
"A mirror of your own": "Um espelho seu",
"Models are fetched the first time a feature needs one. This is where the download looks first; every other source is still tried after it.": "Os modelos são baixados na primeira vez que um recurso precisa deles. Aqui o download procura primeiro; as outras fontes ainda são tentadas depois.",
diff --git a/src/crates/concat/locales/ru.json b/src/crates/concat/locales/ru.json
index 2926ed53..5c970719 100644
--- a/src/crates/concat/locales/ru.json
+++ b/src/crates/concat/locales/ru.json
@@ -25,6 +25,7 @@
"Add track": "Добавить дорожку",
"Added {0} captions": "Добавлено субтитров: {0}",
"Adjust": "Коррекция",
+ "Advanced": "Advanced",
"Air and presence: a lift above six kilohertz.": "Воздух и присутствие: подъём выше шести килогерц.",
"All media": "Все медиа",
"almost done": "почти готово",
@@ -47,6 +48,7 @@
"Basic": "Основное",
"Bass": "Низкие",
"Big square pixels.": "Крупные квадратные пиксели.",
+ "Bitrate": "Bitrate",
"Bits": "Биты",
"Black & White": "Чёрно-белое",
"Blacks": "Чёрные",
@@ -74,6 +76,7 @@
"Caption": "Субтитр",
"Captions": "Субтитры",
"Cathedral": "Собор",
+ "CBR": "CBR",
"Center": "По центру",
"Centre": "Центр",
"Centre X": "Центр X",
@@ -100,6 +103,8 @@
"CONTENTS": "СОДЕРЖИМОЕ",
"Contents": "Содержимое",
"Pan tool": "Pan tool",
+ "Show advanced options": "Show advanced options",
+ "Target bitrate": "Target bitrate",
"Timeline shortcuts": "Timeline shortcuts",
"Contrast": "Контраст",
"Contrast Pop": "Сочный контраст",
@@ -138,6 +143,7 @@
"Original source": "Исходный источник",
"Custom URL": "Свой URL",
"For mainland China": "Для материкового Китая",
+ "VBR": "VBR",
"Where each model came from": "Откуда взята каждая модель",
"A mirror of your own": "Собственное зеркало",
"Models are fetched the first time a feature needs one. This is where the download looks first; every other source is still tried after it.": "Модели загружаются, когда функция впервые в них нуждается. Здесь загрузка ищет в первую очередь; остальные источники всё равно проверяются после.",
diff --git a/src/crates/concat/locales/tr.json b/src/crates/concat/locales/tr.json
index 50013ca9..46db8782 100644
--- a/src/crates/concat/locales/tr.json
+++ b/src/crates/concat/locales/tr.json
@@ -25,6 +25,7 @@
"Add track": "Parça ekle",
"Added {0} captions": "{0} altyazı eklendi",
"Adjust": "Ayarla",
+ "Advanced": "Advanced",
"Air and presence: a lift above six kilohertz.": "Hava ve varlık: altı kilohertz üzerinde bir yükseltme.",
"All media": "Tüm medya",
"almost done": "neredeyse bitti",
@@ -47,6 +48,7 @@
"Basic": "Temel",
"Bass": "Bas",
"Big square pixels.": "Büyük kare pikseller.",
+ "Bitrate": "Bitrate",
"Bits": "Bit",
"Black & White": "Siyah-Beyaz",
"Blacks": "Siyahlar",
@@ -74,6 +76,7 @@
"Caption": "Altyazı",
"Captions": "Altyazılar",
"Cathedral": "Katedral",
+ "CBR": "CBR",
"Center": "Ortala",
"Centre": "Orta",
"Centre X": "Merkez X",
@@ -100,6 +103,8 @@
"CONTENTS": "İÇERİK",
"Contents": "İçerik",
"Pan tool": "Pan tool",
+ "Show advanced options": "Show advanced options",
+ "Target bitrate": "Target bitrate",
"Timeline shortcuts": "Timeline shortcuts",
"Contrast": "Kontrast",
"Contrast Pop": "Canlı kontrast",
@@ -138,6 +143,7 @@
"Original source": "Özgün kaynak",
"Custom URL": "Özel URL",
"For mainland China": "Çin anakarası için",
+ "VBR": "VBR",
"Where each model came from": "Her modelin geldiği yer",
"A mirror of your own": "Kendi yansınız",
"Models are fetched the first time a feature needs one. This is where the download looks first; every other source is still tried after it.": "Modeller bir özellik ilk kez ihtiyaç duyduğunda indirilir. İndirme önce buraya bakar; diğer tüm kaynaklar yine de sonra denenir.",
diff --git a/src/crates/concat/locales/zh-Hans.json b/src/crates/concat/locales/zh-Hans.json
index ffe1a390..7f1c9333 100644
--- a/src/crates/concat/locales/zh-Hans.json
+++ b/src/crates/concat/locales/zh-Hans.json
@@ -25,6 +25,7 @@
"Add track": "添加轨道",
"Added {0} captions": "已添加 {0} 条字幕",
"Adjust": "调整",
+ "Advanced": "Advanced",
"Air and presence: a lift above six kilohertz.": "空气感与临场感:提升 6 kHz 以上的频段。",
"All media": "全部媒体",
"almost done": "即将完成",
@@ -47,6 +48,7 @@
"Basic": "基础",
"Bass": "低音",
"Big square pixels.": "大块的方形像素。",
+ "Bitrate": "Bitrate",
"Bits": "位数",
"Black & White": "黑白",
"Blacks": "黑色色阶",
@@ -74,6 +76,7 @@
"Caption": "字幕",
"Captions": "字幕",
"Cathedral": "教堂",
+ "CBR": "CBR",
"Center": "居中",
"Centre": "居中",
"Centre X": "中心 X",
@@ -100,6 +103,8 @@
"CONTENTS": "内容",
"Contents": "内容",
"Pan tool": "Pan tool",
+ "Show advanced options": "Show advanced options",
+ "Target bitrate": "Target bitrate",
"Timeline shortcuts": "Timeline shortcuts",
"Contrast": "对比度",
"Contrast Pop": "对比增强",
@@ -138,6 +143,7 @@
"Original source": "原始来源",
"Custom URL": "自定义 URL",
"For mainland China": "适用于中国大陆",
+ "VBR": "VBR",
"Where each model came from": "各模型的原始出处",
"A mirror of your own": "你自己的镜像",
"Models are fetched the first time a feature needs one. This is where the download looks first; every other source is still tried after it.": "模型会在功能首次需要时下载。下载会先从这里查找;之后仍会尝试其他所有来源。",
diff --git a/src/crates/concat/locales/zh-TW.json b/src/crates/concat/locales/zh-TW.json
index 0f3a9f53..e1a7e61f 100644
--- a/src/crates/concat/locales/zh-TW.json
+++ b/src/crates/concat/locales/zh-TW.json
@@ -30,6 +30,7 @@
"Add track": "新增軌道",
"Added {0} captions": "已新增 {0} 段字幕",
"Adjust": "調整",
+ "Advanced": "Advanced",
"Age": "老化程度",
"Air and presence: a lift above six kilohertz.": "提升 6 kHz 以上的頻段,增添空氣感與臨場感。",
"All media": "所有媒體",
@@ -57,6 +58,7 @@
"Basic": "基本",
"Bass": "低音",
"Big square pixels.": "放大成方形像素。",
+ "Bitrate": "Bitrate",
"Bits": "位元",
"Black & White": "黑白",
"Black and white through a coloured filter: red darkens skies and lightens skin, green does the reverse. A little grain if you want it.": "透過彩色濾鏡呈現黑白影像:紅色會壓暗天空、提亮膚色,綠色則相反。也可依喜好加上些許顆粒。",
@@ -92,6 +94,7 @@
"Caption": "字幕",
"Captions": "字幕",
"Cathedral": "大教堂",
+ "CBR": "CBR",
"Center": "置中",
"Centre": "置中",
"Centre X": "中心 X 座標",
@@ -126,6 +129,8 @@
"CONTENTS": "內容",
"Contents": "內容",
"Pan tool": "Pan tool",
+ "Show advanced options": "Show advanced options",
+ "Target bitrate": "Target bitrate",
"Timeline shortcuts": "Timeline shortcuts",
"Contrast": "對比度",
"Contrast Pop": "強化對比",
@@ -171,6 +176,7 @@
"Original source": "原始來源",
"Custom URL": "自訂 URL",
"For mainland China": "適用於中國大陸",
+ "VBR": "VBR",
"Where each model came from": "各模型的原始出處",
"A mirror of your own": "你自己的鏡像",
"Models are fetched the first time a feature needs one. This is where the download looks first; every other source is still tried after it.": "模型會在功能首次需要時下載。下載會先從這裡尋找;之後仍會嘗試其他所有來源。",
diff --git a/src/crates/concat/src/lib.rs b/src/crates/concat/src/lib.rs
index 8b95f489..a9fed3a4 100644
--- a/src/crates/concat/src/lib.rs
+++ b/src/crates/concat/src/lib.rs
@@ -995,6 +995,15 @@ pub fn run() -> Result<(), slint::PlatformError> {
app.on_export_ten_bit_changed(on_window!(|state, on: bool| {
state.handle(Msg::Export(ExportMsg::TenBitChanged(on)));
}));
+ app.on_export_advanced_toggled(on_window!(|state, on: bool| {
+ state.handle(Msg::Export(ExportMsg::AdvancedToggled(on)));
+ }));
+ app.on_export_rate_mode_changed(on_window!(|state, index: i32| {
+ state.handle(Msg::Export(ExportMsg::RateModeChanged(index)));
+ }));
+ app.on_export_bitrate_changed(on_window!(|state, text: SharedString| {
+ state.handle(Msg::Export(ExportMsg::BitrateChanged(text.to_string())));
+ }));
app.on_export_again(on_window!(|state| {
state.handle(Msg::Export(ExportMsg::Again));
}));
diff --git a/src/crates/concat/src/panes/export.rs b/src/crates/concat/src/panes/export.rs
index 4a2a83bd..a6539300 100644
--- a/src/crates/concat/src/panes/export.rs
+++ b/src/crates/concat/src/panes/export.rs
@@ -38,6 +38,12 @@ pub enum ExportMsg {
QualityChanged(i32),
CodecChanged(i32),
TenBitChanged(bool),
+ /// The Advanced section is opened or closed.
+ AdvancedToggled(bool),
+ /// VBR or CBR.
+ RateModeChanged(i32),
+ /// The target bitrate field: digits only, in kbps.
+ BitrateChanged(String),
/// Back to the form after a finished or failed render.
Again,
/// Pick the destination folder.
@@ -68,6 +74,13 @@ pub struct ExportPane {
/// Index into `VideoCodec::ALL`.
pub codec: usize,
pub ten_bit: bool,
+ /// The Advanced section is open: bitrate controls show, and the size
+ /// estimate reads the chosen bitrate.
+ pub advanced: bool,
+ /// Index into `RateMode::ALL`.
+ pub rate_mode: usize,
+ /// Target bitrate in kbps, used when `rate_mode` is CBR.
+ pub bitrate: u32,
pub phase: ExportPhase,
pub progress: f32,
pub stage: String,
@@ -89,6 +102,9 @@ impl Default for ExportPane {
quality: 1,
codec: 0,
ten_bit: false,
+ advanced: false,
+ rate_mode: 0,
+ bitrate: 8000,
phase: ExportPhase::Idle,
progress: 0.0,
stage: String::new(),
@@ -120,6 +136,14 @@ impl ExportPane {
ExportMsg::QualityChanged(index) => self.quality = (index.max(0) as usize).min(2),
ExportMsg::CodecChanged(index) => self.codec = (index.max(0) as usize).min(2),
ExportMsg::TenBitChanged(on) => self.ten_bit = on,
+ ExportMsg::AdvancedToggled(on) => self.advanced = on,
+ ExportMsg::RateModeChanged(index) => self.rate_mode = index.max(0) as usize,
+ ExportMsg::BitrateChanged(text) => {
+ let digits: String = text.chars().filter(|c| c.is_ascii_digit()).collect();
+ if let Ok(value) = digits.parse::<u32>() {
+ self.bitrate = value.clamp(100, 200_000);
+ }
+ }
ExportMsg::Again => {
self.phase = ExportPhase::Idle;
self.progress = 0.0;
@@ -187,12 +211,18 @@ impl ExportPane {
let (num, den) = EXPORT_RATES[self.rate.min(2)];
let rate = num as f32 / den as f32;
let pixels = (width as f32 * height as f32) / (1920.0 * 1080.0);
- let video = EXPORT_TIERS[tier.min(2)]
- * 1_000_000.0
- * pixels
- * (rate / 30.0)
- * self.codec().size_factor()
- * if self.ten_bit { 1.05 } else { 1.0 };
+ // In CBR the bitrate is the number, not the tier; the pixels, rate
+ // and codec factors no longer apply because the encoder is pinned.
+ let video = if self.advanced && self.rate_mode == 1 {
+ self.bitrate as f32 * 1000.0
+ } else {
+ EXPORT_TIERS[tier.min(2)]
+ * 1_000_000.0
+ * pixels
+ * (rate / 30.0)
+ * self.codec().size_factor()
+ * if self.ten_bit { 1.05 } else { 1.0 }
+ };
(video + AUDIO_BPS) * studio.duration().max(1.0) / 8.0
}
@@ -230,6 +260,16 @@ impl ExportPane {
preset: "veryfast".into(),
codec: self.codec(),
ten_bit: self.ten_bit,
+ rate_mode: if self.advanced && self.rate_mode == 1 {
+ concat_media::RateMode::Cbr
+ } else {
+ concat_media::RateMode::Vbr
+ },
+ bitrate_kbps: if self.advanced && self.rate_mode == 1 {
+ self.bitrate
+ } else {
+ 0
+ },
};
let (frame_w, frame_h) = studio.output_size();
let titles = studio
@@ -311,6 +351,9 @@ impl ExportPane {
quality: self.quality as i32,
codec: self.codec as i32,
ten_bit: self.ten_bit,
+ advanced: self.advanced,
+ rate_mode: self.rate_mode as i32,
+ bitrate: self.bitrate as i32,
encoding: {
// "HEVC 10-bit · hardware": the standard, the depth when it
// is the deeper one, and whether the platform's own encoder
diff --git a/src/crates/concat/ui/app.slint b/src/crates/concat/ui/app.slint
index b98e523d..a4dff730 100644
--- a/src/crates/concat/ui/app.slint
+++ b/src/crates/concat/ui/app.slint
@@ -178,6 +178,9 @@ export component App inherits Window {
callback export-quality-changed(index: int);
callback export-codec-changed(index: int);
callback export-ten-bit-changed(on: bool);
+ callback export-advanced-toggled(on: bool);
+ callback export-rate-mode-changed(index: int);
+ callback export-bitrate-changed(text: string);
callback export-start();
callback export-cancel();
callback export-reveal();
@@ -466,6 +469,9 @@ export component App inherits Window {
quality-changed(index) => { root.export-quality-changed(index); }
codec-changed(index) => { root.export-codec-changed(index); }
ten-bit-changed(on) => { root.export-ten-bit-changed(on); }
+ advanced-toggled(on) => { root.export-advanced-toggled(on); }
+ rate-mode-changed(index) => { root.export-rate-mode-changed(index); }
+ bitrate-changed(text) => { root.export-bitrate-changed(text); }
begin => { root.export-start(); }
cancel => { root.export-cancel(); }
reveal => { root.export-reveal(); }
diff --git a/src/crates/concat/ui/dialogs/export.slint b/src/crates/concat/ui/dialogs/export.slint
index aee77560..8e710e35 100644
--- a/src/crates/concat/ui/dialogs/export.slint
+++ b/src/crates/concat/ui/dialogs/export.slint
@@ -34,6 +34,12 @@ export struct ExportData {
/// index into the codec list: H.264, HEVC, AV1
codec: int,
ten-bit: bool,
+ /// The Advanced section is open: bitrate controls show.
+ advanced: bool,
+ /// 0 = VBR, 1 = CBR.
+ rate-mode: int,
+ /// Target bitrate in kbps, used when rate-mode is CBR.
+ bitrate: int,
/// "HEVC 10-bit · hardware": what the file will be encoded as
encoding: string,
/// What each preset would weigh. Three strings rather than a list: a Slint
@@ -160,6 +166,9 @@ export component ExportDialog inherits Modal {
callback quality-changed(index: int);
callback codec-changed(index: int);
callback ten-bit-changed(on: bool);
+ callback advanced-toggled(on: bool);
+ callback rate-mode-changed(index: int);
+ callback bitrate-changed(text: string);
callback begin();
callback cancel();
callback reveal();
@@ -305,6 +314,38 @@ export component ExportDialog inherits Modal {
}
}
+ if !root.running: DialogSection {
+ title: I18n.t("Advanced");
+
+ DialogRow {
+ label: I18n.t("Show advanced options");
+ Switch {
+ checked: root.data.advanced;
+ toggled(on) => { root.advanced-toggled(on); }
+ }
+ }
+ }
+
+ if !root.running && root.data.advanced: DialogSection {
+ title: I18n.t("Bitrate");
+
+ DialogRow {
+ label: I18n.t("Mode");
+ Select {
+ current: root.data.rate-mode;
+ options: [I18n.t("VBR"), I18n.t("CBR")];
+ changed(index) => { root.rate-mode-changed(index); }
+ }
+ }
+ if root.data.rate-mode == 1: DialogRow {
+ label: I18n.t("Target bitrate");
+ Field {
+ value: root.data.bitrate + " kbps";
+ edited(text) => { root.bitrate-changed(text); }
+ }
+ }
+ }
+
// ── the footer ───────────────────────────────────────────────────
Rectangle {
height: 1px;