跳转至内容

屏幕截图

来自 ArchWiki
(从Screenshot重定向而来)

本文列出并描述了截图屏幕录制软件。

截图软件

专用软件

应用程序列表

  • CoreShotXorg的C-Suite屏幕捕获实用程序。
https://cubocore.gitlab.io/coreapps.html || coreshotAUR
  • Cutefish Screenshot — CutefishOS的截图工具。
https://github.com/cutefishos/screenshot || cutefish-screenshot
  • Escrotum — 使用PyGTK的屏幕捕获工具,灵感来自scrot,并可作为其替代品。
https://github.com/Roger/escrotum || escrotum-gitAUR
https://github.com/lupoDharkael/flameshot || flameshot
https://gitlab.gnome.org/GNOME/gnome-screenshot/ || gnome-screenshot
https://gitlab.freedesktop.org/emersion/grim || grim
  • gscreenshotGTK前端,支持多种截图后端,包括scrotImageMagickPILimlib2grim;具有延迟、选择和复制到剪贴板功能。
https://github.com/thenaterhood/gscreenshot || gscreenshotAUR
  • HotShots — 屏幕捕获和保存为多种图像格式,并添加注释和图形数据(箭头、线条、文本等)的应用程序。
https://github.com/obiwankennedy/HotShots || hotshots-gitAUR
  • imgur-screenshot — 截取屏幕选区,上传到imgur+更多酷功能。
https://github.com/jomo/imgur-screenshot || imgur-screenshotAUR
  • ksnip — 基于Qt的跨平台截图工具,提供丰富的注释功能、基本的图像处理和远程目的地(ftp、imgur、脚本)。
https://github.com/ksnip/ksnip || ksnip
  • Lightscreen — 简单的工具,用于自动化保存和编目截图的繁琐过程,它作为一个隐藏的后台进程运行,通过一个(或多个)热键调用,然后根据用户偏好将截图文件保存到磁盘。
https://lightscreen.com.ar || lightscreenAUR
  • LXImage-QtLXImage图像查看器和截图工具的Qt端口(使用lximage-qt --screenshot运行)。
https://github.com/lxde/lximage-qt || lximage-qt
  • maim — 简单的命令行实用程序,用于截屏,旨在替代scrot,并在许多方面比scrot表现更好。
https://github.com/naelstrof/maim || maim
  • MATE ScreenshotMATE桌面的截图工具。
https://mate-desktop.org || mate-utils
  • menyoki — 支持图像处理操作的命令行截图和屏幕录制工具。
https://github.com/orhun/menyoki || menyoki
  • mss — 一个xrandr感知的Python截图模块,带有极简的CLI。
https://pypi.ac.cn/project/mss/ || python-mss
https://github.com/elementary/screenshot || pantheon-screenshot
  • ScreenCloud — 截取整个屏幕或选定区域的截图,然后上传到imgur+带插件和系统托盘。
https://screencloud.net/ || screencloudAUR
  • ScreenGrab — 适用于X11和Wayland的桌面环境无关的截图工具,现在由LXQt项目维护。
https://github.com/lxqt/screengrab || screengrab
  • scrot — X的简单命令行截图工具。
https://github.com/resurrecting-open-source-projects/scrot || scrot
  • Shotgun — 用Rust编写的极简X截图实用程序(根据作者的说法,它比maim快两倍)。
https://github.com/neXromancers/shotgun || shotgun
  • Shutter — 功能丰富的截图和编辑程序(支持延迟)。
https://shutter-project.org/ || shutter
  • SpectacleKDE屏幕捕获应用程序,能够捕获整个桌面、单个窗口、窗口的一部分、选定的矩形区域或自由形状区域的图像;属于plasma。在Wayland下需要运行plasma。
https://invent.kde.org/plasma/spectacle || spectacle
  • Xfce4-screenshooter — 用于Xfce的应用程序和面板插件,用于截取整个屏幕、活动窗口或选定区域的屏幕截图;属于xfce4-goodies。在Wayland上只允许全屏捕获(2025年10月)。
https://docs.xfce.org/apps/screenshooter/start || xfce4-screenshooter
https://www.x.org/ || xorg-xwd

