スクリーンキャプチャ

提供: ArchWiki
2023年3月15日 (水) 13:36時点におけるKusanaginoturugi (トーク | 投稿記録)による版 (→‎専用のソフトウェア: 記事を追加)
ナビゲーションに移動 検索に移動

関連記事

この記事では、スクリーンショットスクリーンキャストのソフトウェアを一覧にして解説しています。

スクリーンショットソフトウェア

専用のソフトウェア

  • CoreShot — Simple lightweight screen capture utility for X11. Part of C-Suite.
https://cubocore.org/ || coreshotAUR
  • Deepin Screenshot — とても使いやすいスクリーンショットツール。機能: スクリーンショットツールを発動するホットキー、選択した領域のスクリーンショットの取得、スクリーンショットに文章や線画を簡単に追加。Python/Qt5 ベース。
https://www.deepin.org/ || deepin-screenshot
  • Escrotum — pygtk を使用して画面をキャプチャ。scrot の影響を受けています。
https://github.com/Roger/escrotum || escrotum-gitAUR
  • Flameshot — インタラクティブにスクリーンショットを取得できる Qt5 ベースのソフトウェア。取得したいエリアを選択して様々なツールで落書きしたりカスタマイズする機能があります。
https://github.com/lupoDharkael/flameshot || flameshot
  • gnome-screenshot — dconf, gtk3, libcanberra にしか依存しないため GNOME 以外でも使えます。
http://gnome.org || gnome-screenshot
  • gscreenshot — シンプルな GTK スクリーンショットユーティリティ。遅延時間を設定したり範囲選択・クリップボードにコピーする機能があります。
https://github.com/thenaterhood/gscreenshot || gscreenshotAUR
  • imgur-screenshot — スクリーンショットを取得して imgur にアップロードするツール。
https://github.com/jomo/imgur-screenshot || imgur-screenshot-gitAUR
  • KShare — ShareX の影響を受けているクロスプラットフォームのユーティリティ。Qt で書かれています。
https://kshare.arsenarsen.com || kshareAUR
  • Lightscreen — 退屈なスクリーンショットの保存とカタログ化を自動化するシンプルなツール。表には現れないバックグラウンドプロセスとして動作し、(複数の) ホットキーで呼び出してスクリーンショットファイルをユーザーの設定にあわせてディスクに保存する。
http://lightscreen.com.ar || lightscreenAUR
  • maim — スクリーンショットを取得するシンプルなコマンドラインユーティリティ。scrot を置き換えるものとして様々な点で scrot よりも優れています。
https://github.com/naelstrof/maim || maim
  • screencloud — 画面全体のスクリーンショットや領域を選択して撮影し、imgur+auth にスクリーンショットをアップロードできるツール。プラグインとシステムトレイが付属。
http://screencloud.net/ || screencloudAUR
  • screengrab — スクリーンショットを手軽に取得するためのクロスプラットフォームのアプリケーション (Qt)。
http://screengrab.doomer.org/ || screengrab
  • Scrot — X 向けのシンプルなコマンドラインスクリーンショットユーティリティ。
http://freecode.com/projects/scrot || scrot
  • Shutter — リッチなスクリーンショット・編集プログラム。
http://shutter-project.org/ || shutterAUR
  • Spectacle — スクリーンショットを撮るための KDE のアプリケーション。デスクトップ全体、単一のウィンドウ、ウィンドウの一部、四角形またはフリーハンドで指定した領域の画面をキャプチャすることができます。kdegraphics[リンク切れ: パッケージが存在しません] に含まれています。
https://github.com/KDE/spectacle/ || spectacle
  • Xfce4 Screenshooter — 画面全体、アクティブウィンドウ、または選択領域のキャプチャを行えます。スクリーンショットを撮るまでの待機時間とスクリーンショットを撮った後の動作を設定できます: PNG ファイルに保存、クリップボードにコピー、別のアプリケーションで開く、無料の画像ホスティングサービスである Imgur や ZimageZ にアップロード。xfce4-goodies に含まれています。
