Skip to content

🎥 Make videos programmatically with React

`@remotion/renderer`: Fix stride bug with videos of rotation 180

Jonny Burger5c9ad53b4391
diff --git a/packages/renderer/rust/scalable_frame.rs b/packages/renderer/rust/scalable_frame.rs
index 1f59cfa77c..657905eaff 100644
--- a/packages/renderer/rust/scalable_frame.rs
+++ b/packages/renderer/rust/scalable_frame.rs
@@ -363,13 +363,15 @@ pub fn rotate_180(
stride: usize,
channels: usize,
) -> (Vec<u8>, u32, u32) {
- let mut new_data: Vec<u8> = vec![0; stride * height as usize];
+ let new_stride = width as usize * channels;
+
+ let mut new_data: Vec<u8> = vec![0; new_stride * height as usize];
for y in 0..height {
for x in 0..width {
let new_x = width - x - 1;
let new_y = height - y - 1;
- let new_index = (new_y as usize * stride) + (new_x as usize * channels);
+ let new_index = (new_y as usize * new_stride) + (new_x as usize * channels);
let old_index = (y as usize * stride) + (x as usize * channels);
new_data[new_index..new_index + channels]
.copy_from_slice(&data[old_index..old_index + channels]);