用法

本文或本节需要在语言、wiki 语法或风格方面进行改进。请参阅 Help:Style 获取参考。

原因: 我认为将仅包含描述的小节(escrotum)合并到上述应用程序列表的适当单元中,并为其他部分创建Wiki页面会更好。(在Talk:Screen capture讨论)
maim

maim旨在成为一个改进的scrot。

将全屏保存到文件

$ maim filename

提示选择并保存到文件

$ maim --select filename

保存活动窗口到文件,假设已安装xdotool

$ maim --window $(xdotool getactivewindow) filename

提示选择,保存时不包含光标,并将其存储到剪贴板,假设已安装xclip

$ maim -s | xclip -selection clipboard -t image/png -i
scrot

scrot支持从CLI截图,并提供用户可定义的延迟等功能。除非另有说明,否则它会将文件保存在当前工作目录中。

$ scrot -t 20 -d 5

上述命令将保存一个带日期的.png文件,以及一个缩略图(原始尺寸的20%),用于网络发布。在此实例中,它提供了5秒的延迟后进行捕获。

您也可以在使用文件名保存时使用标准的日期和时间格式。例如:

$ scrot ~/screenshots/%Y-%m-%d-%T-screenshot.png

将截图保存在一个包含当前年、月、日、时、分、秒的文件名中,保存在名为“screenshots”的主目录下的一个文件夹中

有关更多信息,请参阅scrot(1)

注意 在某些窗口管理器(dwmAURxmonad及其他)中,scrot -s在通过窗口管理器的键盘快捷键运行时可能无法正常工作。可以通过在scrot调用前加上短暂的延迟sleep 0.2; scrot -s来解决。

桌面环境特定

Budgie

Budgie自带了一个名为BudgieScreenshot的截图工具。

它允许使用PrintScreen捕获整个屏幕、活动窗口或选定区域。请参阅键盘快捷键了解特定操作的快捷键。

Cinnamon

默认安装的Cinnamon不提供截图工具。安装gnome-screenshot后,可以通过菜单 > 附件 > 截图或按PrintScreen键进行截图。

GNOME

GNOME用户可以按PrintScreen键或点击系统菜单中的相机图标。您也可以选择安装gnome-screenshot并通过应用程序 > 附件 > 截取屏幕截图打开。

GNOME内置了屏幕录制功能,使用Ctrl+Shift+Alt+r组合键。录制进行时,屏幕右下角会显示一个红圈。录制完成后,一个名为Screencast from %d%u-%c.webm的文件会被保存在Videos目录中。要使用屏幕录制功能,需要安装gst-plugin-pipewiregst-plugins-good软件包。

KDE

如果您使用KDE,您可能想使用Spectacle

Spectacle由spectacle软件包提供。

Xfce

如果您使用Xfce,您可以安装xfce4-screenshooter,然后添加键盘绑定。

Xfce菜单 > 设置 > 键盘 > 应用程序快捷方式

如果您想跳过截图提示,请在终端输入$ xfce4-screenshooter -h查看选项。

其他桌面环境或窗口管理器

本文或此部分候选合并至ImageMagick#Screenshot taking

注意: 此子分类并非关于“其他DE/WM”的通用内容,而是关于import的使用。(在Talk:Screen capture讨论)

对于其他桌面环境(如LXDE)或窗口管理器(如OpenboxCompiz),您可以将上述命令添加到热键以进行截图。例如:

$ import -window root ~/Pictures/$(date '+%Y%m%d-%H%M%S').png

请注意,importimagemagick软件包的一部分。将上述命令添加到Compiz的PrintScreen键,可以按照日期和时间将截图保存到Pictures文件夹。

请注意,Openbox中的rc.xml文件不识别逗号;因此,要在Openbox中将该命令绑定到PrintScreen键,您需要在rc.xml文件的键盘部分添加以下内容:

rc.xml
<!-- Screenshot -->
<keybind key="Print">
  <action name="Execute">
    <command>sh -c "import -window root ~/Pictures/$(date '+%Y%m%d-%H%M%S').png"</command>
  </action>
</keybind>

如果上面的PrintScreen不起作用,请参阅键盘输入并使用不同的keysymkeycode

包含截图工具的软件包

ImageMagick/GraphicsMagick

请参阅ImageMagick#Screenshot taking

GIMP

您也可以使用GIMP进行截图(文件 > 创建 > 屏幕截图...)。

imlib2

imlib2提供了一个名为imlib2_grab的二进制文件来截屏。要截取整个屏幕,请键入:

$ imlib2_grab screenshot.png

FFmpeg

请参阅FFmpeg#Screen capture

屏幕录制软件

另请参阅FFmpeg#Screen captureWikipedia:Comparison of screencasting software

屏幕录制工具允许您创建桌面或单个窗口的视频。

  • Deepin Screen Recorder — Deepin桌面的屏幕录制应用程序。
https://www.deepin.org/en/original/deepin-screen-recorder/ || deepin-screen-recorder
  • FFcast — 基于FFmpeg的Bash编写的屏幕录制工具。
https://github.com/lolilolicon/FFcast || ffcastAUR
  • GPU Screen Recorder — 仅在GPU上捕获屏幕的录制器,以大幅提高性能,可与NVIDIA ShadowPlay媲美,并支持直播和重播缓冲区。
https://git.dec05eba.com/gpu-screen-recorder-ui/about/ || gpu-screen-recorder-uiAUR
  • Green Recorder — Linux系统的简单而功能齐全的桌面录制器。
https://github.com/dvershinin/green-recorder || green-recorderAUR
  • Kazam — 注重设计的屏幕录制程序,支持多屏设置。
https://launchpad.net/kazam || kazamAUR
  • Kooha — 简单的屏幕录制器,带有极简的GTK界面。
https://github.com/SeaDve/Kooha || kooha
  • menyoki — 命令行屏幕捕获和图像操作(仅X11,Wayland计划中)。
https://github.com/orhun/menyoki || menyoki
https://obsproject.com/ || obs-studio
  • Peek — 简单的屏幕录制工具,可生成GIF、APNG、WebM或MP4动画(截至2023年1月已停止开发)。
https://github.com/phw/peek || peek
  • RecApp — 使用免费GStreamer模块编写的GTK屏幕录制器,用户友好,不依赖FFmpeg(已停止开发)。
https://github.com/amikha1lov/RecApp || recappAUR
  • RecordMyDesktop — 易于使用的CLI界面工具,可将桌面录制为Ogg格式(开发不活跃)。
https://recordmydesktop.sourceforge.net/ || recordmydesktop
  • screencast — 使用FFmpeg录制X11桌面的命令行界面,支持离线录制和直播。
https://github.com/dbermond/screencast/ || screencastAUR
  • Screencast — 为elementary OS设计的简单屏幕录制器。
https://github.com/artemanufrij/screencast || pantheon-screencastAUR
  • SimpleScreenRecorder — 使用C++/Qt5编写的功能丰富的屏幕录制器,支持X11和OpenGL。
https://www.maartenbaert.be/simplescreenrecorder/ || simplescreenrecorderAUR
  • SpectacleKDE屏幕捕获应用程序,能够在Wayland上捕获视频(无声音),包括整个桌面、单个屏幕或单个窗口;属于kde-graphics(仅在kwin激活时工作,因此不能与其他窗口管理器一起使用)。
https://invent.kde.org/plasma/spectacle || spectacle
  • VokoScreen — 功能强大的屏幕录制GUI工具,使用GStreamer,支持多种编解码器,捕获视频和声音,支持内部或外部(麦克风、摄像头)以及屏幕/窗口/视图源,支持鼠标区域+按钮的缩放和高亮显示,但Wayland支持有限。
https://linuxecke.volkoh.de/vokoscreen/vokoscreen.html || vokoscreen
  • Wayfarer — GTK4 Wayland屏幕录制器,支持Pipewire和Xorg。
https://github.com/stronnag/wayfarer || wayfarerAUR

标注和可视化工具

一些可在屏幕录制时用于标注事物,或显示按键、鼠标活动等元素的工具。

  • Gromit — 屏幕绘制。