https://goodies.xfce.org/projects/applications/xfce4-screenshooter || xfce4-screenshooter
  • xwd — X Window System イメージダンプユーティリティ。
http://xorg.freedesktop.org/ || xorg-xwd


xwd

xwd(1) is provided by xorg-xwd.

To take a screenshot of the root window:

$ xwd -root -out screenshot.xwd
ヒント: To obtain a delay before taking a screenshot, use the sleep command. For example: sleep 5; xwd ....

scrot

scrot enables taking screenshots from the CLI and offers features such as a user-definable time delay. Unless instructed otherwise, it saves the file in the current working directory.

$ scrot -t 20 -d 5

The above command saves a dated .png file, along with a thumbnail (20% of original), for Web posting. It provides a 5 second delay before capturing in this instance.

You can also use standard date and time formatting when saving to a file. e.g.,

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

saves the screenshot in a filename with the current year, month, date, hours, minutes, and seconds to a folder in your home directory called "screenshots"

See scrot(1) for more information.

ノート: In some window managers (dwmAUR, xmonad and possibly others) scrot -s does not work properly when running via window manager's keyboard shortcut, this can be worked around by prepending scrot invocation with a short pause sleep 0.2; scrot -s.

escrotum

escrotum-gitAUR screen capture using PyGTK, inspired by scrot

Created because scrot has glitches when selection mode is used with refreshing windows.

Because the command line interface its almost the same as scrot, can be used as a replacement of it.

maim

maim is aimed to be an improved scrot.

Save the full screen to file:

$ maim filename

Prompt for selection and save to file:

$ maim --select filename

Save the active window to file, assuming xdotool is installed:

$ maim --window $(xdotool getactivewindow) filename

Prompt for selection, save without cursor, and store it to clipboard, assuming xclip is installed:

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

デスクトップ環境による方法

Spectacle

KDE を使っている場合、Spectacle を使用すると良いでしょう。Prnt Scr で使うことができます。

Spectacle は spectacle に入っています。

Xfce Screenshooter

Xfce を使っている場合 xfce4-screenshooter をインストールしてキーボードバインディングを追加することができます:

Xfce Menu > Settings > Keyboard > Application Shortcuts

Screenshot プロンプトをスキップしたい場合は、オプションのターミナルに $ xfce4-screenshooter -h と入力してください。

GNOME

GNOME ユーザーは Prnt Scr を押すか Apps > Accessories > Take Screenshot でスクリーンショットが取れます。gnome-screenshot をインストールする必要があります。

Cinnamon

Cinnamon はデフォルトでスクリーンショットユーティリティがインストールされません。gnome-screenshot をインストールするとスクリーンショットが有効になり、Menu > Accessories > Screenshot または Prnt Scr を押すことで撮影できるようになります。

他のデスクトップ環境やウィンドウマネージャ

LXDE などのデスクトップ環境や OpenboxCompiz などのウィンドウマネージャの場合、上述のコマンドをホットキーに追加してスクリーンショットを撮影することができます。例えば:

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

上のコマンドを Prnt Scr キーに追加すれば Compiz でスクリーンショットを取得して Pictures フォルダに日付を付けて保存できます。Openbox の rc.xml ファイルではコンマを使えないので、Openbox でこのコマンドを Prnt Scr キーに指定するには、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>

上記の Print が動作しない場合、特別なキーボードキーをみて、別のキーシムキーコードを使って下さい。 LXDE などのデスクトップ環境や OpenboxCompiz などのウィンドウマネージャの場合、上述のコマンドをホットキーに追加してスクリーンショットを撮影することができます。例えば:

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

上のコマンドを Prnt Scr キーに追加すれば Compiz でスクリーンショットを取得して Pictures フォルダに日付を付けて保存できます。Openbox の rc.xml ファイルではコンマを使えないので、Openbox でこのコマンドを Prnt Scr キーに指定するには、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>

上記の Print が動作しない場合、特別なキーボードキーをみて、別のキーシムキーコードを使って下さい。 Xfce を使っている場合 xfce4-screenshooter をインストールしてキーボードバインディングを追加することができます:

Xfce Menu > Settings > Keyboard > Application Shortcuts

Screenshot プロンプトをスキップしたい場合は、オプションのターミナルに $ xfce4-screenshooter -h と入力してください。

スクリーンショットユーティリティが含まれているパッケージ

ImageMagick/GraphicsMagick

See ImageMagick#Screenshot taking.

GIMP

GIMP を使ってスクリーンショットを取得することもできます (File > Create > Screenshot...)。

imlib2

imlib2 にはスクリーンショットを取得するためのバイナリ imlib2_grab が含まれています。フルスクリーンのスクリーンショットを取得するには、次を入力:

$ imlib2_grab screenshot.png

FFmpeg

FFmpeg#スクリーンキャプチャを参照。

一般的な方法

ImageMagick/GraphicsMagick

import コマンドを使うことで現在のシステムのスクリーンショットを簡単に取得できます:

$ import -window root screenshot.jpg

importimagemagick パッケージに入っています。

-window オプションを付けずに import を実行するとウィンドウや任意の領域をインタラクティブに選択することが可能です。

ノート: graphicsmagick を使いたい場合は、"gm" を前に付けて下さい、例: $ gm import -window root screenshot.jpg

複数の X 画面のスクリーンショット

twinview または dualhead で使っている場合、2回スクリーンショットを取得して imagemagick を使って貼り付けます:

import -window root -display :0.0 -screen /tmp/0.png
import -window root -display :0.1 -screen /tmp/1.png
convert +append /tmp/0.png /tmp/1.png screenshot.png
rm /tmp/{0,1}.png

Xinerama ヘッドのスクリーンショット

Xinerama による multi-head セットアップでは仮想スクリーンが一つしかありません。物理的なスクリーンの高さに違いがあると、スクリーンショットにデッドスペースが出来てしまいます。こういう場合、それぞれの物理的なスクリーンごとにスクリーンショットを取得すると良いでしょう。Xinerama の情報が X サーバーから取り出せていれば、以下のスクリプトが動作します:

#!/bin/sh
xdpyinfo -ext XINERAMA | sed '/^  head #/!d;s///' |
while IFS=' :x@,' read i w h x y; do
        import -window root -crop ${w}x$h+$x+$y head_$i.png
done

アクティブなウィンドウ/フォーカスしたウィンドウのスクリーンショット

以下のスクリプトは現在フォーカスされているウィンドウのスクリーンショットを取得します。EWMH/NetWM 準拠の X ウィンドウマネージャで動作します。スクリーンショットを上書きしないように、ファイル名に取得時刻を使っています。

#!/bin/sh
activeWinLine=$(xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)")
activeWinId=${activeWinLine:40}
import -window "$activeWinId" /tmp/$(date +%F_%H%M%S_%N).png

もしくは、次のコマンドは EWMH をサポートしているかどうかに関わらず動作します:

$ import -window "$(xdotool getwindowfocus -f)" /tmp/$(date +%F_%H%M%S_%N).png
ノート: (dwb や zathura) プログラムのスクリーンショットが空になる場合は、xdotool コマンドに -frame を付けたり -f を削除してみてください。

xwd

ルートウィンドウのスクリーンショットを取得:

$ xwd -root -out screenshot.xwd
ノート: import でアクティブウィンドウのスクリーンショットを取得する方法でも xwd を使うことができます。

scrot

scrot を使えば CLI からスクリーンショットを撮ることができ、シャッターを押すまでの待機時間をユーザーが定義できるなどの機能があります。特に指定がなければ、カレントディレクトリにファイルが保存されます。

$ scrot -t 20 -d 5

