首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >Captura - 功能强大的开源屏幕录制与截图工具

Captura - 功能强大的开源屏幕录制与截图工具

原创
作者头像
qife122
发布2026-03-05 08:43:44
发布2026-03-05 08:43:44
510
举报

Captura:全能型开源屏幕录制与截图工具

Captura 是一款功能强大、完全免费的屏幕录制和截图工具。它不仅可以帮助您轻松创建高质量的视频教程、游戏录像和会议记录,还提供了丰富的定制选项,让您的录制过程更加专业和高效。从简单的截图到复杂的多音轨视频录制,Captura 都能轻松应对。

功能特性

Captura 提供了一系列强大而实用的功能,满足您在不同场景下的需求:

  • 多功能录制:支持全屏、特定窗口、选定区域或单个屏幕的录制。无论是录制整个桌面还是仅录制应用程序界面,都能轻松实现。
  • 高清截图:不仅可以录制视频,还能随时截取屏幕截图,并支持 PNG、JPG 等多种图片格式。
  • 音视频同步录制:能够同时从麦克风和扬声器(系统音频)捕获音频,并进行混合录制,确保视频讲解与系统声音完美同步。
  • 鼠标与键盘可视化:在录制的视频中高亮显示鼠标点击和键盘按键,是制作教程和演示的绝佳辅助功能。
  • 摄像头录制:支持连接网络摄像头,并可将其画面作为画中画嵌入到屏幕录制中。
  • 强大的命令行支持:提供命令行接口(测试版),方便高级用户通过脚本或与其他工具集成实现自动化操作。
  • 多语言界面:项目已翻译成多种语言,方便全球用户使用。
  • 可自定义热键:支持为开始/停止录制、暂停、截图等常用操作设置全局热键,提高工作效率。
  • 丰富的输出格式:基于 FFmpeg,支持将录制的视频输出为 AVI、GIF、MP4 等多种格式。
  • 界面美观:采用 ModernUI 风格,界面简洁直观,操作便捷。

安装指南

Captura 提供多种安装方式,您可以根据自己的偏好选择。

系统要求

  • 操作系统: Windows 7 或更高版本(建议 Windows 10)。
  • 运行时: .NET Framework 4.7.1 或更高版本。
  • 编码器: FFmpeg (Captura 会自动提示下载,或您也可以手动配置)。

下载安装

  1. 下载最新版本 访问 Captura 的 GitHub Releases 页面,下载 Captura-Setup.exe (安装版) 或 Captura-Portable.zip (便携版)。便携版解压后即可使用,无需安装。
  2. 通过 Chocolatey 安装(推荐) 如果您安装了 Chocolatey 包管理器,可以通过以下命令一键安装:choco install captura -y
  3. 首次启动与 FFmpeg 配置 首次启动 Captura 时,程序会自动检测 FFmpeg。如果未找到,会提示您下载。您只需点击“下载 FFmpeg”按钮,程序将自动完成下载和配置。当然,您也可以手动下载 FFmpeg 并将其所在文件夹路径配置到 Captura 的设置中。

使用说明

Captura 的用户界面非常直观,主要功能都集中在主窗口。以下是一些基础使用示例。

基础使用:录制全屏视频

  1. “来源” 选项卡中选择 “屏幕”
  2. “音频” 下拉菜单中选择您想要录制的麦克风和扬声器。
  3. 点击主界面上的红色 “录制” 按钮(或使用默认热键 Ctrl+F10)开始录制。
  4. 录制过程中,您可以点击 “暂停” 按钮(或使用默认热键 Ctrl+F11)暂停录制。
  5. 完成录制后,再次点击红色按钮(此时已变为 “停止” 按钮,或使用默认热键 Ctrl+F10)停止录制。视频将自动保存到您的输出文件夹。