https://github.com/bk138/gromit-mpx/ || gromit-mpxAUR
  • key-mon — 显示当前按下的键盘按键。
https://github.com/scottkirkwood/key-mon/ || key-monAUR
  • screenkey — 显示当前按下的键盘按键。
https://www.thregr.org/~wavexx/software/screenkey/ || screenkey(在Wayland下似乎不显示任何内容)

Wayland

使用以下工具可在基于Wlroots的合成器上捕获屏幕:

可选地,slurp可用于选择要捕获的屏幕部分。如果您的GPU支持vaapi编码,wl-screenrecAUR可能是比wf-recorder更高效的选择。

截取整个屏幕的截图

$ grim screenshot.png

Sway中截取当前窗口的截图

$ swaymsg -t get_tree | jq -r '.. | select(.focused?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | grim -g - screenshot.png

Hyprland中截取当前窗口的截图

$ hyprctl -j activewindow | jq -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"' | grim -g - screenshot.png

截取屏幕的一部分

$ slurp | grim -g - screenshot.png

截取屏幕的一部分,并使用wl-clipboard将输出放入剪贴板。

$ slurp | grim -g - - | wl-copy

截取屏幕的一部分,保存到文件,并使用wl-clipboard将输出放入剪贴板。

$ slurp | grim -g - - | tee ~/Pictures/$(date +%s).png | wl-copy

录制整个屏幕的视频,文件名为recording.mp4(默认是recording.mkv)。

$ wf-recorder -f recording.mp4

录制屏幕的一部分视频

$ wf-recorder -g "$(slurp)"
提示
  • hyprcapAUR是一个脚本实用程序,用于在Hyprland上利用上述多个程序进行截图和屏幕录制。
  • slurpshot是一个交互式截图脚本,使用了bemenu
  • 要使用捕获后的截图编辑和绘图工具,例如swappygrim -g "$(slurp)" - | swappy -f -
  • screenshot.sh — 使用zenitygrimslurp的Wayland GUI截图工具。

屏幕录制

通过GNOME屏幕录制

green-recorderAURobs-gnome-screencastAUR and obs-studio support screen recording on Wayland using GNOME screencast feature。

Via the WebRTC protocol

See PipeWire#WebRTC screen sharing

Chromium and Firefox should now be able to access the screenshare. You can verify this through Mozilla's getUserMedia / getDisplayMedia Test Page

Hyprland

The Hyprland window manager allows screen casting and recording with OBS (including selection of individual windows and workspaces) when used with xdg-desktop-portal-hyprland [1]

Sway

Configuration for screen sharing with selection on Sway is covered by default in /usr/share/xdg-desktop-portal/sway-portals.conf

Other wlroots based compositors

本文或本章节的准确性存在争议。

Reason: According to XDG Desktop Portal#List of backends and interfaces, the GTK portal (xdg-desktop-portal-gtk) is irrelevant to screen sharing. Explain why it is needed and potentially update the linked table. (Discuss in Talk:Screen capture)

本文或本节需要在语言、wiki 语法或风格方面进行改进。请参阅 Help:Style 获取参考。

Reason: Writing style does not fit with Help:Style#Language register. (Discuss in Talk:Screen capture)

for those on a different wlroots based compositors, such as dwl: you will need to do the following,

install xdg-desktop-portal-wlr with the gtk version then follow XDG Desktop Portal#Configuration with PipeWire installed then restart

See PipeWire#WebRTC screen sharing

Via a virtual webcam video feed

See v4l2loopback#Casting Wayland using wf-recorder

提示
  • This method has been tested with zoomAUR (desktop client running under xorg-xwayland) and BigBlueButton under chromium (under firefox the resolution is really low)。
  • The example uses wf-recorder but you can use whatever software, just feed the output to the virtual device。

Install wf-recorder (or wf-recorder-gitAUR) and v4l2loopback-dkms. Load the v4l2loopback kernel module with the following parameters

# modprobe v4l2loopback exclusive_caps=1 card_label=VirtualVideoDevice

Verify that a new virtual video device VirtualVideoDevice has been created

$ v4l2-ctl --list-devices
...
VirtualVideoDevice (platform:v4l2loopback-000):
	/dev/video2