上記のコマンドは日付が入った .png ファイルが作成され、ウェブ投稿用にサムネイルも作られます (元の画像の 20%)。上の例ではキャプチャするまで5秒間待ちます。

ファイルに保存するときに標準的な日付のフォーマットを使うこともできます、例えば:

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

このコマンドではホームディレクトリの "screenshots" という名前のフォルダに、現在の年・月・日・時間・分・秒がファイル名のスクリーンショットが保存されます。

詳しくは scrot(1) を見て下さい。[1] のようにファイルのアップロードを自動化することもできます。

ノート: 一部のウィンドウマネージャでは (dwmxmonad など)、scrot -s がウィンドウマネージャのキーボードショートカットで正しく動作しないことがあります。scrot を実行する前に短いポーズを挟むことで問題を解決できます: sleep 0.2; scrot -s

escrotum

escrotum-gitAUR は pygtk を使って画面をキャプチャします。scrot にインスパイアされています。

選択モードを使った時に scrot ではウィンドウのリフレッシュでバグが発生するので開発されました。

コマンドラインインターフェースは scrot とほぼ同じなので、そのまま同じように使うことができます。

maim

maim は scrot の向上版を目指しています。

scrot の欠点を補っており slop で領域のスクリーンショットを取得します。

FFmpeg

FFmpeg は X11 のスクリーンをキャプチャできる x11grab デバイスを提供しています。

ディスプレイの横幅x高さを指定してスクリーンショットを取得:

$ ffmpeg -f x11grab -video_size widthxheight -i $DISPLAY -vframes 1 screen.png

上記のコマンドでは PNG コーデック (ロスレスでスクリーンショットに向いている) を使っていますが、他の画像コーデックも使うことができます。

同じデバイスを使ってスクリーンキャストも可能です (ディスプレイのリフレッシュレートを rate HZ で指定):

$ ffmpeg -f x11grab -video_size widthxheight -framerate rate -i $DISPLAY -c:v libx264 -preset ultrafast cast.mkv

上記のコマンドでは、エンコード速度が一番高速な x264 コーデックを使っていますが、他のコーデックも使えます。ただし (ディスクのパフォーマンスが足りなかったりエンコードが遅かったりして) フレームの書き込みが遅すぎると、フレームが抜け落ちて出力された動画は飛び飛びになります。

Weston

Wayland のコンポジットマネージャである Weston では、Super+s を押すことでスクリーンショットを撮影することができ、Weston の現在の作業ディレクトリに保存されます。スクリーンキャストもサポートされています。録画の開始と停止は Super+r を押すことで行われ、Weston の現在の作業ディレクトリに capture.wcap という名前のファイルが作成されます。wcap-decode --yuv4mpeg2 capture.wcap を実行することでキャプチャを YUV フォーマットにデコードできます。このコマンドの出力をファイルに書き込んだり、FFmpeg にパイプして更に処理を加えることもできます。

スクリーンキャスト ソフトウェア

See also FFmpeg#Screen capture and Wikipedia:Comparison of screencasting software.

Screencast utilities allow you to create a video of your desktop or individual windows.

  • Byzanz — Simple screencast tool that produces GIF animations.
https://gitlab.gnome.org/Archive/byzanz || byzanz
  • Deepin Screen Recorder — Screen recorder application for Deepin desktop.
https://www.deepin.org/en/original/deepin-screen-recorder/ || deepin-screen-recorder
  • FFcast — FFmpeg-based screencast tool written in Bash.
https://github.com/lolilolicon/FFcast || ffcastAUR
  • Gpu Screen Recorder — Screen recorder that captures a video on the GPU only to vastly improve performance, comparable to Nvidia ShadowPlay. Supports live streaming and replay buffer as well. Currently limited to NVIDIA.
https://git.dec05eba.com/gpu-screen-recorder-gtk/about/ || gpu-screen-recorder-gtk-gitAUR
  • Green Recorder — Simple yet functional desktop recorder for Linux systems.
