MIPS | Malaysian Informatics And Programming Society

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

You need to have FFmpeg installed on your system. See platform-specific instructions below for installation guidance.

Windows Instructions

Installation

  1. 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).
  2. 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.
  3. (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 running ffmpeg from any command prompt location. If you skip this step, you must navigate to the bin directory first before running commands.

Recording

  1. Open Command Prompt: Open a Windows Command Prompt or PowerShell window.
  2. 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
    
  3. 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.
  4. Stop Recording: To finish the recording, switch focus back to the Command Prompt window where FFmpeg is running and press the q key.

Playback

macOS Instructions

Installation

The easiest way to install FFmpeg on macOS is using Homebrew:

brew install ffmpeg

Recording

  1. 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.
  2. 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>.

  3. 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.
  4. Stop Recording: Bring the Terminal window into focus and press the q key.

Playback

Linux Instructions

Installation

Use your distribution’s package manager.

Recording

  1. 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 (like wf-recorder). The command above will likely not work.
  2. Stop Recording: Bring the terminal window into focus and press the q key.

Playback

Command Parameters Explained

Here’s a breakdown of the parameters used in the commands above: