FFmpeg is a powerful command-line tool for handling multimedia data. It can be used for efficient, low-resource screen recording, making it suitable for proctoring purposes where minimal system impact and reasonable file sizes are desired. This guide provides instructions for installing and using FFmpeg on Windows, macOS, and Linux using consistent parameters focused on low bitrate output.
The goal is to create screen recordings using settings like low frame rates and low bitrates, resulting in significantly compressed MP4 or MKV files appropriate for review without consuming excessive disk space or system resources during recording.
- Prerequisites
- Windows Instructions
- macOS Instructions
- Linux Instructions
- Command Parameters Explained
Prerequisites
You need to have FFmpeg installed on your system. See platform-specific instructions below for installation guidance.
Windows Instructions
Installation
- Download: Obtain the FFmpeg “essentials” build for Windows. A common source is Gyan.dev. Download the
ffmpeg-release-essentials.zip
file. (As of early 2025, recent versions should work well). - Extract: Unzip the downloaded file to a location of your choice. For simplicity, you might place it in your user directory and rename the extracted folder to simply
ffmpeg
. Example path:C:\Users\YourUsername\ffmpeg
. - (Optional but Recommended) Add to Path: For easier use, you can add the
bin
subdirectory within your FFmpeg installation folder (e.g.,C:\Users\YourUsername\ffmpeg\bin
) to your system’s PATH environment variable. This allows runningffmpeg
from any command prompt location. If you skip this step, you must navigate to thebin
directory first before running commands.
Recording
- Open Command Prompt: Open a Windows Command Prompt or PowerShell window.
- Navigate to FFmpeg (if not in PATH): If you didn’t add FFmpeg to your PATH, navigate to the directory containing
ffmpeg.exe
. Example:cd C:\Users\YourUsername\ffmpeg\bin
-
Start Recording: Execute the following command in one single line. Replace
<video_filename>.mp4
with your desired output file name (e.g.,proctoring_session_YourName.mp4
). See the ‘Command Parameters Explained’ section below for details on each option.ffmpeg -f gdigrab -r 2 -probesize 40M -threads 1 -i desktop -vcodec libx264 -b:v 256k -pix_fmt yuv420p <video_filename>.mp4
- Note: If FFmpeg is in your PATH, you can run this command from any directory without the
./
prefix.
- Note: If FFmpeg is in your PATH, you can run this command from any directory without the
- Stop Recording: To finish the recording, switch focus back to the Command Prompt window where FFmpeg is running and press the
q
key.
Playback
- You can typically play the recording by double-clicking the generated
.mp4
file in File Explorer. - Alternatively, use
ffplay
from the command line (if available in your FFmpeg build/path):ffplay <video_filename>.mp4
macOS Instructions
Installation
The easiest way to install FFmpeg on macOS is using Homebrew:
brew install ffmpeg
Recording
- Permissions: The first time you try to record the screen, macOS will likely prompt you to grant permission to your terminal application (e.g., Terminal.app, iTerm2) for “Screen Recording” under
System Settings
>Privacy & Security
>Screen Recording
. You must grant this permission. - Identify Screen Input Device: Run this command first to see available video devices:
ffmpeg -f avfoundation -list_devices true -i ""
Look through the output under “AVFoundation video devices”. Find the line that mentions
Capture screen
(e.g.,[AVFoundation input device @ 0x...] [1] Capture screen 0
). Note the index number in the square brackets (e.g.,1
). This is your<screen_index>
. -
Start Recording: Open the Terminal application. Run the following command, replacing
<screen_index>
with the number found above and<video_filename>.mp4
with your desired file name. See the ‘Command Parameters Explained’ section below for details on each option.ffmpeg -f avfoundation -r 2 -probesize 40M -threads 1 -i "<screen_index>" -vcodec libx264 -b:v 256k -pix_fmt yuv420p <video_filename>.mp4
- Note: This command captures video only. Capturing audio requires identifying the audio device index and modifying the
-i
option (e.g.,-i "<screen_index>:<audio_index>"
), which is often unnecessary for simple proctoring.
- Note: This command captures video only. Capturing audio requires identifying the audio device index and modifying the
- Stop Recording: Bring the Terminal window into focus and press the
q
key.
Playback
- Double-click the
.mp4
file in Finder to open it with QuickTime Player or another default media player. - Use
ffplay
in the terminal:ffplay <video_filename>.mp4
Linux Instructions
Installation
Use your distribution’s package manager.
- Debian/Ubuntu:
sudo apt update && sudo apt install ffmpeg
- Fedora:
sudo dnf install ffmpeg
- Arch Linux:
sudo pacman -S ffmpeg
Recording
-
Start Recording (Xorg): Open a terminal. Run the following command, replacing
<video_filename>.mp4
with your desired file name. This typically works on systems using the Xorg display server. See the ‘Command Parameters Explained’ section below for details on each option.ffmpeg -f x11grab -r 2 -probesize 40M -threads 1 -i :0.0 -vcodec libx264 -b:v 256k -pix_fmt yuv420p <video_filename>.mp4
- Note: FFmpeg using
x11grab
generally captures the entire screen connected to display:0.0
by default. If the capture area is incorrect, add the-video_size <width>x<height>
option (e.g.,-video_size 1920x1080
) immediately before the-i :0.0
flag. - Wayland Users: Screen capture on Wayland typically requires different methods than
x11grab
. Investigate tools compatible with your Wayland compositor (likewf-recorder
). The command above will likely not work.
- Note: FFmpeg using
-
Stop Recording: Bring the terminal window into focus and press the
q
key.
Playback
- Use your default system media player (like VLC, Totem, etc.) by double-clicking the file.
- Use
ffplay
in the terminal:ffplay <video_filename>.mp4
Command Parameters Explained
Here’s a breakdown of the parameters used in the commands above:
-f <format>
: Specifies the input format/device driver.gdigrab
: Used on Windows for capturing the screen.avfoundation
: Used on macOS for accessing input devices, including the screen.x11grab
: Used on Linux (with Xorg display server) for capturing the screen.
-r <rate>
: Sets the output frame rate (frames per second).2
: Used in the examples. This very low rate significantly reduces file size and CPU load, making it suitable for proctoring where smooth motion is not required, only periodic snapshots of screen activity.
-probesize <size>
: Sets the initial buffer size FFmpeg uses to analyze the input stream.40M
: Used in the examples (40 Megabytes). This can sometimes help FFmpeg start faster or avoid issues analyzing the desktop input, especially on Windows. Optional.
-threads <count>
: Limits the number of CPU threads used for encoding.1
: Used in the examples. Restricting to a single thread minimizes the performance impact on the system during recording, which is important for proctoring. Optional; removing it lets FFmpeg use more threads (potentially faster encoding but higher CPU usage).
-i <input>
: Specifies the input source.desktop
: Used withgdigrab
on Windows to select the entire desktop."<screen_index>"
: Used withavfoundation
on macOS, where<screen_index>
is the number identifying the screen capture device (found using-list_devices true
).:0.0
: Used withx11grab
on Linux, typically referring to the primary display and its entire screen area.
-video_size <width>x<height>
or-s <width>x<height>
: (Optional) Explicitly sets the capture resolution. While often automatically detected (especiallyx11grab
), this can be added before the-i
flag if needed (e.g.,-video_size 1920x1080
).-vcodec <codec>
: Specifies the video codec for encoding the output file.libx264
: Selects the widely used H.264 codec (via the high-qualitylibx264
library), offering good compression.
-b:v <bitrate>
: Sets the target video bitrate.256k
: Used in the examples (256 kilobits per second). This forces a low bitrate, prioritizing small file size over high visual quality, consistent with proctoring requirements. Increase this (e.g.,512k
,1000k
) for better quality if needed, resulting in larger files.
-pix_fmt <format>
: Sets the output pixel format.yuv420p
: A common format ensuring compatibility with most players and web browsers.
<video_filename>.mp4
: The name for your output video file.- You can replace
.mp4
with.mkv
if preferred. MKV (Matroska) containers can sometimes be more robust against corruption if the recording process is interrupted unexpectedly.
- You can replace