https://github.com/dvershinin/green-recorder || green-recorderAUR
  • Kazam — Screencasting program with design in mind. Handles multiscreen setups.
https://launchpad.net/kazam || kazamAUR
  • Kooha — Simple screen recorder with a minimal GTK interface.
https://github.com/SeaDve/Kooha || kooha
  • menyoki — Screen{shot,cast} and perform ImageOps on the command line.
https://github.com/orhun/menyoki || menyoki
https://obsproject.com/ || obs-studio
  • Peek — Simple screencast tool that produces GIF, APNG, WebM or MP4 animations.
https://github.com/phw/peek || peek
  • RecApp — User friendly screencaster written in GTK. Using free GStreamer modules and not depend on FFmpeg. No longer under development.
https://github.com/amikha1lov/RecApp || recapp-gitAUR
  • RecordItNow — Plugin based desktop recorder for KDE 4.
http://recorditnow.sourceforge.net/ || recorditnowAUR
  • RecordMyDesktop — Easy to use utility that records your desktop into the ogg format with a CLI, GTK or Qt interface. (inactive development)
http://recordmydesktop.sourceforge.net/ || CLI: recordmydesktop, GTK: gtk-recordmydesktopAUR, Qt: qt-recordmydesktopAUR
  • screencast — Command line interface to record an X11 desktop using FFmpeg, having support for offline recording and live streaming.
https://github.com/dbermond/screencast/ || screencastAUR
  • Screencast — Simple screencast recorder designed for elementary OS.
https://github.com/artemanufrij/screencast || pantheon-screencastAUR
  • SimpleScreenRecorder — Feature-rich screen recorder written in C++/Qt5 that supports X11 and OpenGL.
https://www.maartenbaert.be/simplescreenrecorder/ || simplescreenrecorder
  • VokoScreen — Simple screencast GUI tool using GStreamer.
https://linuxecke.volkoh.de/vokoscreen/vokoscreen.html || vokoscreen
  • XVidCap — Application used for recording a screencast or digital recording of an X Window System screen output with an audio narration.
http://xvidcap.sourceforge.net/ || xvidcapAUR

Wayland

wlroots ベースのコンポジタで画面をキャプチャするには、スクリーンショットの場合は grim または swayshotAUR、ビデオの場合は wf-recorder (または wf-recorder-gitAUR) を使用します。wlrobs-hgAUR は、wlroot ベースのコンポジタでのスクリーンキャプチャーを可能にする obs-studioプラグインです。必要に応じて、slurp を使用してキャプチャする画面の部分を選択できます。

画面全体のスクリーンショットを撮ります。

$ grim screenshot.png

現在のウィンドウのスクリーンショットを撮る。

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

画面の一部のスクリーンショットを撮ります。

$ grim -g "$(slurp)" screenshot.png

画面の一部のスクリーンショットを取得し、wl-clipboard を使用してクリップボードに出力します。

$ grim -g "$(slurp)" - | wl-copy

画面全体のビデオをキャプチャする。

$ wf-recorder -f recording.mp4

画面の一部のビデオをキャプチャする。

$ wf-recorder -g "$(slurp)"
ヒント:
  • slurpshot を使用してスクリプトを撮るインタラクティブなスクリーンショットです bemenu
  • swappy キャプチャ後のスクリーンショット編集および描画ツールを使用するには grim -g "$(slurp)" - | swappy -f -

また、上記の一部のプログラムは Wayland (例:ksnipgreen-recorderAUR) で動作します。

スクリーンキャスト

GNOME スクリーンキャストより

green-recorderAURobs-gnome-screencastAUR、および obs-xdg-portal-gitAUR は、GNOME スクリーンキャスト機能を使用した Wayland でのスクリーンレコーディングをサポートしています。

仮想 Web カメラのビデオフィード経由

