Skip to content

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

feat(export): a transparent project exports with its alpha - ProRes 4444 or VP9 alpha on the sheet, everything else laid over black (#456)

Jareer470391e747cb
diff --git a/src/crates/concat-api/src/lib.rs b/src/crates/concat-api/src/lib.rs
index ed482cc9..647f00b2 100644
--- a/src/crates/concat-api/src/lib.rs
+++ b/src/crates/concat-api/src/lib.rs
@@ -689,7 +689,7 @@ impl Api {
None if hdr => export::VideoCodec::Hevc,
None => export::VideoCodec::H264,
Some(name) => export::VideoCodec::parse(name).ok_or_else(|| {
- ApiError::invalid(format!("unknown codec {name:?}: h264, hevc or av1"))
+ ApiError::invalid(format!("unknown codec {name:?}: h264, hevc, av1, prores-4444 or vp9-alpha"))
})?,
};
if hdr && codec == export::VideoCodec::H264 {
diff --git a/src/crates/concat-export/src/lib.rs b/src/crates/concat-export/src/lib.rs
index cc12b831..f1c07efb 100644
--- a/src/crates/concat-export/src/lib.rs
+++ b/src/crates/concat-export/src/lib.rs
@@ -415,7 +415,7 @@ fn unity() -> f64 {
/// Everything a full export needs: the destination, the output format, and
/// the flattened clip list.
-#[derive(Deserialize)]
+#[derive(Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ExportRequest {
/// The file to write. Siblings named `.{stem}.concat-*` are used as
@@ -1143,6 +1143,20 @@ pub fn render_on(
compositor: Option<WgpuCompositor>,
mut reporter: Reporter<'_>,
) -> Result<String, String> {
+ // A clear canvas bound for a format that keeps no alpha is laid over
+ // black first, as the frame is drawn, rather than having its alpha
+ // dropped by the encoder after: dropped, a soft edge or a glow keeps
+ // its full colour and comes out as a solid halo (#456).
+ let flattened;
+ let request = if request.canvas[3] < 255 && !request.codec.keeps_alpha() {
+ flattened = ExportRequest {
+ canvas: over_black(request.canvas),
+ ..request.clone()
+ };
+ &flattened
+ } else {
+ request
+ };
if !request.effect_time_offset.is_finite()
|| request.effect_time_offset.abs() > concat_project::model::ranges::MAX_TIME
{
@@ -2311,6 +2325,13 @@ pub struct PreviewFrameRequest {
pub canvas: [u8; 4],
}
+/// A straight `[r, g, b, a]` canvas laid over opaque black: what a frame
+/// with no alpha to keep shows where nothing covers it.
+fn over_black([r, g, b, a]: [u8; 4]) -> [u8; 4] {
+ let weigh = |level: u8| ((u16::from(level) * u16::from(a) + 127) / 255) as u8;
+ [weigh(r), weigh(g), weigh(b), 255]
+}
+
/// The canvas of a request that does not name one: what every frame had
/// before there was a choice. Not `[u8; 4]`'s default, which is clear.
fn opaque_black() -> [u8; 4] {
@@ -3723,8 +3744,10 @@ mod tests {
) else {
return; // no ffmpeg here
};
+ let mut red = Frame::black(64, 64);
+ red.fill([200, 40, 40, 255]);
for _ in 0..15 {
- encoder.write_frame(&Frame::black(64, 64)).expect("writes");
+ encoder.write_frame(&red).expect("writes");
}
encoder.finish().expect("finishes");
// Half a second of a 440 Hz tone, 16-bit stereo at 48 kHz.
@@ -3764,11 +3787,14 @@ mod tests {
footage.media_width = Some(64);
footage.media_height = Some(64);
footage.has_audio = Some(false);
+ // Half the frame's size on a clear canvas: the corners are what
+ // the file has to keep clear, and the middle the picture (#456).
+ footage.scale = 0.5;
let mut sound = clip("audio", 1, 0.0, 0.5, 0.0);
sound.path = tone.to_string_lossy().into_owned();
sound.has_audio = Some(true);
let request = |codec: VideoCodec, output: &Path| ExportRequest {
- canvas: [0, 0, 0],
+ canvas: [0, 0, 0, 0],
output: output.to_string_lossy().into_owned(),
width: 64,
height: 64,
@@ -3816,6 +3842,17 @@ mod tests {
let info = concat_media::probe(&output).expect("probes");
assert_eq!(info.video.expect("a picture").codec, picture);
assert_eq!(info.audio.expect("a sound").codec, heard);
+ let mut decoder = Decoder::open(&output, &DecodeOptions::default()).expect("opens");
+ let frame = decoder.next_frame().expect("decodes").expect("a frame");
+ let corner = frame.pixel(2, 2).expect("a pixel");
+ let middle = frame.pixel(32, 32).expect("a pixel");
+ assert!(corner[3] <= 4, "{}: the corner is {corner:?}", codec.label());
+ assert!(middle[3] >= 250, "{}: the middle is {middle:?}", codec.label());
+ assert!(
+ middle[0].abs_diff(200) <= 12 && middle[1].abs_diff(40) <= 12,
+ "{}: the middle is {middle:?}",
+ codec.label()
+ );
let leftovers: Vec<_> = std::fs::read_dir(&dir)
.expect("lists")
.filter_map(|entry| entry.ok())
@@ -3823,6 +3860,24 @@ mod tests {
.collect();
assert!(leftovers.is_empty(), "scratch files are removed");
}
+
+ // An .mp4 keeps no alpha, so the clear canvas is laid over black as
+ // the frame is drawn: a half-faded picture comes out half way to
+ // black, not at its full colour with the alpha dropped after.
+ let mut faded = footage.clone();
+ faded.opacity = 0.5;
+ let output = dir.join("flat.mp4");
+ render(&ExportRequest {
+ clips: vec![faded],
+ ..request(VideoCodec::H264, &output)
+ })
+ .expect("an .mp4 of a clear canvas renders");
+ let mut decoder = Decoder::open(&output, &DecodeOptions::default()).expect("opens");
+ let frame = decoder.next_frame().expect("decodes").expect("a frame");
+ let middle = frame.pixel(32, 32).expect("a pixel");
+ assert!((130..=170).contains(&middle[0]), "the middle is {middle:?}");
+ let corner = frame.pixel(2, 2).expect("a pixel");
+ assert!(corner[0] <= 8 && corner[3] == 255, "the corner is {corner:?}");
let _ = std::fs::remove_dir_all(&dir);
}
diff --git a/src/crates/concat/locales/ar.json b/src/crates/concat/locales/ar.json
index 4a1b2cbb..088ec304 100644
--- a/src/crates/concat/locales/ar.json
+++ b/src/crates/concat/locales/ar.json
@@ -245,8 +245,11 @@
"export.format": "الصيغة",
"export.halfTheSize": "نصف الحجم",
"export.hardware": "عتاد",
+ "export.keepsTransparencyMov": "شفاف · لبرامج المونتاج، كبير",
+ "export.keepsTransparencyWebm": "شفاف · للويب وOBS، صغير",
"export.mixingAudio": "جارٍ مزج الصوت",
"export.nameNeedsToBeAFileName": "يجب أن يكون الاسم اسم ملف: غير فارغ، ولا يحتوي أيًّا من / \\ : * ? \" < > |",
+ "export.noTransparency": "هذه الصيغة لا تحفظ الشفافية: الأجزاء الشفافة تظهر سوداء. ProRes 4444 أو VP9 alpha تحفظانها.",
"export.notOnThisDevice": "غير متوفر على هذا الجهاز",
"export.nothingTimelineExport": "لا يوجد شيء على المخطط الزمني لتصديره",
"export.nothingToExport": "لا شيء للتصدير",
diff --git a/src/crates/concat/locales/az.json b/src/crates/concat/locales/az.json
index c14a4ef1..73f9415c 100644
--- a/src/crates/concat/locales/az.json
+++ b/src/crates/concat/locales/az.json
@@ -245,8 +245,11 @@
"export.format": "Format",
"export.halfTheSize": "Yarı ölçüdə",
"export.hardware": "aparat",
+ "export.keepsTransparencyMov": "Şəffaf · redaktorlar üçün, böyük",
+ "export.keepsTransparencyWebm": "Şəffaf · veb və OBS üçün, kiçik",
"export.mixingAudio": "Səs qarışdırılır",
"export.nameNeedsToBeAFileName": "Ad fayl adı olmalıdır: boş olmasın və bu simvollar olmasın: / \\ : * ? \" < > |",
+ "export.noTransparency": "Bu format şəffaflığı saxlamır: şəffaf hissələr qara çıxır. ProRes 4444 və ya VP9 alpha onu saxlayır.",
"export.notOnThisDevice": "Bu cihazda yoxdur",
"export.nothingTimelineExport": "Zaman xəttində ixrac ediləcək heç nə yoxdur",
"export.nothingToExport": "İxrac ediləcək heç nə yoxdur",
diff --git a/src/crates/concat/locales/bn.json b/src/crates/concat/locales/bn.json
index f6622a95..b2f9814a 100644
--- a/src/crates/concat/locales/bn.json
+++ b/src/crates/concat/locales/bn.json
@@ -245,8 +245,11 @@
"export.format": "ফরম্যাট",
"export.halfTheSize": "অর্ধেক আকার",
"export.hardware": "হার্ডওয়্যার",
+ "export.keepsTransparencyMov": "স্বচ্ছ · এডিটরের জন্য, বড়",
+ "export.keepsTransparencyWebm": "স্বচ্ছ · ওয়েব ও OBS-এর জন্য, ছোট",
"export.mixingAudio": "অডিও মিক্স করা হচ্ছে",
"export.nameNeedsToBeAFileName": "নামটি একটি ফাইলের নাম হতে হবে: খালি নয়, এবং / \\ : * ? \" < > | এগুলো থাকবে না",
+ "export.noTransparency": "এই ফরম্যাট স্বচ্ছতা রাখে না: স্বচ্ছ অংশ কালো হয়ে যায়। ProRes 4444 বা VP9 alpha তা রাখে।",
"export.notOnThisDevice": "এই ডিভাইসে নেই",
"export.nothingTimelineExport": "টাইমলাইনে এক্সপোর্ট করার মতো কিছু নেই",
"export.nothingToExport": "এক্সপোর্ট করার মতো কিছু নেই",
diff --git a/src/crates/concat/locales/de.json b/src/crates/concat/locales/de.json
index a8fadab2..0f062b79 100644
--- a/src/crates/concat/locales/de.json
+++ b/src/crates/concat/locales/de.json
@@ -245,8 +245,11 @@
"export.format": "Format",
"export.halfTheSize": "Halb so groß",
"export.hardware": "Hardware",
+ "export.keepsTransparencyMov": "Transparent · für Schnittprogramme, groß",
+ "export.keepsTransparencyWebm": "Transparent · für Web und OBS, klein",
"export.mixingAudio": "Ton wird gemischt",
"export.nameNeedsToBeAFileName": "Der Name muss ein Dateiname sein: nicht leer und ohne / \\ : * ? \" < > |",
+ "export.noTransparency": "Dieses Format behält keine Transparenz: Durchsichtiges wird schwarz. ProRes 4444 oder VP9 alpha behalten sie.",
"export.notOnThisDevice": "Nicht auf diesem Gerät",
"export.nothingTimelineExport": "Auf der Zeitleiste gibt es nichts zu exportieren",
"export.nothingToExport": "Nichts zu exportieren",
diff --git a/src/crates/concat/locales/en.json b/src/crates/concat/locales/en.json
index 186a07d1..523fa4e4 100644
--- a/src/crates/concat/locales/en.json
+++ b/src/crates/concat/locales/en.json
@@ -245,8 +245,11 @@
"export.format": "Format",
"export.halfTheSize": "Half the size",
"export.hardware": "hardware",
+ "export.keepsTransparencyMov": "Transparent · for editors, large",
+ "export.keepsTransparencyWebm": "Transparent · for web and OBS, small",
"export.mixingAudio": "Mixing audio",
"export.nameNeedsToBeAFileName": "The name has to be a file name: not empty, and none of / \\ : * ? \" < > |",
+ "export.noTransparency": "This format keeps no transparency: the clear parts come out black. ProRes 4444 or VP9 alpha keep it.",
"export.notOnThisDevice": "Not on this device",
"export.nothingTimelineExport": "There is nothing on the timeline to export",
"export.nothingToExport": "Nothing to export",
diff --git a/src/crates/concat/locales/es.json b/src/crates/concat/locales/es.json
index 9d4aa152..6630ce18 100644
--- a/src/crates/concat/locales/es.json
+++ b/src/crates/concat/locales/es.json
@@ -245,8 +245,11 @@
"export.format": "Formato",
"export.halfTheSize": "La mitad de tamaño",
"export.hardware": "hardware",
+ "export.keepsTransparencyMov": "Transparente · para editores, grande",
+ "export.keepsTransparencyWebm": "Transparente · para web y OBS, pequeño",
"export.mixingAudio": "Mezclando el audio",
"export.nameNeedsToBeAFileName": "El nombre tiene que ser un nombre de archivo: no vacío y sin / \\ : * ? \" < > |",
+ "export.noTransparency": "Este formato no conserva la transparencia: lo transparente sale negro. ProRes 4444 o VP9 alpha la conservan.",
"export.notOnThisDevice": "No disponible en este dispositivo",
"export.nothingTimelineExport": "No hay nada en la línea de tiempo que exportar",
"export.nothingToExport": "Nada que exportar",
diff --git a/src/crates/concat/locales/fa.json b/src/crates/concat/locales/fa.json
index 688b3b86..99bdfbcf 100644
--- a/src/crates/concat/locales/fa.json
+++ b/src/crates/concat/locales/fa.json
@@ -245,8 +245,11 @@
"export.format": "فرمت",
"export.halfTheSize": "نصف اندازه",
"export.hardware": "سخت‌افزار",
+ "export.keepsTransparencyMov": "شفاف · برای نرم‌افزارهای تدوین، بزرگ",
+ "export.keepsTransparencyWebm": "شفاف · برای وب و OBS، کوچک",
"export.mixingAudio": "در حال میکس کردن صدا",
"export.nameNeedsToBeAFileName": "نام باید نام یک فایل باشد: خالی نباشد و بدون / \\ : * ? \" < > |",
+ "export.noTransparency": "این قالب شفافیت را نگه نمی‌دارد: بخش‌های شفاف سیاه می‌شوند. ProRes 4444 یا VP9 alpha آن را نگه می‌دارند.",
"export.notOnThisDevice": "در این دستگاه نیست",
"export.nothingTimelineExport": "چیزی روی تایم‌لاین برای خروجی گرفتن وجود ندارد",
"export.nothingToExport": "چیزی برای خروجی گرفتن وجود ندارد",
diff --git a/src/crates/concat/locales/fr.json b/src/crates/concat/locales/fr.json
index 75aeaeeb..6d7107ef 100644
--- a/src/crates/concat/locales/fr.json
+++ b/src/crates/concat/locales/fr.json
@@ -245,8 +245,11 @@
"export.format": "Format",
"export.halfTheSize": "Deux fois plus petit",
"export.hardware": "matériel",
+ "export.keepsTransparencyMov": "Transparent · pour les logiciels de montage, lourd",
+ "export.keepsTransparencyWebm": "Transparent · pour le web et OBS, léger",
"export.mixingAudio": "Mixage de l'audio",
"export.nameNeedsToBeAFileName": "Le nom doit être un nom de fichier : non vide et sans / \\ : * ? \" < > |",
+ "export.noTransparency": "Ce format ne garde pas la transparence : les parties transparentes sortent en noir. ProRes 4444 ou VP9 alpha la gardent.",
"export.notOnThisDevice": "Pas sur cet appareil",
"export.nothingTimelineExport": "Il n'y a rien à exporter sur la timeline",
"export.nothingToExport": "Rien à exporter",
diff --git a/src/crates/concat/locales/he.json b/src/crates/concat/locales/he.json
index aa9e2f06..3e20397f 100644
--- a/src/crates/concat/locales/he.json
+++ b/src/crates/concat/locales/he.json
@@ -245,8 +245,11 @@
"export.format": "פורמט",
"export.halfTheSize": "חצי מהגודל",
"export.hardware": "חומרה",
+ "export.keepsTransparencyMov": "שקוף · לתוכנות עריכה, גדול",
+ "export.keepsTransparencyWebm": "שקוף · לרשת ול־OBS, קטן",
"export.mixingAudio": "מערבב שמע",
"export.nameNeedsToBeAFileName": "השם חייב להיות שם קובץ: לא ריק, ובלי אף אחד מהתווים / \\ : * ? \" < > |",
+ "export.noTransparency": "פורמט זה לא שומר על שקיפות: החלקים השקופים יוצאים שחורים. ProRes 4444 או VP9 alpha שומרים עליה.",
"export.notOnThisDevice": "לא במכשיר הזה",
"export.nothingTimelineExport": "אין בציר הזמן שום דבר לייצוא",
"export.nothingToExport": "אין מה לייצא",
diff --git a/src/crates/concat/locales/hi.json b/src/crates/concat/locales/hi.json
index b5f2f3a3..a90c5152 100644
--- a/src/crates/concat/locales/hi.json
+++ b/src/crates/concat/locales/hi.json
@@ -245,8 +245,11 @@
"export.format": "फ़ॉर्मेट",
"export.halfTheSize": "आधा साइज़",
"export.hardware": "हार्डवेयर",
+ "export.keepsTransparencyMov": "पारदर्शी · एडिटर के लिए, बड़ा",
+ "export.keepsTransparencyWebm": "पारदर्शी · वेब और OBS के लिए, छोटा",
"export.mixingAudio": "ऑडियो मिक्स हो रहा है",
"export.nameNeedsToBeAFileName": "नाम एक फ़ाइल नाम होना चाहिए: खाली नहीं, और इनमें से कोई चिह्न नहीं: / \\ : * ? \" < > |",
+ "export.noTransparency": "यह फ़ॉर्मैट पारदर्शिता नहीं रखता: पारदर्शी हिस्से काले आते हैं। ProRes 4444 या VP9 alpha इसे रखते हैं।",
"export.notOnThisDevice": "इस डिवाइस पर उपलब्ध नहीं",
"export.nothingTimelineExport": "टाइमलाइन पर एक्सपोर्ट करने के लिए कुछ नहीं है",
"export.nothingToExport": "एक्सपोर्ट करने के लिए कुछ नहीं",
diff --git a/src/crates/concat/locales/hr.json b/src/crates/concat/locales/hr.json
index 37aeb6c7..622f5cec 100644
--- a/src/crates/concat/locales/hr.json
+++ b/src/crates/concat/locales/hr.json
@@ -245,8 +245,11 @@
"export.format": "Format",
"export.halfTheSize": "Upola manje",
"export.hardware": "hardver",
+ "export.keepsTransparencyMov": "Prozirno · za programe za montažu, veliko",
+ "export.keepsTransparencyWebm": "Prozirno · za web i OBS, malo",
"export.mixingAudio": "Miksanje zvuka",
"export.nameNeedsToBeAFileName": "Naziv mora biti naziv datoteke: ne prazan i bez / \\ : * ? \" < > |",
+ "export.noTransparency": "Ovaj format ne čuva prozirnost: prozirni dijelovi izlaze crni. ProRes 4444 ili VP9 alpha je čuvaju.",
"export.notOnThisDevice": "Nije na ovom uređaju",
"export.nothingTimelineExport": "Na vremenskoj liniji nema ničega za izvoz",
"export.nothingToExport": "Ništa za izvoz",
diff --git a/src/crates/concat/locales/id.json b/src/crates/concat/locales/id.json
index 37e625a8..28fb3656 100644
--- a/src/crates/concat/locales/id.json
+++ b/src/crates/concat/locales/id.json
@@ -245,8 +245,11 @@
"export.format": "Format",
"export.halfTheSize": "Setengah ukuran",
"export.hardware": "perangkat keras",
+ "export.keepsTransparencyMov": "Transparan · untuk editor, besar",
+ "export.keepsTransparencyWebm": "Transparan · untuk web dan OBS, kecil",
"export.mixingAudio": "Mencampur audio",
"export.nameNeedsToBeAFileName": "Nama harus berupa nama file: tidak kosong, dan tanpa / \\ : * ? \" < > |",
+ "export.noTransparency": "Format ini tidak menyimpan transparansi: bagian transparan jadi hitam. ProRes 4444 atau VP9 alpha menyimpannya.",
"export.notOnThisDevice": "Tidak tersedia di perangkat ini",
"export.nothingTimelineExport": "Tidak ada apa pun di linimasa untuk diekspor",
"export.nothingToExport": "Tidak ada yang bisa diekspor",
diff --git a/src/crates/concat/locales/it.json b/src/crates/concat/locales/it.json
index 628ff6e2..cd64e878 100644
--- a/src/crates/concat/locales/it.json
+++ b/src/crates/concat/locales/it.json
@@ -245,8 +245,11 @@
"export.format": "Formato",
"export.halfTheSize": "Metà delle dimensioni",
"export.hardware": "hardware",
+ "export.keepsTransparencyMov": "Trasparente · per i programmi di montaggio, pesante",
+ "export.keepsTransparencyWebm": "Trasparente · per web e OBS, leggero",
"export.mixingAudio": "Mixaggio dell'audio",
"export.nameNeedsToBeAFileName": "Il nome deve essere un nome di file: non vuoto e senza / \\ : * ? \" < > |",
+ "export.noTransparency": "Questo formato non mantiene la trasparenza: le parti trasparenti escono nere. ProRes 4444 o VP9 alpha la mantengono.",
"export.notOnThisDevice": "Non su questo dispositivo",
"export.nothingTimelineExport": "Non c'è nulla sulla timeline da esportare",
"export.nothingToExport": "Niente da esportare",
diff --git a/src/crates/concat/locales/ja.json b/src/crates/concat/locales/ja.json
index c2852980..37441c72 100644
--- a/src/crates/concat/locales/ja.json
+++ b/src/crates/concat/locales/ja.json
@@ -245,8 +245,11 @@
"export.format": "形式",
"export.halfTheSize": "半分のサイズ",
"export.hardware": "ハードウェア",
+ "export.keepsTransparencyMov": "透明 · 編集ソフト向け、大きい",
+ "export.keepsTransparencyWebm": "透明 · Web・OBS 向け、小さい",
"export.mixingAudio": "オーディオをミックス中",
"export.nameNeedsToBeAFileName": "名前はファイル名にしてください。空にせず、/ \\ : * ? \" < > | は使えません",
+ "export.noTransparency": "この形式は透明を保持しません。透明な部分は黒になります。ProRes 4444 か VP9 alpha なら保持します。",
"export.notOnThisDevice": "このデバイスでは使用不可",
"export.nothingTimelineExport": "タイムラインに書き出すものがありません",
"export.nothingToExport": "書き出すものがありません",
diff --git a/src/crates/concat/locales/ko.json b/src/crates/concat/locales/ko.json
index 4ca5b561..0b42e994 100644
--- a/src/crates/concat/locales/ko.json
+++ b/src/crates/concat/locales/ko.json
@@ -245,8 +245,11 @@
"export.format": "형식",
"export.halfTheSize": "절반 크기",
"export.hardware": "하드웨어",
+ "export.keepsTransparencyMov": "투명 · 편집 프로그램용, 큼",
+ "export.keepsTransparencyWebm": "투명 · 웹·OBS용, 작음",
"export.mixingAudio": "오디오 믹싱 중",
"export.nameNeedsToBeAFileName": "이름은 파일 이름이어야 합니다. 비워 둘 수 없고 / \\ : * ? \" < > | 는 쓸 수 없습니다",
+ "export.noTransparency": "이 형식은 투명도를 유지하지 않습니다. 투명한 부분은 검게 나옵니다. ProRes 4444 또는 VP9 alpha는 유지합니다.",
"export.notOnThisDevice": "이 기기에서 사용 불가",
"export.nothingTimelineExport": "타임라인에 내보낼 것이 없습니다",
"export.nothingToExport": "내보낼 것이 없습니다",
diff --git a/src/crates/concat/locales/nl.json b/src/crates/concat/locales/nl.json
index cd54f4d0..a71eefc2 100644
--- a/src/crates/concat/locales/nl.json
+++ b/src/crates/concat/locales/nl.json
@@ -245,8 +245,11 @@
"export.format": "Indeling",
"export.halfTheSize": "Half zo groot",
"export.hardware": "hardware",
+ "export.keepsTransparencyMov": "Transparant · voor montageprogramma's, groot",
+ "export.keepsTransparencyWebm": "Transparant · voor web en OBS, klein",
"export.mixingAudio": "Audio mixen",
"export.nameNeedsToBeAFileName": "De naam moet een bestandsnaam zijn: niet leeg, en zonder / \\ : * ? \" < > |",
+ "export.noTransparency": "Dit formaat houdt geen transparantie: doorzichtige delen worden zwart. ProRes 4444 of VP9 alpha houden die wel.",
"export.notOnThisDevice": "Niet op dit apparaat",
"export.nothingTimelineExport": "Er staat niets op de tijdlijn om te exporteren",
"export.nothingToExport": "Niets om te exporteren",
diff --git a/src/crates/concat/locales/pl.json b/src/crates/concat/locales/pl.json
index f8983901..51230148 100644
--- a/src/crates/concat/locales/pl.json
+++ b/src/crates/concat/locales/pl.json
@@ -245,8 +245,11 @@
"export.format": "Format",
"export.halfTheSize": "O połowę mniejszy",
"export.hardware": "sprzętowo",
+ "export.keepsTransparencyMov": "Przezroczyste · do programów montażowych, duże",
+ "export.keepsTransparencyWebm": "Przezroczyste · do sieci i OBS, małe",
"export.mixingAudio": "Miksowanie dźwięku",
"export.nameNeedsToBeAFileName": "Nazwa musi być nazwą pliku: niepusta i bez znaków / \\ : * ? \" < > |",
+ "export.noTransparency": "Ten format nie zachowuje przezroczystości: przezroczyste części będą czarne. ProRes 4444 lub VP9 alpha ją zachowują.",
"export.notOnThisDevice": "Niedostępne na tym urządzeniu",
"export.nothingTimelineExport": "Na osi czasu nie ma nic do wyeksportowania",
"export.nothingToExport": "Nic do wyeksportowania",
diff --git a/src/crates/concat/locales/pt-BR.json b/src/crates/concat/locales/pt-BR.json
index 1d068eea..cfe89251 100644
--- a/src/crates/concat/locales/pt-BR.json
+++ b/src/crates/concat/locales/pt-BR.json
@@ -245,8 +245,11 @@
"export.format": "Formato",
"export.halfTheSize": "Metade do tamanho",
"export.hardware": "hardware",
+ "export.keepsTransparencyMov": "Transparente · para editores, grande",
+ "export.keepsTransparencyWebm": "Transparente · para web e OBS, pequeno",
"export.mixingAudio": "Mixando o áudio",
"export.nameNeedsToBeAFileName": "O nome precisa ser um nome de arquivo: não vazio e sem / \\ : * ? \" < > |",
+ "export.noTransparency": "Este formato não mantém a transparência: as partes transparentes saem pretas. ProRes 4444 ou VP9 alpha mantêm.",
"export.notOnThisDevice": "Indisponível neste dispositivo",
"export.nothingTimelineExport": "Não há nada na linha do tempo para exportar",
"export.nothingToExport": "Nada para exportar",
diff --git a/src/crates/concat/locales/ru.json b/src/crates/concat/locales/ru.json
index 8d561166..2cf73877 100644
--- a/src/crates/concat/locales/ru.json
+++ b/src/crates/concat/locales/ru.json
@@ -245,8 +245,11 @@
"export.format": "Формат",
"export.halfTheSize": "Вдвое меньше",
"export.hardware": "аппаратно",
+ "export.keepsTransparencyMov": "Прозрачный · для монтажных программ, большой",
+ "export.keepsTransparencyWebm": "Прозрачный · для веба и OBS, маленький",
"export.mixingAudio": "Сведение звука",
"export.nameNeedsToBeAFileName": "Имя должно быть именем файла: не пустым и без / \\ : * ? \" < > |",
+ "export.noTransparency": "Этот формат не сохраняет прозрачность: прозрачные места будут чёрными. ProRes 4444 или VP9 alpha сохраняют её.",
"export.notOnThisDevice": "Недоступно на этом устройстве",
"export.nothingTimelineExport": "На таймлайне нечего экспортировать",
"export.nothingToExport": "Нечего экспортировать",
diff --git a/src/crates/concat/locales/th.json b/src/crates/concat/locales/th.json
index 0b482a2a..e8f5ab8d 100644
--- a/src/crates/concat/locales/th.json
+++ b/src/crates/concat/locales/th.json
@@ -245,8 +245,11 @@
"export.format": "รูปแบบ",
"export.halfTheSize": "ขนาดครึ่งเดียว",
"export.hardware": "ฮาร์ดแวร์",
+ "export.keepsTransparencyMov": "โปร่งใส · สำหรับโปรแกรมตัดต่อ, ไฟล์ใหญ่",
+ "export.keepsTransparencyWebm": "โปร่งใส · สำหรับเว็บและ OBS, ไฟล์เล็ก",
"export.mixingAudio": "กำลังมิกซ์เสียง",
"export.nameNeedsToBeAFileName": "ชื่อต้องเป็นชื่อไฟล์ที่ใช้ได้: ห้ามว่าง และห้ามมี / \\ : * ? \" < > |",
+ "export.noTransparency": "รูปแบบนี้ไม่เก็บความโปร่งใส ส่วนที่โปร่งใสจะเป็นสีดำ ProRes 4444 หรือ VP9 alpha เก็บไว้ได้",
"export.notOnThisDevice": "ไม่มีในอุปกรณ์นี้",
"export.nothingTimelineExport": "ไม่มีอะไรบนไทม์ไลน์ให้ส่งออก",
"export.nothingToExport": "ไม่มีอะไรให้ส่งออก",
diff --git a/src/crates/concat/locales/tr.json b/src/crates/concat/locales/tr.json
index 3980d6de..9f71e46f 100644
--- a/src/crates/concat/locales/tr.json
+++ b/src/crates/concat/locales/tr.json
@@ -245,8 +245,11 @@
"export.format": "Biçim",
"export.halfTheSize": "Yarı boyut",
"export.hardware": "donanım",
+ "export.keepsTransparencyMov": "Saydam · düzenleyiciler için, büyük",
+ "export.keepsTransparencyWebm": "Saydam · web ve OBS için, küçük",
"export.mixingAudio": "Ses karıştırılıyor",
"export.nameNeedsToBeAFileName": "Ad bir dosya adı olmalı: boş olmamalı ve / \\ : * ? \" < > | içermemeli",
+ "export.noTransparency": "Bu biçim saydamlığı korumaz: saydam yerler siyah çıkar. ProRes 4444 veya VP9 alpha korur.",
"export.notOnThisDevice": "Bu cihazda yok",
"export.nothingTimelineExport": "Zaman çizelgesinde dışa aktarılacak bir şey yok",
"export.nothingToExport": "Dışa aktarılacak bir şey yok",
diff --git a/src/crates/concat/locales/uk.json b/src/crates/concat/locales/uk.json
index ff51120f..0b0c741c 100644
--- a/src/crates/concat/locales/uk.json
+++ b/src/crates/concat/locales/uk.json
@@ -245,8 +245,11 @@
"export.format": "Формат",
"export.halfTheSize": "Удвічі менший розмір",
"export.hardware": "апаратно",
+ "export.keepsTransparencyMov": "Прозорий · для монтажних програм, великий",
+ "export.keepsTransparencyWebm": "Прозорий · для вебу та OBS, малий",
"export.mixingAudio": "Зведення аудіо",
"export.nameNeedsToBeAFileName": "Назва має бути іменем файлу: не порожньою й без символів / \\ : * ? \" < > |",
+ "export.noTransparency": "Цей формат не зберігає прозорість: прозорі місця будуть чорними. ProRes 4444 або VP9 alpha її зберігають.",
"export.notOnThisDevice": "Недоступно на цьому пристрої",
"export.nothingTimelineExport": "На часовій шкалі немає нічого для експорту",
"export.nothingToExport": "Нічого експортувати",
diff --git a/src/crates/concat/locales/ur.json b/src/crates/concat/locales/ur.json
index 1632b105..65f95ddc 100644
--- a/src/crates/concat/locales/ur.json
+++ b/src/crates/concat/locales/ur.json
@@ -245,8 +245,11 @@
"export.format": "فارمیٹ",
"export.halfTheSize": "آدھا سائز",
"export.hardware": "ہارڈویئر",
+ "export.keepsTransparencyMov": "شفاف · ایڈیٹرز کے لیے، بڑا",
+ "export.keepsTransparencyWebm": "شفاف · ویب اور OBS کے لیے، چھوٹا",
"export.mixingAudio": "آڈیو مکس ہو رہا ہے",
"export.nameNeedsToBeAFileName": "نام فائل کا نام ہونا چاہیے: خالی نہ ہو، اور اس میں / \\ : * ? \" < > | میں سے کچھ نہ ہو",
+ "export.noTransparency": "یہ فارمیٹ شفافیت نہیں رکھتا: شفاف حصے سیاہ آتے ہیں۔ ProRes 4444 یا VP9 alpha اسے رکھتے ہیں۔",
"export.notOnThisDevice": "اس ڈیوائس پر نہیں",
"export.nothingTimelineExport": "ٹائم لائن پر ایکسپورٹ کرنے کے لیے کچھ نہیں",
"export.nothingToExport": "ایکسپورٹ کے لیے کچھ نہیں",
diff --git a/src/crates/concat/locales/vi.json b/src/crates/concat/locales/vi.json
index 25fef029..5462d110 100644
--- a/src/crates/concat/locales/vi.json
+++ b/src/crates/concat/locales/vi.json
@@ -245,8 +245,11 @@
"export.format": "Định dạng",
"export.halfTheSize": "Một nửa kích thước",
"export.hardware": "phần cứng",
+ "export.keepsTransparencyMov": "Trong suốt · cho phần mềm dựng, lớn",
+ "export.keepsTransparencyWebm": "Trong suốt · cho web và OBS, nhỏ",
"export.mixingAudio": "Đang trộn âm thanh",
"export.nameNeedsToBeAFileName": "Tên phải là tên tệp: không được để trống và không chứa / \\: * ? \" < > |",
+ "export.noTransparency": "Định dạng này không giữ độ trong suốt: phần trong suốt sẽ thành màu đen. ProRes 4444 hoặc VP9 alpha giữ được.",
"export.notOnThisDevice": "Không có trên thiết bị này",
"export.nothingTimelineExport": "Không có gì trên dòng thời gian để xuất",
"export.nothingToExport": "Không có gì để xuất",
diff --git a/src/crates/concat/locales/zh-Hans.json b/src/crates/concat/locales/zh-Hans.json
index 2cc7b1ee..b70de879 100644
--- a/src/crates/concat/locales/zh-Hans.json
+++ b/src/crates/concat/locales/zh-Hans.json
@@ -245,8 +245,11 @@
"export.format": "格式",
"export.halfTheSize": "缩小一半",
"export.hardware": "硬件",
+ "export.keepsTransparencyMov": "透明 · 用于剪辑软件,体积大",
+ "export.keepsTransparencyWebm": "透明 · 用于网页和 OBS,体积小",
"export.mixingAudio": "正在混合音频",
"export.nameNeedsToBeAFileName": "名称必须是文件名:不能为空,也不能含有 / \\ : * ? \" < > |",
+ "export.noTransparency": "此格式不保留透明:透明部分会变成黑色。ProRes 4444 或 VP9 alpha 可以保留。",
"export.notOnThisDevice": "此设备不支持",
"export.nothingTimelineExport": "时间线上没有可导出的内容",
"export.nothingToExport": "没有可导出的内容",
diff --git a/src/crates/concat/locales/zh-TW.json b/src/crates/concat/locales/zh-TW.json
index 558eb44f..0677de11 100644
--- a/src/crates/concat/locales/zh-TW.json
+++ b/src/crates/concat/locales/zh-TW.json
@@ -245,8 +245,11 @@
"export.format": "格式",
"export.halfTheSize": "檔案大小減半",
"export.hardware": "硬體",
+ "export.keepsTransparencyMov": "透明 · 用於剪輯軟體,檔案大",
+ "export.keepsTransparencyWebm": "透明 · 用於網頁和 OBS,檔案小",
"export.mixingAudio": "正在混合音訊",
"export.nameNeedsToBeAFileName": "名稱必須是檔案名稱:不能為空,也不能含有 / \\ : * ? \" < > |",
+ "export.noTransparency": "此格式不保留透明:透明部分會變成黑色。ProRes 4444 或 VP9 alpha 可以保留。",
"export.notOnThisDevice": "此裝置不支援",
"export.nothingTimelineExport": "時間軸上沒有可匯出的內容",
"export.nothingToExport": "沒有可匯出的內容",
diff --git a/src/crates/concat/src/panes/export.rs b/src/crates/concat/src/panes/export.rs
index 0222aff4..94dceb67 100644
--- a/src/crates/concat/src/panes/export.rs
+++ b/src/crates/concat/src/panes/export.rs
@@ -138,6 +138,7 @@ impl ExportPane {
// and its own rate, first on the rate list.
self.resolution = Self::own_rung(studio);
self.rate = 0;
+ self.follow_canvas(studio);
}
ExportMsg::Close => self.open = false,
ExportMsg::NameEdited(name) => self.name = name,
@@ -366,6 +367,30 @@ impl ExportPane {
(video + AUDIO_BPS) * studio.duration().max(1.0) / 8.0
}
+ /// The codec a sheet opens on follows the canvas (#456): a timeline
+ /// that lets something show through opens on ProRes 4444, which every
+ /// editor takes with its alpha (VP9 where ProRes cannot be written),
+ /// and an opaque one leaves an alpha codec picked for an overlay
+ /// before for H.264, rather than writing it hundreds of megabits it
+ /// has no use for. Within the sheet the pick is the person's.
+ fn follow_canvas(&mut self, studio: &Studio) {
+ use concat_media::VideoCodec;
+ let chosen = VideoCodec::ALL[self.codec.min(VideoCodec::ALL.len() - 1)];
+ let see_through = studio.timeline().video.canvas[3] < 255;
+ let wanted = if see_through && !chosen.keeps_alpha() {
+ [VideoCodec::ProRes4444, VideoCodec::Vp9Alpha]
+ .into_iter()
+ .find(|codec| codec.encodable())
+ } else if !see_through && chosen.keeps_alpha() {
+ Some(VideoCodec::H264)
+ } else {
+ None
+ };
+ if let Some(index) = wanted.and_then(|codec| VideoCodec::ALL.iter().position(|c| *c == codec)) {
+ self.codec = index;
+ }
+ }
+
/// The codec the sheet has chosen - HEVC for an HDR file where H.264
/// was, since H.264 does not carry HDR.
pub fn codec(&self, studio: &Studio) -> concat_media::VideoCodec {
@@ -389,7 +414,10 @@ impl ExportPane {
concat_media::VideoCodec::H264 => concat_media::VideoCodec::Hevc,
codec => codec,
};
- studio.timeline().video.color_space.is_hdr()
+ // An overlay that keeps its alpha is written SDR: the export
+ // tone-maps an HDR timeline for it.
+ !chosen.keeps_alpha()
+ && studio.timeline().video.color_space.is_hdr()
&& !self.sdr
&& deep.ten_bit_available()
&& deep.encodable()
@@ -426,7 +454,11 @@ impl ExportPane {
self.message = t("export.nameNeedsToBeAFileName");
return;
};
- let output = format!("{}/{name}.mp4", self.folder.trim_end_matches('/'));
+ let output = format!(
+ "{}/{name}.{}",
+ self.folder.trim_end_matches('/'),
+ self.codec(studio).container()
+ );
// A file already there is replaced once the person has said so:
// the confirmation sheet asks, and its answer comes back as
// `Overwrite`. Nothing is written until then; the engine renders
@@ -541,6 +573,7 @@ impl ExportPane {
.iter()
.filter(|clip| clip.kind == concat_project::model::ClipKind::Text)
.count();
+ let container = self.codec(studio).container();
ExportData {
open: self.open,
name: self.name.as_str().into(),
@@ -548,9 +581,9 @@ impl ExportPane {
// shows, not the app's own that the export writes into.
// The name as it will be written: trimmed, as `begin` trims it.
path: match platform::published_folder() {
- Some(folder) => format!("{folder}/{}.mp4", self.name.trim()),
+ Some(folder) => format!("{folder}/{}.{container}", self.name.trim()),
None => format!(
- "{}/{}.mp4",
+ "{}/{}.{container}",
self.folder.trim_end_matches('/'),
self.name.trim()
),
@@ -599,6 +632,11 @@ impl ExportPane {
h264_encodable: concat_media::VideoCodec::H264.encodable(),
hevc_encodable: concat_media::VideoCodec::Hevc.encodable(),
av1_encodable: concat_media::VideoCodec::Av1.encodable(),
+ prores_encodable: concat_media::VideoCodec::ProRes4444.encodable(),
+ vp9_alpha_encodable: concat_media::VideoCodec::Vp9Alpha.encodable(),
+ see_through: studio.timeline().video.canvas[3] < 255,
+ keeps_alpha: self.codec(studio).keeps_alpha(),
+ rate_controlled: self.codec(studio).rate_controlled(),
ten_bit: self.ten_bit,
hdr_timeline: studio.timeline().video.color_space.is_hdr(),
hdr: self.hdr(studio),
diff --git a/src/crates/concat/ui/dialogs/export.slint b/src/crates/concat/ui/dialogs/export.slint
index 8262c4d8..0e19fccc 100644
--- a/src/crates/concat/ui/dialogs/export.slint
+++ b/src/crates/concat/ui/dialogs/export.slint
@@ -46,13 +46,25 @@ export struct ExportData {
/// it; the export is at the timeline's rate unless another is picked
rates: [string],
rate-details: [string],
- /// index into the codec list: H.264, HEVC, AV1
+ /// index into the codec list: H.264, HEVC, AV1, ProRes 4444, VP9 alpha
codec: int,
/// Which of them this device can encode. A phone's chip may lack
/// HEVC or AV1; the picker says so rather than failing on Export.
h264-encodable: bool,
hevc-encodable: bool,
av1-encodable: bool,
+ /// The two that keep a transparent frame's alpha (#456): ProRes 4444
+ /// in a .mov, and VP9 with alpha in a .webm, which a phone's FFmpeg
+ /// does not carry.
+ prores-encodable: bool,
+ vp9-alpha-encodable: bool,
+ /// The timeline's canvas lets something show through.
+ see-through: bool,
+ /// The codec picked keeps alpha.
+ keeps-alpha: bool,
+ /// The codec picked is held to a bitrate; ProRes is not, its profile
+ /// sets its rate.
+ rate-controlled: bool,
ten-bit: bool,
/// The timeline is HDR, so the file can be written HDR or SDR.
hdr-timeline: bool,
@@ -133,6 +145,9 @@ component PreviewSection inherits DialogSection {
in property <float> playhead;
in property <float> duration;
in property <float> frame-rate;
+ /// The frame lets something show through (#456): a checker under it,
+ /// as on the monitor.
+ in property <bool> see-through;
callback seek(seconds: float);
@@ -147,6 +162,18 @@ component PreviewSection inherits DialogSection {
background: Theme.stage;
clip: true;
+ // Under the frame's own rectangle, not the letterbox around it.
+ if root.see-through && root.frame.width > 0: Image {
+ property <float> aspect: root.frame.width / Math.max(1, root.frame.height);
+ width: Math.min(parent.width, parent.height * self.aspect);
+ height: Math.min(parent.height, parent.width / self.aspect);
+ x: (parent.width - self.width) / 2;
+ y: (parent.height - self.height) / 2;
+ source: @image-url("../assets/checker.png");
+ horizontal-tiling: repeat;
+ vertical-tiling: repeat;
+ }
+
Image {
width: 100%;
height: 100%;
@@ -325,16 +352,27 @@ component OutputSection inherits DialogSection {
label: I18n.t("export.codec");
Select {
current: root.data.codec;
- options: ["H.264", "HEVC", "AV1"];
+ options: ["H.264", "HEVC", "AV1", "ProRes 4444", "VP9 alpha"];
details: [
root.data.h264-encodable ? I18n.t("export.playsEverywhere") : I18n.t("export.notOnThisDevice"),
root.data.hevc-encodable ? I18n.t("export.halfTheSize") : I18n.t("export.notOnThisDevice"),
root.data.av1-encodable ? I18n.t("export.smallest") : I18n.t("export.notOnThisDevice"),
+ root.data.prores-encodable ? I18n.t("export.keepsTransparencyMov") : I18n.t("export.notOnThisDevice"),
+ root.data.vp9-alpha-encodable ? I18n.t("export.keepsTransparencyWebm") : I18n.t("export.notOnThisDevice"),
];
changed(index) => { root.codec-changed(index); }
}
}
+ // A transparent timeline in a format that keeps no alpha: said before
+ // Export rather than found in the file.
+ if root.data.see-through && !root.data.keeps-alpha: Text {
+ text: I18n.t("export.noTransparency");
+ color: Theme.fg-dim;
+ font-size: Theme.fs-sm;
+ wrap: word-wrap;
+ }
+
if root.data.hdr: DialogRow {
label: I18n.t("export.codec");
Select {
@@ -352,7 +390,7 @@ component OutputSection inherits DialogSection {
// recommendation, which every platform takes) until it is dragged,
// stepped or typed to another. The encoder keeps to it as an average,
// so the size on the Export button is the size written.
- DialogRow {
+ if root.data.rate-controlled: DialogRow {
label: I18n.t("export.bitrate");
HorizontalLayout {
alignment: end;
@@ -371,7 +409,9 @@ component OutputSection inherits DialogSection {
}
// HDR is ten bits always, so the switch is for SDR alone.
- if !root.data.hdr && root.data.deep-available: DialogRow {
+ // The alpha codecs have their depth set: ProRes 4444 is ten bits,
+ // VP9 with alpha eight.
+ if !root.data.hdr && root.data.deep-available && !root.data.keeps-alpha: DialogRow {
label: I18n.t("export.tenBitColour");
HorizontalLayout {
alignment: end;
@@ -720,6 +760,7 @@ export component ExportDialog inherits Rectangle {
playhead: root.playhead;
duration: root.duration-seconds;
frame-rate: root.frame-rate;
+ see-through: root.data.see-through;
seek(seconds) => { root.seek(seconds); }
}
SummarySection { data: root.data; }
@@ -760,6 +801,7 @@ export component ExportDialog inherits Rectangle {
playhead: root.playhead;
duration: root.duration-seconds;
frame-rate: root.frame-rate;
+ see-through: root.data.see-through;
seek(seconds) => { root.seek(seconds); }
}
SummarySection { data: root.data; }