基础使用:截图指定区域

  1. “来源” 选项卡中选择 “区域”
  2. 屏幕中央会出现一个区域选择框。您可以拖动边框调整其大小,或按住标题栏移动其位置。
  3. 点击 “截图” 按钮(相机图标)。
  4. 截图会立即在屏幕右上角的通知栏中显示预览。点击预览可以打开图片,或点击编辑按钮使用外部编辑器进行编辑。

核心代码分析

Captura 的项目结构清晰,模块化程度高,以下是几个核心模块的代码示例,展示了其部分实现。

主应用入口与初始化 (App.xaml.cs)
代码语言:csharp
复制
using FirstFloor.ModernUI.Presentation;
using System;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Threading;
using Captura.Loc;
using Captura.Models;
using Captura.MouseKeyHook;
using Captura.ViewModels;
using Captura.Views;
using CommandLine;

namespace Captura
{
    public partial class App
    {
        public App()
        {
            // 单例模式检查,防止多开
            SingleInstanceManager.SingleInstanceCheck();

            // 显示启动画面
            ShowSplashScreen();
        }

        public static CmdOptions CmdOptions { get; private set; }
        
        // 全局UI线程异常处理
        void App_OnDispatcherUnhandledException(object Sender, DispatcherUnhandledExceptionEventArgs Args)
        {
            var dir = Path.Combine(ServiceProvider.SettingsDir, "Crashes");
            Directory.CreateDirectory(dir);
            File.WriteAllText(Path.Combine(dir, $"{DateTime.Now:yyyy-MM-dd-HH-mm-ss}.txt"), Args.Exception.ToString());
            Args.Handled = true;
            new ErrorWindow(Args.Exception, Args.Exception.Message).ShowDialog();
        }

        void Application_Startup(object Sender, StartupEventArgs Args)
        {
            AppDomain.CurrentDomain.UnhandledException += OnCurrentDomainOnUnhandledException;

            // 加载核心模块(依赖注入)
            ServiceProvider.LoadModule(new CoreModule());
            ServiceProvider.LoadModule(new ViewCoreModule());

            // 解析命令行参数
            Parser.Default.ParseArguments<CmdOptions>(Args.Args)
                .WithParsed(M => CmdOptions = M);

            if (CmdOptions.Settings != null)
            {
                ServiceProvider.SettingsDir = CmdOptions.Settings;
            }

            var settings = ServiceProvider.Get<Settings>();

            // 初始化主题、语言、快捷键映射
            InitTheme(settings);
            BindLanguageSetting(settings);
            BindKeymapSetting(settings);
        }

        // ... 其他初始化方法
    }
}
自定义视频源选择器 (VideoSourcePickerWindow.xaml.cs)

这个窗口允许用户通过直观的界面选择要录制的窗口或屏幕。

代码语言:csharp
复制
using System;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using Captura.Video;
using Color = System.Windows.Media.Color;
using Cursors = System.Windows.Input.Cursors;
using HorizontalAlignment = System.Windows.HorizontalAlignment;
using MouseEventArgs = System.Windows.Input.MouseEventArgs;

namespace Captura
{
    public partial class VideoSourcePickerWindow
    {
        enum VideoPickerMode { Window, Screen }
        readonly VideoPickerMode _mode;
        Predicate<IWindow> Predicate { get; set; }

        VideoSourcePickerWindow(VideoPickerMode Mode)
        {
            _mode = Mode;
            InitializeComponent();

            // 窗口铺满整个虚拟屏幕
            Left = SystemParameters.VirtualScreenLeft;
            Top = SystemParameters.VirtualScreenTop;
            Width = SystemParameters.VirtualScreenWidth;
            Height = SystemParameters.VirtualScreenHeight;

            UpdateBackground(); // 截取当前屏幕作为背景

            var platformServices = ServiceProvider.Get<IPlatformServices>();
            _screens = platformServices.EnumerateScreens().ToArray();
            _windows = platformServices.EnumerateWindows().ToArray();

            ShowCancelText();
        }

