Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
Merge branch 'main' of github.com:siddharthvaddem/openscreen into feature/remember-last-export-folder
AbhinRustagi1aac6eddb034
diff --cc electron/ipc/handlers.tsindex cb8d217a3,7361b26fc..4e2b3aa56--- a/electron/ipc/handlers.ts+++ b/electron/ipc/handlers.ts@@@ -822,92 -985,76 +985,99 @@@ export function registerIpcHandlers* @returns Object with success status, optional file path, and error details.*/- ipcMain.handle("save-exported-video", async (_, videoData: ArrayBuffer, fileName: string) => {- try {- // Determine file type from extension- const isGif = fileName.toLowerCase().endsWith(".gif");- const filters = isGif- ? [{ name: mainT("dialogs", "fileDialogs.gifImage"), extensions: ["gif"] }]- : [{ name: mainT("dialogs", "fileDialogs.mp4Video"), extensions: ["mp4"] }];+ ipcMain.handle(+ "save-exported-video",+ async (_, videoData: ArrayBuffer, fileName: string, exportFolder?: string) => {+ try {+ // Determine file type from extension+ const isGif = fileName.toLowerCase().endsWith(".gif");+ const filters = isGif+ ? [{ name: mainT("dialogs", "fileDialogs.gifImage"), extensions: ["gif"] }]+ : [{ name: mainT("dialogs", "fileDialogs.mp4Video"), extensions: ["mp4"] }];++ // Prefer the user's last export folder if it still exists, otherwise fall+ // back to ~/Downloads. Validation must happen here because the renderer+ // can't stat the filesystem.+ let defaultDir = app.getPath("downloads");+ if (exportFolder) {+ try {+ const stats = await fs.stat(exportFolder);+ if (stats.isDirectory()) {+ defaultDir = exportFolder;+ }+ } catch (err) {+ // Stat can fail because the folder was moved/deleted (expected) or+ // because of a permission error (worth surfacing). Either way we+ // fall back to Downloads, but log so debugging isn't blind.+ console.warn(+ `Could not access remembered export folder "${exportFolder}", falling back to Downloads:`,+ err,+ );+ }+ }-- const result = await dialog.showSaveDialog({- title: isGif- ? mainT("dialogs", "fileDialogs.saveGif")- : mainT("dialogs", "fileDialogs.saveVideo"),- defaultPath: path.join(defaultDir, fileName),- filters,- properties: ["createDirectory", "showOverwriteConfirmation"],- });++ const dialogOptions = buildDialogOptions(++ {++ title: isGif++ ? mainT("dialogs", "fileDialogs.saveGif")++ : mainT("dialogs", "fileDialogs.saveVideo"),++ defaultPath: path.join(defaultDir, fileName),++ filters,++ properties: ["createDirectory", "showOverwriteConfirmation"],++ },++ getMainWindow(),++ );++ const result = await dialog.showSaveDialog(dialogOptions);- const dialogOptions = buildDialogOptions(- {- title: isGif- ? mainT("dialogs", "fileDialogs.saveGif")- : mainT("dialogs", "fileDialogs.saveVideo"),- defaultPath: path.join(app.getPath("downloads"), fileName),- filters,- properties: ["createDirectory", "showOverwriteConfirmation"],- },- getMainWindow(),- );- const result = await dialog.showSaveDialog(dialogOptions);+ if (result.canceled || !result.filePath) {+ return {+ success: false,+ canceled: true,+ message: "Export canceled",+ };+ }++ // --- FIX: Normalize the path for Windows compatibility ---+ const normalizedPath = path.normalize(result.filePath);++ // Ensure the parent directory exists (Windows may fail if the folder is missing)+ await fs.mkdir(path.dirname(normalizedPath), { recursive: true });+ // --- END FIX ---++ await fs.writeFile(normalizedPath, Buffer.from(videoData));- if (result.canceled || !result.filePath) {+ return {+ success: true,+ path: normalizedPath,+ message: "Video exported successfully",+ };+ } catch (error) {+ console.error("Failed to save exported video:", error);return {success: false,- canceled: true,- message: "Export canceled",+ message: "Failed to save exported video",+ error: String(error),};}-- // --- FIX: Normalize the path for Windows compatibility ---- const normalizedPath = path.normalize(result.filePath);-- // Ensure the parent directory exists (Windows may fail if the folder is missing)- await fs.mkdir(path.dirname(normalizedPath), { recursive: true });- // --- END FIX ----- await fs.writeFile(normalizedPath, Buffer.from(videoData));-- return {- success: true,- path: normalizedPath,- message: "Video exported successfully",- };- } catch (error) {- console.error("Failed to save exported video:", error);- return {- success: false,- message: "Failed to save exported video",- error: String(error),- };- }- });+ },+ );ipcMain.handle("open-video-file-picker", async () => {try {- const result = await dialog.showOpenDialog({- title: mainT("dialogs", "fileDialogs.selectVideo"),- defaultPath: RECORDINGS_DIR,- filters: [- {- name: mainT("dialogs", "fileDialogs.videoFiles"),- extensions: ["webm", "mp4", "mov", "avi", "mkv"],- },- { name: mainT("dialogs", "fileDialogs.allFiles"), extensions: ["*"] },- ],- properties: ["openFile"],- });+ const dialogOptions = buildDialogOptions(+ {+ title: mainT("dialogs", "fileDialogs.selectVideo"),+ defaultPath: RECORDINGS_DIR,+ filters: [+ {+ name: mainT("dialogs", "fileDialogs.videoFiles"),+ extensions: ["webm", "mp4", "mov", "avi", "mkv"],+ },+ { name: mainT("dialogs", "fileDialogs.allFiles"), extensions: ["*"] },+ ],+ properties: ["openFile"],+ },+ getMainWindow(),+ );+ const result = await dialog.showOpenDialog(dialogOptions);if (result.canceled || result.filePaths.length === 0) {return { success: false, canceled: true };