Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat: Divisible width/height by 2, project config fix

Richie McIlroy2b9247d22060
diff --git a/apps/desktop/src/routes/editor/Header.tsx b/apps/desktop/src/routes/editor/Header.tsx
index e4a6edfab..2af5f7833 100644
--- a/apps/desktop/src/routes/editor/Header.tsx
+++ b/apps/desktop/src/routes/editor/Header.tsx
@@ -149,7 +149,7 @@ function ExportButton() {
}
function ShareButton() {
- const { videoId, presets } = useEditorContext();
+ const { videoId, project, presets } = useEditorContext();
const [meta, metaActions] = createResource(() =>
commands.getRecordingMeta(videoId, "recording")
);
@@ -158,7 +158,7 @@ function ShareButton() {
mutationFn: async () => {
const res = await commands.uploadRenderedVideo(
videoId,
- presets.getDefaultConfig() ?? DEFAULT_PROJECT_CONFIG
+ project ? project : presets.getDefaultConfig() ?? DEFAULT_PROJECT_CONFIG
);
if (res.status !== "ok") throw new Error(res.error);
},
diff --git a/crates/rendering/src/lib.rs b/crates/rendering/src/lib.rs
index df37b305f..4abc569bc 100644
--- a/crates/rendering/src/lib.rs
+++ b/crates/rendering/src/lib.rs
@@ -260,10 +260,9 @@ impl ProjectUniforms {
let aspect = match &project.aspect_ratio {
None => {
- return (
- (crop.size.x as f32 + padding) as u32,
- (crop.size.y as f32 + padding) as u32,
- );
+ let width = ((crop.size.x as f32 + padding) as u32 + 1) & !1;
+ let height = ((crop.size.y as f32 + padding) as u32 + 1) & !1;
+ return (width, height);
}
Some(AspectRatio::Square) => 1.0,
Some(AspectRatio::Wide) => 16.0 / 9.0,
@@ -272,13 +271,16 @@ impl ProjectUniforms {
Some(AspectRatio::Tall) => 3.0 / 4.0,
};
- if crop_aspect > aspect {
+ let (width, height) = if crop_aspect > aspect {
(crop.size.x, (crop.size.x as f32 / aspect) as u32)
} else if crop_aspect < aspect {
((crop.size.y as f32 * aspect) as u32, crop.size.y)
} else {
(crop.size.x, crop.size.y)
- }
+ };
+
+ // Ensure width and height are divisible by 2
+ ((width + 1) & !1, (height + 1) & !1)
}
pub fn new(constants: &RenderVideoConstants, project: &ProjectConfiguration) -> Self {