ヒント:
  • このメソッドは zoomAUR (xorg-xwayland で実行されるデスクトップ・クライアント) および chrome (firefox で実行される BigBlueButton) でテストされています (firefox では解像度が非常に低くなります) skypeforlinux-stable-binAUR は仮想ビデオデバイス VirtualVideoDevice を検出しますが、空白の画面を出力します。
  • この例では wf-recorder を使用していますが、出力を仮想デバイスに送信するだけで、任意のソフトウェアを使用できます。

wf-recorder (または wf-recorder-gitAUR) および v4l2loopback-dkms をインストールします。次のパラメータを指定して v4l2loopback カーネルモジュールをロードします。

# modprobe v4l2loopback exclusive_caps=1 card_label=VirtualVideoDevice

新しい仮想ビデオデバイス VirtualVideoDevice が作成されたことを確認します。

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

wf-recorder を使用して画面の記録を開始し、v4l2loopback によって作成された新しい仮想ビデオデバイス VirtualVideoDevice に出力を送ります。

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

ビデオ出力をズーム [2] と互換性を持たせるには、yuv420p 色空間が必要です。

上記の仮想ビデオデバイスをビデオ通話/ビデオ会議アプリケーションの "ウェブカメラ" として選択できるようになりました (デバイスの名前は VirtualVideoDevice) ffplay (ffmpegの一部) 、mpv、または gst-launch (gstreamer の一部) を使用して、仮想ビデオデバイスが実際にスクリーン共有を出力していることを確認できます。

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

Firefox がビデオストリームを読み取ることができず、"AbortError: Starting video failed" のようなメッセージを出力する場合は、プリロードを試してください v4l2compat.so:

$ LD_PRELOAD=/usr/lib/v4l1compat.so firefox
個々のアプリケーションの共有
警告: ウィンドウのサイズを変更しても、共有されている領域は変更されないため、このメソッドには個々のアプリケーション共有の適切な実装は含まれません。

前述のように、wf-recorder では、まず slurp で領域を選択することで、画面の一部のみを記録できます。この機能を使用して、仮想ビデオデバイスを介して特定のリージョンまたはアプリケーションウィンドウを共有するには、次の変更されたコマンドで画面の記録を開始します。

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

画面の領域を選択すると、上記のように仮想ビデオデバイス /dev/video2 からビデオフィードにアクセスできるようになります。

WebRTC プロトコル経由

警告: このメソッドでは、出力全体の共有のみが許可され、個々のアプリケーション [3] の共有は許可されません。

こちらを参照 PipeWire#WebRTC screen sharing.

これで Chromium と Firefox からスクリーンシェアにアクセスできるようになります。こちらを参照、 Mozilla's getUserMedia/getDisplayMedia Test Page

ターミナル

ansi コードで出力

util-linux パッケージに含まれている、script コマンドを使うことができます。$ script と入力すればその瞬間から、全ての出力は (ansi コードを含めて) typescript ファイルに保存されるようになります。

終わったら、exit と入力するだけで typescript が作成されます。作成されたファイルは AURansi2htmlAUR パッケージを使って html に変換できます。

typescript ファイルを typescript.html に変換するには、次を実行:

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

また、コマンドによっては直接 ansi2html にパイプで渡すこともできます:

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

どんなコマンドでも使えるというわけではないので、その場合は、script を使う必要があります。

フレームバッファ

フレームバッファをインストールして、fbgrabfbdump を使用して、スクリーンショットを撮ります。

仮想コンソール

Uvesafb をインストールして fbgrab または fbdump を使ってスクリーンショットを取得してください。

単にコンソールの文章を取得したいだけで画像は要らない場合、util-linux パッケージに含まれている setterm を使うことができます。以下のコマンドは仮想コンソール 1 のテキストをカレントディレクトリの screen.dump ファイルに保存します:

# setterm -dump 1 -file screen.dump

/dev/vcs1 の中身を読まないといけないので root 権限が必要です。