        readonly IScreen[] _screens;
        readonly IWindow[] _windows;

        public IScreen SelectedScreen { get; private set; }
        public IWindow SelectedWindow { get; private set; }

        // 截取屏幕作为背景,实现“透视”效果
        void UpdateBackground()
        {
            using var bmp = ScreenShot.Capture();
            var stream = new MemoryStream();
            bmp.Save(stream, ImageFormats.Png);
            stream.Seek(0, SeekOrigin.Begin);
            var decoder = new PngBitmapDecoder(stream, BitmapCreateOptions.None, BitmapCacheOption.Default);
            Background = new ImageBrush(decoder.Frames[0]);
        }
        
        // ... 其他交互逻辑
    }
}
通知堆栈管理 (NotificationStack.xaml.cs)

Captura 使用一个优雅的通知堆栈来管理截图预览和操作反馈。

代码语言:csharp
复制
using System;
using System.Linq;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Threading;
using MouseEventArgs = System.Windows.Input.MouseEventArgs;

namespace Captura
{
    public partial class NotificationStack
    {
        static readonly TimeSpan TimeoutToHide = TimeSpan.FromSeconds(5);
        DateTime _lastMouseMoveTime;
        readonly DispatcherTimer _timer;

        public NotificationStack()
        {
            InitializeComponent();

            _timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) };
            _timer.Tick += TimerOnTick;
            _timer.Start();
        }

        void TimerOnTick(object Sender, EventArgs Args)
        {
            var now = DateTime.Now;
            var elapsed = now - _lastMouseMoveTime;

            // 检查是否有未完成的通知(如正在上传)
            var unfinished = ItemsControl.Items
                .OfType<NotificationBalloon>()
                .Any(M => !M.Notification.Finished);

            if (unfinished)
            {
                _lastMouseMoveTime = now;
            }

            if (elapsed < TimeoutToHide)
                return;

            if (!unfinished)
            {
                OnClose(); // 自动隐藏
            }
        }

        public void Hide()
        {
            BeginAnimation(OpacityProperty, new DoubleAnimation(0, new Duration(TimeSpan.FromMilliseconds(100))));
            if (_timer.IsEnabled)
                _timer.Stop();
        }

        public void Show()
        {
            _lastMouseMoveTime = DateTime.Now;
            BeginAnimation(OpacityProperty, new DoubleAnimation(1, new Duration(TimeSpan.FromMilliseconds(300))));
            if (!_timer.IsEnabled)
                _timer.Start();
        }

        // 移除指定元素,并伴有滑出动画
        void Remove(FrameworkElement Element)
        {
            var transform = new TranslateTransform();
            Element.RenderTransform = transform;

            var translateAnim = new DoubleAnimation(500, new Duration(TimeSpan.FromMilliseconds(200)));
            var opactityAnim = new DoubleAnimation(0, new Duration(TimeSpan.FromMilliseconds(200)));
            var heightAnim = new DoubleAnimation(Element.ActualHeight, 0, new Duration(TimeSpan.FromMilliseconds(200)));

            heightAnim.Completed += (S, E) => ItemsControl.Items.Remove(Element);

            opactityAnim.Completed += (S, E) => Element.BeginAnimation(HeightProperty, heightAnim);

            transform.BeginAnimation(TranslateTransform.XProperty, translateAnim);
            Element.BeginAnimation(OpacityProperty, opactityAnim);
        }

        // ... 添加通知、鼠标移动处理等方法
    }
}
```FINISHED
代码语言:txt
复制

9EN9f9Pid8T89KjZma8Lo9oN+oe+voeUx2TBEXvxyQA=

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Captura:全能型开源屏幕录制与截图工具
    • 功能特性
    • 安装指南
      • 系统要求
      • 下载安装
    • 使用说明
      • 基础使用:录制全屏视频
      • 基础使用:截图指定区域
      • 核心代码分析
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档