Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix display layer not rendering

Brendan Allan625d0cec9c42
diff --git a/apps/cli/src/main.rs b/apps/cli/src/main.rs
index 72d153bf6..f9ba4445b 100644
--- a/apps/cli/src/main.rs
+++ b/apps/cli/src/main.rs
@@ -170,12 +170,12 @@ impl Export {
let mut stdout = stdout();
let exporter_output_path = cap_export::mp4::Mp4ExportSettings {
- fps: 10,
+ fps: 60,
resolution_base: XY::new(1920, 1080),
compression: cap_export::mp4::ExportCompression::Minimal,
}
.export(exporter_base, move |f| {
- print!("\rrendered frame {f}");
+ // print!("\rrendered frame {f}");
stdout.flush().unwrap();
})
diff --git a/crates/rendering/src/layers/camera.rs b/crates/rendering/src/layers/camera.rs
index 78795e13b..8730c82f0 100644
--- a/crates/rendering/src/layers/camera.rs
+++ b/crates/rendering/src/layers/camera.rs
@@ -88,7 +88,6 @@ impl CameraLayer {
pub fn render(&self, pass: &mut wgpu::RenderPass<'_>) {
if let Some(bind_group) = &self.bind_group {
- dbg!(bind_group.global_id());
pass.set_pipeline(&self.pipeline.render_pipeline);
pass.set_bind_group(0, bind_group, &[]);
pass.draw(0..4, 0..1);
diff --git a/crates/rendering/src/layers/display.rs b/crates/rendering/src/layers/display.rs
index 913b4d0f2..5f8d64ce4 100644
--- a/crates/rendering/src/layers/display.rs
+++ b/crates/rendering/src/layers/display.rs
@@ -16,12 +16,18 @@ pub struct DisplayLayer {
impl DisplayLayer {
pub fn new(device: &wgpu::Device) -> Self {
let frame_texture = CompositeVideoFramePipeline::create_frame_texture(device, 1920, 1080);
+ let frame_texture_view = frame_texture.create_view(&Default::default());
+
+ let uniforms_buffer = CompositeVideoFrameUniforms::default().to_buffer(device);
+ let pipeline = CompositeVideoFramePipeline::new(device);
+ let bind_group = Some(pipeline.bind_group(&device, &uniforms_buffer, &frame_texture_view));
+
Self {
- frame_texture_view: frame_texture.create_view(&Default::default()),
+ frame_texture_view,
frame_texture,
- uniforms_buffer: CompositeVideoFrameUniforms::default().to_buffer(device),
- pipeline: CompositeVideoFramePipeline::new(device),
- bind_group: None,
+ uniforms_buffer,
+ pipeline,
+ bind_group,
}
}
diff --git a/crates/video-decode/src/bin/print_frames.rs b/crates/video-decode/src/bin/print_frames.rs
new file mode 100644
index 000000000..397f1a7b9
--- /dev/null
+++ b/crates/video-decode/src/bin/print_frames.rs
@@ -0,0 +1,27 @@
+use std::path::PathBuf;
+
+use cap_video_decode::AVAssetReaderDecoder;
+
+#[tokio::main]
+pub async fn main() {
+ let handle = tokio::runtime::Handle::current();
+
+ let path: PathBuf = std::env::args().collect::<Vec<_>>().swap_remove(1).into();
+
+ let _ = std::thread::spawn(|| {
+ let mut decoder = AVAssetReaderDecoder::new(path, handle).unwrap();
+
+ for frame in decoder.frames() {
+ let Ok(frame) = frame else {
+ return;
+ };
+
+ dbg!(frame.pts());
+ }
+ })
+ .join();
+}
+
+pub fn pts_to_frame(pts: i64, time_base: (f64, f64), fps: u32) -> u32 {
+ (fps as f64 * ((pts as f64 * time_base.0) / (time_base.1))).round() as u32
+}
diff --git a/crates/video-decode/src/main.rs b/crates/video-decode/src/main.rs
deleted file mode 100644
index ca992830d..000000000
--- a/crates/video-decode/src/main.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-use std::time::Instant;
-
-use cap_video_decode::FFmpegDecoder;
-
-#[tokio::main]
-async fn main() {
- let handle = tokio::runtime::Handle::current();
-
- let _ = std::thread::spawn(|| {
- let mut args = std::env::args();
- args.next();
-
- let path = args.next().unwrap();
-
- let mut decoder = FFmpegDecoder::new(path, None).unwrap();
-
- let start = Instant::now();
-
- let frame_count = decoder.frames().count();
- let duration = start.elapsed();
- println!(
- "decoded {} frames in {:?} - {} frames/s",
- frame_count,
- duration,
- frame_count as f64 / duration.as_secs_f64()
- );
- })
- .join();
-}