...    

Start recording the screen with wf-recorder and feed the output to the new virtual video device VirtualVideoDevice created by v4l2loopback

$ wf-recorder --muxer=v4l2 --codec=rawvideo --file=/dev/video2 -x yuv420p

The yuv420p colour space is required for the video output to be compatible with Zoom [2]

Tip If you encounter Unknown V4L2 pixel format equivalent for rgb0 run wf-recorder with --force-yuv or -t to force conversion of the data to yuv format, before sending it to the GPU. [3]

You can now select the above virtual video device as your "webcam" in video calling/video conferencing applications (the device is called VirtualVideoDevice). You can use ffplay (part of ffmpeg), mpv, or gst-launch (part of gstreamer) to verify that the virtual video device indeed outputs your screenshare

$ ffplay /dev/video2
$ mpv av://v4l2:/dev/video2
$ gst-launch-1.0 -v v4l2src device=/dev/video2 ! glimagesink

If Firefox is unable to read the video stream and prints a message like "AbortError: Starting video failed", try preloading v4l2compat.so

$ LD_PRELOAD=/usr/lib/v4l1compat.so firefox
Sharing individual applications
Warning This method does not involve a proper implementation of individual application sharing as the region being shared will not change after resizing any windows。

As explained above, wf-recorder is able to record only a portion of the screen by first selecting a region with slurp. To use this functionality for sharing a specific region/application window through a virtual video device, start recording the screen with the following modified command

$ wf-recorder -g "$(slurp)" --muxer=v4l2 --codec=rawvideo --file=/dev/video2 -x yuv420p

After selecting a region of the screen, you will be able to access the video feed through the virtual video device /dev/video2 as above。

Screencast Wayland windows with X11 applications

You can share native Wayland windows (or the whole screen/workspace) to the X11 application. For this you need to use xwaylandvideobridgeAUR. See Fixing Wayland: Xwayland screen casting for details。

Terminal

Capture with ANSI codes

You can use the script(1) command, part of the util-linux package. Just run script and from that moment, all the output is going to be saved to the typescript file, including the ANSI codes。

Once you are done, just run exit and the typescript would ready. The resulting file can be converted to HTML using the ansi2htmlAUR package (not to be confused with ansi2html from python-ansi2html).

To convert the typescript file to typescript.html, do the following

$ ansi2html --bg=dark < typescript > typescript.html

Actually, some commands can be piped directly to ansi2html

$ ls --color|ansi2html --bg=dark >output.html

That does not work on every single case, so in those cases, using script is mandatory。

帧缓冲

Use fbgrab or fbdumpAUR to take a screenshot。

虚拟控制台

屏幕截图

If you merely want to capture the text in the console and not an actual image, you can use setterm, which is part of the util-linux package. The following command will dump the textual contents of virtual console 1 to a file screen.dump in the current directory

# setterm -dump 1 -file screen.dump

Root permission is needed because the contents of /dev/vcs1 need to be read。

Screencast of console

asciinema allows to record a whole terminal session activity, which is saved in a file in its own (open) format. This file can be played with the same tool or an HTML5 version of the tool, and can be shared on the asciinema.org official web site of the application, or on any own hosted HTML version。

Usage: asciinema(1) or asciinema --help

  • asciinema rec output.cast records the session, Ctrl+\ can pause/resume it, Ctrl-d/exit of the session will stop it. Name of output file is optional。

Interesting arguments for recording

  • -c command if you just want to record a specific command action/output
  • -i 1.2 record for 1.2 seconds only
  • -t "beautiful title" add a title to the terminalcast

Other functions than recording

  • asciinema play file.cast play an asciinema record file
  • asciinema upload file.cast upload the file on asciinema.org for sharing
  • asciinema auth manage recordings on asciinema.org account

故障排除

Screenshot uses old screen state

See KDE#Spectacle screenshot uses old screen state

NVIDIA clipping background

If the NVIDIA driver is in use and the screen recording is experiencing background clipping, enable the ForceCompositionPipeline setting. See NVIDIA/Troubleshooting#Avoid screen tearing for details。