Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Editor export options picker (FPS/Resolution) #236

Merged
merged 9 commits into from
Jan 17, 2025
1 change: 1 addition & 0 deletions apps/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ async fn main() -> Result<(), String> {
render_constants,
&segments,
fps,
XY::new(1920, 1080),
)
.unwrap();

Expand Down
4 changes: 3 additions & 1 deletion apps/desktop/src-tauri/src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
general_settings::GeneralSettingsStore, get_video_metadata, upsert_editor_instance,
windows::ShowCapWindow, RenderProgress, VideoRecordingMetadata, VideoType,
};
use cap_project::ProjectConfiguration;
use cap_project::{ProjectConfiguration, XY};
use std::path::PathBuf;
use tauri::AppHandle;

Expand All @@ -15,6 +15,7 @@ pub async fn export_video(
progress: tauri::ipc::Channel<RenderProgress>,
force: bool,
fps: u32,
resolution_base: XY<u32>,
) -> Result<PathBuf, String> {
let screen_metadata =
match get_video_metadata(app.clone(), video_id.clone(), Some(VideoType::Screen)).await {
Expand Down Expand Up @@ -84,6 +85,7 @@ pub async fn export_video(
editor_instance.render_constants.clone(),
&editor_instance.segments,
fps,
resolution_base,
)
.map_err(|e| {
sentry::capture_message(&e.to_string(), sentry::Level::Error);
Expand Down
12 changes: 9 additions & 3 deletions apps/desktop/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use cap_media::feeds::{AudioInputFeed, AudioInputSamplesSender};
use cap_media::frame_ws::WSFrame;
use cap_media::sources::CaptureScreen;
use cap_media::{feeds::CameraFeed, sources::ScreenCaptureTarget};
use cap_project::XY;
use cap_project::{Content, ProjectConfiguration, RecordingMeta, Resolution, SharingMeta};
use cap_recording::RecordingOptions;
use cap_rendering::ProjectRecordings;
Expand Down Expand Up @@ -850,6 +851,7 @@ async fn open_file_path(_app: AppHandle, path: PathBuf) -> Result<(), String> {
struct RenderFrameEvent {
frame_number: u32,
fps: u32,
resolution_base: XY<u32>,
}

#[derive(Serialize, specta::Type, tauri_specta::Event, Debug, Clone)]
Expand All @@ -867,10 +869,10 @@ impl EditorStateChanged {

#[tauri::command]
#[specta::specta]
async fn start_playback(app: AppHandle, video_id: String, fps: u32) {
async fn start_playback(app: AppHandle, video_id: String, fps: u32, resolution_base: XY<u32>) {
upsert_editor_instance(&app, video_id)
.await
.start_playback(fps)
.start_playback(fps, resolution_base)
.await
}

Expand Down Expand Up @@ -2270,7 +2272,11 @@ async fn create_editor_instance_impl(app: &AppHandle, video_id: String) -> Arc<E
let preview_tx = instance.preview_tx.clone();
move |e| {
preview_tx
.send(Some((e.payload.frame_number, e.payload.fps)))
.send(Some((
e.payload.frame_number,
e.payload.fps,
e.payload.resolution_base,
)))
.ok();
}
});
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src-tauri/src/recording.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use cap_flags::FLAGS;
use cap_media::feeds::CameraFeed;
use cap_media::sources::{CaptureScreen, CaptureWindow};
use cap_project::{
Content, ProjectConfiguration, TimelineConfiguration, TimelineSegment, ZoomSegment,
Content, ProjectConfiguration, TimelineConfiguration, TimelineSegment, ZoomSegment, XY,
};
use cap_recording::CompletedRecording;
use cap_rendering::ProjectRecordings;
Expand Down Expand Up @@ -164,7 +164,6 @@ pub async fn stop_recording(app: AppHandle, state: MutableState<'_, App>) -> Res
return Err("Recording not in progress".to_string())?;
};

let now = Instant::now();
let completed_recording = current_recording.stop().await.map_err(|e| e.to_string())?;

if let Some(window) = CapWindowId::InProgressRecording.get(&app) {
Expand Down Expand Up @@ -253,6 +252,7 @@ pub async fn stop_recording(app: AppHandle, state: MutableState<'_, App>) -> Res
tauri::ipc::Channel::new(|_| Ok(())),
true,
completed_recording.meta.content.max_fps(),
XY::new(1920, 1080),
)
.await
.ok();
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/routes/editor/ConfigSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ export function ConfigSidebar() {
)
}
minValue={1}
maxValue={2.5}
maxValue={4.5}
step={0.001}
/>
</Field>
Expand Down
14 changes: 9 additions & 5 deletions apps/desktop/src/routes/editor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ import { createEventListenerMap } from "@solid-primitives/event-listener";
import { convertFileSrc } from "@tauri-apps/api/core";

import { events } from "~/utils/tauri";
import { EditorContextProvider, FPS, useEditorContext } from "./context";
import {
EditorContextProvider,
EditorInstanceContextProvider,
FPS,
OUTPUT_SIZE,
useEditorContext,
useEditorInstanceContext,
} from "./context";
import {
Dialog,
DialogContent,
Expand All @@ -30,10 +37,6 @@ import {
Subfield,
Toggle,
} from "./ui";
import {
EditorInstanceContextProvider,
useEditorInstanceContext,
} from "./editorInstanceContext";
import { Header } from "./Header";
import { Player } from "./Player";
import { ConfigSidebar } from "./ConfigSidebar";
Expand Down Expand Up @@ -83,6 +86,7 @@ function Inner() {
events.renderFrameEvent.emit({
frame_number: Math.max(Math.floor(time * FPS), 0),
fps: FPS,
resolution_base: OUTPUT_SIZE,
});
}, 1000 / 60);

Expand Down
Loading
Loading